-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam_Students.cs
More file actions
executable file
·149 lines (120 loc) · 4.22 KB
/
Exam_Students.cs
File metadata and controls
executable file
·149 lines (120 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lecture7_Hometask
{
abstract class Person
{
private string name;
private string lastname;
public string Name { get { return name; } set { name = value; } }
public string LastName { get { return lastname; } set { lastname = value; } }
}
class Student : Person
{
private int mark;
public int Mark { get { return mark; } set { mark = value; } }
public Student(string name, string lastname)
{
this.Name = name;
this.LastName = lastname;
}
}
class Teacher : Person
{
private string department;
public string Department { get { return department; } set { department = value; } }
public Teacher(string name, string lastname, string department)
{
this.Name = name;
this.LastName = lastname;
this.Department = department;
}
}
class Group
{
private string number;
public string Number { get { return number; } set { number = value; } }
private int count;
public int Count { get { return count; } set { count = value; } }
private Student[] myList;
public Student[] MyList { get { return myList; } /* set { myList = value; } */ }
public Group(string number, int count)
{
this.Number = number;
this.Count = count;
this.myList = new Student[count];
}
public void AddStudents()
{
for (int i = 0; i < myList.Length; i++)
{
string studentname;
string studentlastname;
Console.WriteLine("Enter student Name");
studentname = Console.ReadLine();
Console.WriteLine("Enter student Lastname");
studentlastname = Console.ReadLine();
Student newstudent = new Student(studentname, studentlastname);
myList[i] = newstudent;
}
}
}
class Exam
{
public string Subj;
Teacher Teach;
Group Group;
public Exam(string subj, Teacher teach, Group group)
{
this.Group = group;
this.Teach = teach;
this.Subj = subj;
}
public void ProcessExam()
{
Random rnd = new Random();
for (int i = 0; i < Group.MyList.Length; i++)
{
Group.MyList[i].Mark = rnd.Next(60, 100);
}
}
public void ResultExam()
{
Console.WriteLine("\nSubject: {0}\n Group name: {1}\n Group count: {2}\n Teacher Lastname: {3}", Subj, Group.Number, Group.Count, Teach.LastName);
Console.WriteLine("\n{0,29}\n", "Students Marks");
for (int i = 0; i < Group.MyList.Length; i++)
{
Console.WriteLine("{0,13} {1,13} {2,7}", Group.MyList[i].Name, Group.MyList[i].LastName, Group.MyList[i].Mark);
}
}
public void Certificate()
{
//Additional function to certificate students
Console.WriteLine("\nCertified students");
for (int i = 0; i < Group.MyList.Length; i++)
{
if (Group.MyList[i].Mark >= 90)
{
Console.WriteLine("{0,2} {1,2} has reached {2,2} mark", Group.MyList[i].Name, Group.MyList[i].LastName, Group.MyList[i].Mark);
}
}
}
}
class Program
{
static void Main(string[] args)
{
Group firstgroup = new Group("RE-22", 5);
firstgroup.AddStudents();
Teacher firstteacher = new Teacher("Vladimir", "Semonov", "ElectricSystems");
Exam firstexam = new Exam("Mathematics", firstteacher, firstgroup);
firstexam.ProcessExam();
firstexam.ResultExam();
firstexam.Certificate();
Console.ReadKey();
}
}
}