Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- namespace ModuleSevenAssignment
- {
- class Program
- {
- //how many students to add according to specs
- const int initialNumStudents = 3;
- //how many grades according to the specs
- const int gradesPerStudent = 5;
- static void Main(string[] args)
- {
- //create course
- Course course = new Course("Programming with C#");
- //add students to course
- for (int i = 0; i < initialNumStudents; i++)
- {
- Student student = new Student("Student", "Name");
- //add grades for student
- for (int j = 0; j < gradesPerStudent; j++)
- {
- student.Grades.Push(100);
- }
- course.AddStudent(student);
- }
- course.ListStudents();
- Console.ReadKey();
- }
- //Contains first name and last name.
- class Person
- {
- public string FName { get; set; }
- public string LName { get; set; }
- public Person(string firstName, string lastName)
- {
- FName = firstName;
- LName = lastName;
- }
- }
- class Student : Person
- {
- public static int StudentsEnrolledInSchool = 0;
- public Stack<int> Grades { get; set; }
- //Use the Person class's constructor to instantiate
- public Student(string firstName, string lastName)
- : base(firstName, lastName)
- {
- Grades = new Stack<int>();
- StudentsEnrolledInSchool++;
- }
- public void TakeTest()
- {
- Console.WriteLine("{0} {1} took a test!", FName, LName);
- }
- }
- class Teacher : Person
- {
- //Use the Person class's constructor to instantiate
- public Teacher(string firstName, string lastName) : base(firstName, lastName) { }
- public void GradeTest()
- {
- Console.WriteLine("{0} {1} graded a test!", FName, LName);
- }
- }
- //Contains teacher, students, and title
- class Course
- {
- public Teacher Teacher { get; set; }
- public ArrayList Students { get; set; }
- public string Title { get; set; }
- public Course(string title)
- {
- Title = title;
- Students = new ArrayList();
- }
- public void AddStudent(Student s)
- {
- Students.Add(s);
- }
- public void ListStudents()
- {
- foreach (Student s in Students)
- {
- Console.WriteLine("{0} {1}", s.FName, s.LName);
- }
- }
- }
- //Contains courses and title
- class Degree
- {
- public string Title { get; set; }
- public List<Course> Courses { get; set; }
- public Degree(string title)
- {
- Title = title;
- Courses = new List<Course>();
- }
- public void AddCourse(Course course)
- {
- Courses.Add(course);
- }
- }
- //Contains degrees and title
- class UProgram
- {
- public string Title { get; set; }
- public List<Degree> Degrees { get; set; }
- public UProgram(string title)
- {
- Title = title;
- Degrees = new List<Degree>();
- }
- public void AddDegree(Degree degree)
- {
- Degrees.Add(degree);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement