Exemplo n.º 1
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.º 2
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.º 3
0
        static void Main(string[] args)
        {
            Student student1 = new Student("Fred", "Flintstone", "9/30/1960", "301 Cobblestone Way", "", "Bedrock", "LA", "70777", "USA");
            Student student2 = new Student("Barney", "Rubble", "9/30/1960", "301 Cobblestone Way", "", "Bedrock", "LA", "70777", "USA");
            Student student3 = new Student("Wilma", "Flintstone", "9/30/1960", "301 Cobblestone Way", "", "Bedrock", "LA", "70777", "USA");

            student1.Grades.Push(75);
            student1.Grades.Push(80);
            student1.Grades.Push(99);
            student1.Grades.Push(100);
            student1.Grades.Push(98);

            student2.Grades.Push(77);
            student2.Grades.Push(78);
            student2.Grades.Push(79);
            student2.Grades.Push(80);
            student2.Grades.Push(81);

            student3.Grades.Push(90);
            student3.Grades.Push(85);
            student3.Grades.Push(80);
            student3.Grades.Push(75);
            student3.Grades.Push(70);

            Course course = new Course("Programming with C#");
            course.Student.Add(student1);                           /* Grading criteria 3 of 5 - Add 3 students using ArrayList method */
            course.Student.Add(student2);
            course.Student.Add(student3);

            course.ListStudents();

            Console.WriteLine("Press any key to continue . . .");
            Console.ReadKey();
        }