Exemplo n.º 1
0
        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);
            ArrayList students = new ArrayList();

            students.Add(student1);
            students.Add(student2);
            students.Add(student3);
            Teacher   teacher1 = new Teacher("Radomir", "Radomirov", "Sofia", 1000, "Bulgaria", 20);
            ArrayList teachers = new ArrayList();

            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>");
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            var students = new ArrayList();

            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();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ArrayList students = new ArrayList(); // 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();
            }
            PCS.ListStudents();
            Console.ReadKey();
            
        }
Exemplo n.º 5
0
        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 obj in students)
                {
                    for (var i = 0; i < 5; i++)
                    {
                        var student = obj as Student;
                        if (student != null)
                        {
                            student.Grades.Push(new Grade("Magic", 1));
                        }
                    }
                }

                var uProgram = new UProgram("Information Technology")
                {
                    Degree = new Degree("Bachelor")
                    {
                        Course = new Course("Programming with C#")
                        {
                            //Add the three Student objects to the Students ArrayList 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();
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            Student student1 = new Student("Richard", "VanSickle", new DateTime(1986, 3, 10), "169 Saxony Rd", "#212", "Encinitas", "CA", "92024", "USA", "A12245", 3.95);
            Student student2 = new Student("Bob", "Smith", new DateTime(1975, 5, 11), "123 Main St", "", "Pleasantville", "CA", "92123", "USA", "A15826", 2.33);
            Student student3 = new Student("Mary", "Jones", new DateTime(1991, 7, 22), "17 South St", "#246", "San Diego", "CA", "90007", "USA", "B00506", 3.10);

            Course course1 = new Course("Programming with C#", 5, 12);

            Teacher teacher1 = new Teacher("Professor", "Longhair", new DateTime(1946, 3, 15), "19 Hollow Rd", "", "New Orleans", "LA", "70056", "USA", new DateTime(1986, 5, 10), 45457, "C Major");

            Degree degree1 = new Degree("Bachelor of Science", 132);

            UProgram uProgram1 = new UProgram("Computer Science", "Sandy Beach");

            // Adding the arraylist

            course1.Students.Add(student1);
            course1.Students.Add(student2);
            course1.Students.Add(student3);

            course1.teachers[0] = teacher1;

            degree1.course   = course1;
            uProgram1.degree = degree1;

            // Inputting the scores for each student

            foreach (Student stu in course1.Students)
            {
                Console.WriteLine($"Enter the grades for {stu.PFirstName} {stu.PLastName}");
                for (int i = 1; i < 6; i++)
                {
                    Console.Write($"Enter grade {i.ToString()}: ");
                    stu.Grades.Push(EnterGrades());
                }
            }

            // Printing out the results

            course1.ListStudents();

            //Console.WriteLine($"The {uProgram1.ProgramName} program contains the {uProgram1.degree.DegreeType} degree");
            //Console.WriteLine($"The {uProgram1.degree.DegreeType} degree contains the course {uProgram1.degree.course.CourseName}");
            //Console.WriteLine($"The {uProgram1.degree.course.CourseName} course contains {Student.studentCount} students");
        }
Exemplo n.º 8
0
        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");

            foreach (Student s in course.studentList)
            {
                Console.WriteLine(s.firstName + " " + s.lastName);
            }
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            //Instantiate three Student objects.
            ArrayList stArr = new ArrayList();
            Student[] st = new Student[3];
            st[0] = new Student("Sophie", "Greene", new DateTime(1982, 12, 1),
                       "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 4.0);
            st[1] = new Student("Mandy", "Newton", new DateTime(1985, 11, 12),
                       "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 3.4);
            st[2] = new Student("Sonia", "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++)
                {
                    st[i].Grades.Push(grds[i,j]);
                }
                stArr.Add(st[i]);
            }

            //Instantiate a Course object called Programming with C#.
            Course[] courses = new Course[1];
            courses[0] = new Course("Programming with C#", 3, 16);

            //Add the three Student objects to the Students ArrayList inside the Course object
            courses[0].Students = stArr;
            courses[0].Students.Sort();
            //Instantiate at least one Teacher object.
            Teacher[] tchArr = new Teacher[2];
            tchArr[0] = new Teacher("Manual", "Zu", new DateTime(1970, 1, 1), "30 Other Street",
                        "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK", "Computing");
            tchArr[1] = new Teacher("Handy", "Man", new DateTime(1930, 10, 1), "30 Other Street",
                       "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK", "Mathmatics");

            //Add that Teacher object to your Course object
            courses[0].Teacher = tchArr;

            //Instantiate a Degree object, such as Bachelor.
            Degree[] deg = new Degree[1];
            deg[0] = new Degree("Bachelor Of Science", 84);

            // Add your Course object to the Degree object.
            deg[0].Courses = courses;

            //Instantiate a UProgram object called Information Technology.
            UProgram prog = new UProgram("Information Technology", "Some One");

            //Add the Degree object to the UProgram object.
            prog.Degrees = deg;

            /*Using a foreach loop, iterate over the Students in the
            ArrayList and output their first and last names to the console window.
            (For this exercise you MUST cast the returned object from the ArrayList
            to a Student object.  Also, place each student name on its own line)*/
            Console.WriteLine("Printing Student List");
            int cnt = 1;
            foreach (Student s in courses[0].Students)
            {
                Console.WriteLine("{0}-{1} {2}",cnt,
                s.FirstName, s.LastName);
                cnt++;
            }
            Console.WriteLine();
            //Call the ListStudents() method from Main().
            courses[0].ListStudents();

            //using casting
            Student stt = (Student)prog.Degrees[0].Courses[0].Students[2];
            Console.WriteLine("using casting");
            Console.WriteLine();
            stt.takeTest();
            Console.WriteLine();

            #region keep console window open
            Console.Write("Press Any Key to Continue");
            Console.ReadKey();
            Console.Clear();
            #endregion
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            //Instantiate three Student objects.
            ArrayList stArr = new ArrayList();

            Student[] st = new Student[3];
            st[0] = new Student("Sophie", "Greene", new DateTime(1982, 12, 1),
                                "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 4.0);
            st[1] = new Student("Mandy", "Newton", new DateTime(1985, 11, 12),
                                "30 Some Street", "", "Leeds", "West Yorkshire", "ZE7 3AE", "UK", 3.4);
            st[2] = new Student("Sonia", "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++)
                {
                    st[i].Grades.Push(grds[i, j]);
                }
                stArr.Add(st[i]);
            }

            //Instantiate a Course object called Programming with C#.
            Course[] courses = new Course[1];
            courses[0] = new Course("Programming with C#", 3, 16);

            //Add the three Student objects to the Students ArrayList inside the Course object
            courses[0].Students = stArr;
            courses[0].Students.Sort();
            //Instantiate at least one Teacher object.
            Teacher[] tchArr = new Teacher[2];
            tchArr[0] = new Teacher("Manual", "Zu", new DateTime(1970, 1, 1), "30 Other Street",
                                    "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK", "Computing");
            tchArr[1] = new Teacher("Handy", "Man", new DateTime(1930, 10, 1), "30 Other Street",
                                    "", "Sheffield", "West Yorkshire", "LE7 9MN", "UK", "Mathmatics");

            //Add that Teacher object to your Course object
            courses[0].Teacher = tchArr;

            //Instantiate a Degree object, such as Bachelor.
            Degree[] deg = new Degree[1];
            deg[0] = new Degree("Bachelor Of Science", 84);

            // Add your Course object to the Degree object.
            deg[0].Courses = courses;

            //Instantiate a UProgram object called Information Technology.
            UProgram prog = new UProgram("Information Technology", "Some One");

            //Add the Degree object to the UProgram object.
            prog.Degrees = deg;


            /*Using a foreach loop, iterate over the Students in the
             * ArrayList and output their first and last names to the console window.
             * (For this exercise you MUST cast the returned object from the ArrayList
             * to a Student object.  Also, place each student name on its own line)*/
            Console.WriteLine("Printing Student List");
            int cnt = 1;

            foreach (Student s in courses[0].Students)
            {
                Console.WriteLine("{0}-{1} {2}", cnt,
                                  s.FirstName, s.LastName);
                cnt++;
            }
            Console.WriteLine();
            //Call the ListStudents() method from Main().
            courses[0].ListStudents();

            //using casting
            Student stt = (Student)prog.Degrees[0].Courses[0].Students[2];

            Console.WriteLine("using casting");
            Console.WriteLine();
            stt.takeTest();
            Console.WriteLine();


            #region keep console window open
            Console.Write("Press Any Key to Continue");
            Console.ReadKey();
            Console.Clear();
            #endregion
        }