public static void Main(string[] args) { // Instantiate three Student objects. Student s1 = new Student("John", "Doe", "May 1, 1995"); s1.AddressLine1 = "1234 Main Street"; s1.AddressLine2 = "Apartment 2F"; s1.City = "New York City"; s1.Zip = "11000"; s1.State = "New York"; s1.City = "USA"; Student s2 = new Student("Jade", "Smith", "Oct 12, 1996"); s1.AddressLine1 = "2122 First Street"; s1.AddressLine2 = ""; s1.City = "Jersey City"; s1.Zip = "07002"; s1.State = "New Jersey"; s1.City = "USA"; Student s3 = new Student("Jack", "Black", "March 25, 1995"); s1.AddressLine1 = "8120 JFK Blvd"; s1.AddressLine2 = "Apartment 1601"; s1.City = "New York City"; s1.Zip = "11025"; s1.State = "New York"; s1.City = "USA"; // Instantiate a Course object called Programming with C#. Course csharp = new Course("Programming with C#"); // Add your three students to this Course object. csharp.students = new Student[3] { s1, s2, s3 }; // Instantiate at least one Teacher object. Teacher lecturer = new Teacher("Mr.", "Jackson"); // Add that Teacher object to your Course object csharp.teachers = new Teacher[3]; csharp.teachers[0] = lecturer; // Instantiate a Degree object, such as Bachelor. Degree degree = new Degree("Bachelor of Science"); // Add your Course object to the Degree object. degree.Course = csharp; // Instantiate a UProgram object called Information Technology. UProgram program = new UProgram("Information Technology"); // Add the Degree object to the UProgram object. program.Degree = degree; // Using Console.WriteLine statements, output the following information to the console window: // The name of the program and the degree it contains Console.WriteLine("The {0} program contains the {1} degree.", program.ProgramName, degree.DegreeName); // The name of the course in the degree Console.WriteLine("The {0} degree contains the {1} course.", degree.DegreeName, csharp.CourseName); // The count of the number of students in the course. Console.WriteLine("There are {0} student(s) in the course {1}.", csharp.students.Length, csharp.CourseName); }
public static void Main(string[] args) { Student[] students = new Student[5]; // creating student record with constructors students[0] = new Student("John", "Doe", "May 1, 1995"); // creating student record with setting fields students[1].firstName = "David"; students[1].lastName = "Smith"; students[1].birthday = "October 2, 1996"; Console.WriteLine("Student {0} {1} was born on {2}.", students[0].firstName, students[0].lastName, students[0].birthday); Console.WriteLine("Student {0} {1} was born on {2}.", students[1].firstName, students[1].lastName, students[1].birthday); }
public static void Main(string[] args) { Random rnd = new Random(); // Instantiate three Student objects. Student s1 = new Student("John", "Doe", "May 1, 1995"); s1.AddressLine1 = "1234 Main Street"; s1.AddressLine2 = "Apartment 2F"; s1.City = "New York City"; s1.Zip = "11000"; s1.State = "New York"; s1.City = "USA"; // 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 < 5; i++) { s1.Grades.Push(rnd.Next(60, 100)); } Student s2 = new Student("Jade", "Smith", "Oct 12, 1996"); s2.AddressLine1 = "2122 First Street"; s2.AddressLine2 = ""; s2.City = "Jersey City"; s2.Zip = "07002"; s2.State = "New Jersey"; s2.City = "USA"; // 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 < 5; i++) { s2.Grades.Push(rnd.Next(60, 100)); } Student s3 = new Student("Jack", "Black", "March 25, 1995"); s3.AddressLine1 = "8120 JFK Blvd"; s3.AddressLine2 = "Apartment 1601"; s3.City = "New York City"; s3.Zip = "11025"; s3.State = "New York"; s3.City = "USA"; // 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 < 5; i++) { s3.Grades.Push(rnd.Next(60, 100)); } // Instantiate a Course object called Programming with C#. Course csharp = new Course("Programming with C#"); // Add your three students to this Course object. // Modify your code to use the ArrayList collection as the replacement // to the array. In other words, when you add a Student to the Course // object, you will add it to the ArrayList and not an array. // Add the three Student objects to the Students ArrayList inside the Course object. csharp.students.Add(s1); csharp.students.Add(s2); csharp.students.Add(s3); // Instantiate at least one Teacher object. Teacher lecturer = new Teacher("Mr.", "Michael", "Jackson"); // Add that Teacher object to your Course object csharp.teachers = new Teacher[3]; csharp.teachers[0] = lecturer; // Instantiate a Degree object, such as Bachelor. Degree degree = new Degree("Bachelor of Science"); // Add your Course object to the Degree object. degree.Course = csharp; // Instantiate a UProgram object called Information Technology. UProgram program = new UProgram("Information Technology"); // Add the Degree object to the UProgram object. program.Degree = degree; // Using Console.WriteLine statements, output the following information to the console window: // The name of the program and the degree it contains Console.WriteLine("The {0} program contains the {1} degree.", program.ProgramName, degree.DegreeName); // The name of the course in the degree Console.WriteLine("The {0} degree contains the {1} course.", degree.DegreeName, csharp.CourseName); // The count of the number of students in the course. Console.WriteLine("There are {0} student(s) in the course {1}.", csharp.students.Count, csharp.CourseName); // Call the ListStudents() method from Main(). csharp.ListStudents(); }