static void Main(string[] args) { var teacher = new Teacher("\"Uncle\" Bob", "Martin", new DateTime(1948, 10, 8)); var cleanCode = new Course("Clean Code 101", "McConnell", "42A", new[] { teacher }); var joe = new Student("Joe", "Smith", new DateTime(1985, 4, 13)); var john = new Student("John", "Doe", new DateTime(1984, 1, 31)); var jane = new Student("Jane", "Doe", new DateTime(1988, 9, 22)); cleanCode.Students.Add(joe); cleanCode.Students.Add(john); cleanCode.Students.Add(jane); foreach (Student student in cleanCode.Students) { AssignRandomGrades(student); } var compSci = new Degree("Computer Science", DegreeType.Bachelor); compSci.Courses.Add(cleanCode); var program = new UProgram("Information Technology", 30.5m); program.Degrees.Add(compSci); WriteProgramInfo(program); cleanCode.ListStudents(); }
static void Main(string[] args) { Student student1 = new Student("Ivan", "Ivanov", "Sofia", 1000, "Bulgaria", 12212); Student student2 = new Student("Petar", "Petrov", "Sofia", 1000, "Bulgaria", 12213); Student student3 = new Student("Todor", "Todorov", "Sofia", 1000, "Bulgaria", 12214); List <Student> students = new List <Student>(); students.Add(student1); students.Add(student2); students.Add(student3); Teacher teacher1 = new Teacher("Radomir", "Radomirov", "Sofia", 1000, "Bulgaria", 20); List <Teacher> teachers = new List <Teacher>(); teachers.Add(teacher1); for (int i = 0; i < 5; i++) { student1.Grades.Push(5); student2.Grades.Push(5); student3.Grades.Push(5); } Student.ListStudents(students); Course course = new Course("Programming with C#", students, teachers); Degree degree1 = new Degree("Bachelor", course, 120); UProgram programe = new UProgram("Information Technology", degree1); Console.WriteLine($"The {programe.ProgramName} program contains the {degree1.DegreeName} of Science degree"); Console.WriteLine(); Console.WriteLine($"The {degree1.DegreeName} of Science degree contains the course {course.CourseName}"); Console.WriteLine(); Console.WriteLine($"The {course.CourseName} course contains {Student.studentCounter} student<s>"); }
static void Main(string[] args) { Student student1 = new Student("Wang", "Gang", "April 23, 1983"); Student student2 = new Student("Tony", "Stark", "January 03, 1994"); Student student3 = new Student("Steve", "Rogers", "July 04, 1920"); Teacher teacher = new Teacher("Bill", "Gates", "April 05, 1960"); Course course = new Course("Programming with C#"); course.addteacher(teacher); for (int i = 0; i < 3; i++) { switch (i) { case 0: course.addstudent(student1); break; case 1: course.addstudent(student2); break; case 2: course.addstudent(student3); break; } } Degree degree = new Degree(course, "Bachelor of Science Degree"); UProgram uprogram = new UProgram(degree, "Information Technology"); ListStudents(course); }
private static void Main(string[] args) { var students = new List <Student>(); students.AddRange(CreateStudents()); var course = new Course { Name = "Programming with C#", Students = students }; var teacher = new Teacher { FirstName = "Nikiphor" }; course.Teachers[0] = teacher; var degree = new Degree { Name = "Bachelor", Course = course }; var program = new UProgram { Name = "Information Technology", Degree = degree }; // print the information about students ListStudents(students); // output from module 6 Console.WriteLine("The {0} program contains the {1} of Science degree", program.Name, program.Degree.Name); Console.WriteLine("The {0} of Science degree contains the course {1}", degree.Name, degree.Course.Name); Console.WriteLine("The {0} course contains {1} students", course.Name, course.Students.Count); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
static void Main(string[] args) { List<Student> students = new List<Student>(); // new empty arraylist //student 1 Student s1 = new Student("Angel", "Munoz", new DateTime(1992, 05, 16), "Dir1", "Juarez", "Chihuahua", 12345, "Mexico"); s1.Grades = new Stack<int>(5); s1.Grades.Push(10); s1.Grades.Push(9); s1.Grades.Push(8); s1.Grades.Push(9); s1.Grades.Push(8); // student 2 Student s2 = new Student("Perla", "Lopez", new DateTime(1992, 12, 10), "Dir1", "Juarez", "Chihuahua", 12345, "Mexico", "Dir2"); s2.Grades = new Stack<int>(5); s2.Grades.Push(8); s2.Grades.Push(9); s2.Grades.Push(8); s2.Grades.Push(9); s2.Grades.Push(10); // student 3 Student s3 = new Student("Victor", "Munoz", new DateTime(1992, 07, 10), "Dir1", "Juarez", "Chihuahua", 12345, "Mexico"); s3.Grades = new Stack<int>(5); s3.Grades.Push(9); s3.Grades.Push(9); s3.Grades.Push(8); s3.Grades.Push(9); s3.Grades.Push(8); // add students to the arraylist students.Add(s1); students.Add(s2); students.Add(s3); //teachers Teacher t1 = new Teacher("Dora", "Rivero", new DateTime(1980, 05, 16), "Dir1", "Juarez", "Chihuahua", 12345, "Mexico"); Teacher t2 = new Teacher("Ricardo", "Trejo", new DateTime(1981, 03, 19), "Dir1", "Juarez", "Chihuahua", 12345, "Mexico", "Dir2"); Teacher t3 = new Teacher("Victor", "Arellanes", new DateTime(1980, 05, 10), "Dir1", "Juarez", "Chihuahua", 12345, "Mexico"); Teacher[] teachers = { t1, t2, t3 }; Course PCS = new Course("Programming with C#", 15, 6, teachers, students); Course PFS = new Course("Programming with F#", 12, 7, teachers, students); Course PJ = new Course("Programming with Java", 15, 5, teachers, students); Course[] courses = { PCS, PFS, PJ }; Degree bachelor = new Degree("Bachelor", 500, courses); UProgram uprogram = new UProgram("Information Technology", "Mike Perez", bachelor); Console.WriteLine("Program: {0}\nDegree: {1}", uprogram.PName, uprogram.Degree.Name); Console.WriteLine("Course:{0}\nStudents in Course: {1}", uprogram.Degree.Courses[0].CName, Student.StudentAmt); foreach(Student student in PCS.Students) { student.TakeTest(); } foreach (Teacher teacher in PCS.Teachers) { teacher.GradeTest(); } // calling method on Course object to list the students in course PCS.ListStudents(); Console.ReadKey(); }
private static void WriteProgramInfo(UProgram program) { var degree = program.Degrees.First(); Console.WriteLine("The {0} program contains the {1} degree.\n", program.Name, degree); var course = degree.Courses.First(); Console.WriteLine("The {0} degree contains the course {1}.\n", degree, course); Console.WriteLine("The {0} course has {1} student(s).\n", course, course.Students.Count); }
private static void Main() { try { //Create 3 student objects. var students = new Students { new Student("Harry", "Potter", new DateTime(1980, 7, 31)), new Student("Ron", "Weasley", new DateTime(1980, 3, 1)), new Student("Hermione", "Granger", new DateTime(1979, 9, 19)) }; // Add 5 grades to the the Stack in the each Student object. // This does not have to be inside the constructor because you may not have grades for a student when you create a new student. foreach (var student in students) { student.Grades = new Stack <Grade>( Enumerable.Repeat(new Grade("Magic", 1), 5)); } var uProgram = new UProgram("Information Technology") { Degree = new Degree("Bachelor") { Course = new Course("Programming with C#") { // Add the three Student objects to the List<T> inside the Course object. Students = students, Teachers = new Collection <Teacher> { new Teacher("Remus", "Lupin", new DateTime(1960, 3, 10)) } } } }; // Call the ListStudents() method from Main(). uProgram.Degree.Course.ListStudents(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("Press any key to continue ..."); Console.ReadLine(); } }
static void Main(string[] args) { //Instantiate a UProgram object called Information Technology. UProgram prog = new UProgram("Information Technology", "Some One"); //Instantiate a Degree object, such as Bachelor. prog.Degrees.Add(new Degree("Bachelor Of Science", 84)); //Instantiate a Course object called Programming with C#. prog.Degrees[0].Courses.Add(new Course("Programming with C#", 3, 16)); /*Grading criterion 3- Added 3 Student objects to this * List<T> using the List<T> method for adding objects.*/ prog.Degrees[0].Courses[0].Students.Add(new Student ("Sophie", "Greene", new DateTime(1982, 12, 1), "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 4.0)); prog.Degrees[0].Courses[0].Students.Add(new Student ("Mandy", "Newton", new DateTime(1985, 11, 12), "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 3.4)); prog.Degrees[0].Courses[0].Students.Add(new Student ("Sophie", "Cry", new DateTime(1952, 1, 12), "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 2.7)); double[,] grds = new double[, ] { { 90, 30, 89, 90, 60 }, { 20, 50, 80, 70, 60 }, { 91, 92, 89, 77, 98 } }; //Add 5 grades to the the Stack in the each Student object. //(this does not have to be inside the constructor because //you may not have grades for a student when you create //a new student.) for (int i = 0; i < grds.GetLength(0); i++) { for (int j = 0; j < grds.GetLength(1); j++) { prog.Degrees[0].Courses[0].Students[i].Grades.Push(grds[i, j]); } } //Instantiate at least one Teacher object. prog.Degrees[0].Courses[0].Teachers.Add(new Teacher ("Manual", "Zu", new DateTime(1970, 1, 1), "30 Other Street", "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK", "Computing")); prog.Degrees[0].Courses[0].Teachers.Add(new Teacher ("Handy", "Man", new DateTime(1930, 10, 1), "30 Other Street", "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK", "Mathmatics")); //results output int input = 0; //exists only of input is 6 while (input != 6) { bool isVal = false; do { welMessage(); isVal = int.TryParse(Console.ReadLine(), out input); } while (!isVal); switch (input) { case 1: Console.Clear(); /*Grading criterion 4- Used a foreach loop to output * the first and last name of each Student in the List<T>.*/ Console.WriteLine("Printing Student List"); int cnt = 1; foreach (Student s in prog.Degrees[0].Courses[0].Students) { Console.WriteLine("{0}-{1} {2}", cnt, s.FirstName, s.LastName); cnt++; } Console.WriteLine(); break; case 2: Console.Clear(); Console.WriteLine("Before Sort >>>>"); prog.Degrees[0].Courses[0].ListStudents(); //sort students sortArr(prog.Degrees[0].Courses[0].Students); Console.WriteLine("After Sort >>>>"); //show students prog.Degrees[0].Courses[0].ListStudents(); break; case 3: //Call the ListStudents() method from Main(). Console.Clear(); prog.Degrees[0].Courses[0].ListStudents(); break; case 4: Console.Clear(); Console.WriteLine("Before Grade Change >>>>"); //show students prog.Degrees[0].Courses[0].ListStudents(); //remove last grade double g = prog.Degrees[0].Courses[0].Students[1].Grades.Pop(); Console.WriteLine("Grade {0} was updated to 99 for student {1} {2}", g, prog.Degrees[0].Courses[0].Students[1].FirstName, prog.Degrees[0].Courses[0].Students[1].LastName); //add new grade prog.Degrees[0].Courses[0].Students[1].Grades.Push(99); Console.WriteLine("After Grade Change >>>>"); //show students prog.Degrees[0].Courses[0].ListStudents(); break; case 5: Console.Clear(); Console.WriteLine("Before Grade Sort >>>>"); //show students prog.Degrees[0].Courses[0].ListStudents(); Console.WriteLine("AfterGrade Sort >>>>"); //Call the ListStudentsSortedGrds() method from Main(). prog.Degrees[0].Courses[0].ListStudentsSortedGrds(); break; default: break; } #region clear console Console.Write("Press Any Key to Continue"); Console.ReadKey(); Console.Clear(); #endregion } #region keep console window open Console.Write("Press Any Key to Continue"); Console.ReadKey(); Console.Clear(); #endregion }