//01. We are given a school. In the school there are //classes of students. Each class has a set of teachers. //Each teacher teaches a set of disciplines. Students have //name and unique class number. Classes have unique text identifier. //Teachers have name. Disciplines have name, number of lectures and //number of exercises. Both teachers and students are people. Students, //classes, teachers and disciplines could have optional comments (free text block). //Your task is to identify the classes (in terms of OOP) and their attributes //and operations, encapsulate their fields, define the class hierarchy and create //a class diagram with Visual Studio. static void Main() { School PMG = new School("PMG"); ClassOfStudents _11a = new ClassOfStudents("11 A"); Student pesho = new Student("Pesho", 1); Student gosho = new Student("Gosho", 2); _11a.AddStudent(pesho); _11a.AddStudent(gosho); Discipline math = new Discipline("Mathematics", 5, 10); Discipline physics = new Discipline("Physics", 5, 15); Teacher rangelova = new Teacher("Rangelova"); rangelova.AddComment("Az imam kozi"); rangelova.AddDiscipline(math); rangelova.AddDiscipline(physics); _11a.AddStudent(pesho); _11a.AddStudent(gosho); _11a.AddTeacher(rangelova); PMG.AddClass(_11a); }
static void Main() { Student student1 = new Student("Ivan", 15); Student student2 = new Student("Petkan", 17); Student student3 = new Student("Dragan", 19); Class osmiB = new Class("osmi B"); osmiB.SetOfStudents.Add(student1); osmiB.SetOfStudents.Add(student2); osmiB.SetOfStudents.Add(student3); Teacher teacher1 = new Teacher("Anatoli"); Teacher teacher2 = new Teacher("Cvetkan"); osmiB.SetOfTeachers.Add(teacher1); osmiB.SetOfTeachers.Add(teacher2); Discipline math = new Discipline("Math", 5, 4); Discipline history = new Discipline("History", 9, 8); Discipline geography = new Discipline("Geography", 4, 9); Discipline science = new Discipline("Science", 5, 4); teacher1.SetOfDisciplines.Add(math); teacher1.SetOfDisciplines.Add(history); teacher2.SetOfDisciplines.Add(geography); teacher2.SetOfDisciplines.Add(science); Console.WriteLine("The class {0} has those students : \n",osmiB.UnicTxtInd); Console.WriteLine(osmiB.StudentToString()); Console.WriteLine("Some teachers:"); Console.WriteLine(osmiB.TeacherToString()); teacher1.AddComment("This is some optional comment"); string comment=teacher1.ShowComment(); Console.WriteLine(comment); }
static void Main() { //define students Student firstStudent = new Student("Ivan Ivanov", 26); firstStudent.AddComment("I love school."); Student secondStudent = new Student("Kiril Stoianov", 21); secondStudent.AddComment("I hate school."); Student thirdStudent = new Student("Martin Hristov", 25); Student[] allStudents = { firstStudent, secondStudent, thirdStudent }; //define disciplines Discipline math = new Discipline("Math", 4, 4); math.AddComment("This is the hardest discipline, but it's very useful."); Discipline biology = new Discipline("Biology", 2, 2); Discipline chemistry = new Discipline("Chemistry", 1, 2); chemistry.AddComment("This is the most useless discipline."); Discipline[] allDisciplines = { math, biology, chemistry }; //define teachers and add disciplines Teacher firstTeacher = new Teacher("Nikolai Nikolov"); firstTeacher.AddDicipline(math); firstTeacher.AddDicipline(chemistry); Teacher secondTeacher = new Teacher("Silviq Stefanova"); secondTeacher.AddComment("She's a great teacher."); secondTeacher.AddDicipline(biology); Teacher[] allTeachers = { firstTeacher, secondTeacher }; //create class Class firstClassInSchool = new Class("12A"); //add students in class firstClassInSchool.AddStudents(allStudents); //add teachers for class firstClassInSchool.AddTeachers(allTeachers); Class[] allClasses = { firstClassInSchool }; //Define school and display information School mySchool = new School("1st Math Highschool"); //display info Console.WriteLine("-------{0}-------", mySchool.Name); Console.WriteLine(); Console.WriteLine("---Teachers---"); foreach (var teacher in allTeachers) { foreach (var discipline in teacher.AllDiciplines) { Console.WriteLine("{0} -> {1}", teacher, discipline); } } Console.WriteLine(); Console.WriteLine("---Classes---"); foreach (var schoolClass in allClasses) { Console.WriteLine(schoolClass); } Console.WriteLine(); //Display Comments Console.WriteLine("---Comments---"); foreach (var schoolClass in allClasses) { schoolClass.ViewComments(); } Console.WriteLine(); foreach (var student in allStudents) { student.ViewComments(); } Console.WriteLine(); foreach (var teacher in allTeachers) { teacher.ViewComments(); } Console.WriteLine(); foreach (var discipline in allDisciplines) { discipline.ViewComments(); } }