sashomaga

Sample school - OOP

Mar 4th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.58 KB | None | 0 0
  1. class Enter
  2.     {
  3.         public static void Main()
  4.         {
  5.             Discipline dis1 = new Discipline("Math", 10, 20, "the science of quantity");
  6.             Discipline dis2 = new Discipline("Biology", 1, 2);
  7.             Discipline dis3 = new Discipline("Informatics", 1000, 20000, "hack the planet");
  8.             List<Discipline> listDisciplines = new List<Discipline>();
  9.             listDisciplines.Add(dis1);
  10.             listDisciplines.Add(dis2);
  11.             listDisciplines.Add(dis3);
  12.  
  13.             Student stud1 = new Student(1, "Pesho", "very dull");
  14.             Student stud2 = new Student(2, "Mariika");
  15.             List<Student> listStudents = new List<Student>();
  16.             listStudents.Add(stud1);
  17.             listStudents.Add(stud2);
  18.  
  19.             Teacher teacher1 = new Teacher(listDisciplines, "Nakov", "the boss");
  20.             Teacher teacher2 = new Teacher(listDisciplines, "Goro");
  21.             List<Teacher> listTeachers = new List<Teacher>();
  22.             listTeachers.Add(teacher1);
  23.             listTeachers.Add(teacher2);
  24.  
  25.             Class class1 = new Class("8A", listTeachers, listStudents);
  26.             List<Class> listClasses = new List<Class>();
  27.             listClasses.Add(class1);
  28.  
  29.             MySchool theBestSchool = new MySchool(listClasses);
  30.  
  31.         }
  32.     }
  33.  
  34. public class Class : Comments
  35.     {
  36.         private string uniqueIdentifier;
  37.         private List<Teacher> listTeachers;
  38.         private List<Student> listStudents;
  39.  
  40.         public Class(string uniuniqueIdentifier, List<Teacher> listTeachers, List<Student> listStudents)
  41.         {
  42.             this.uniqueIdentifier = uniuniqueIdentifier;
  43.             this.listTeachers = listTeachers;
  44.             this.listStudents = listStudents;
  45.         }
  46.     }
  47.  
  48. public class Comments
  49.     {
  50.         private string optionalComment;
  51.  
  52.         public string OptionalComment
  53.         {
  54.             get
  55.             {
  56.                 return this.optionalComment;
  57.             }          
  58.         }  
  59.         public Comments(string optionalComment = null)
  60.         {
  61.             this.optionalComment = optionalComment;
  62.         }
  63.     }
  64.  
  65. public class Discipline : Comments
  66.     {
  67.         private string name;
  68.         private int numOfLectures;
  69.         private int numOfExercises;
  70.  
  71.         public string Name
  72.         {
  73.             get
  74.             {
  75.                 return this.Name;
  76.             }            
  77.         }
  78.  
  79.         public int NumOfExercises
  80.         {
  81.             get
  82.             {
  83.                 return this.numOfExercises;
  84.             }          
  85.         }
  86.  
  87.         public int NumOfLectures
  88.         {
  89.             get
  90.             {
  91.                 return this.numOfLectures;
  92.             }
  93.         }
  94.  
  95.         public Discipline(string name, int numOfLectures, int numOfExercises, string optionalComment = null) : base(optionalComment)
  96.         {
  97.             this.name = name;
  98.             this.numOfLectures = numOfLectures;
  99.             this.numOfExercises = numOfExercises;
  100.         }
  101.     }
  102.  
  103. public class Human : Comments
  104.     {
  105.         private string name;
  106.  
  107.         public string Name
  108.         {
  109.             get
  110.             {
  111.                 return this.name;
  112.             }          
  113.         }
  114.  
  115.         public Human(string name, string optionalComment = null) : base(optionalComment)
  116.         {
  117.             this.name = name;
  118.         }
  119.     }
  120.  
  121. public class MySchool
  122.     {
  123.         private List<Class> listClasses;
  124.  
  125.         public List<Class> ListClasses
  126.         {
  127.             get
  128.             {
  129.                 return this.listClasses;
  130.             }
  131.         }
  132.  
  133.         public MySchool(List<Class> listClasses)
  134.         {
  135.             this.listClasses = listClasses;
  136.         }
  137.     }
  138.  
  139. public class Student : Human
  140.     {
  141.         private int uniqueClassNum;
  142.  
  143.         public int UniqueClassNum
  144.         {
  145.             get
  146.             {
  147.                 return this.uniqueClassNum;
  148.             }
  149.         }
  150.  
  151.         public Student(int uniqueClassNum, string name, string optionalComment = null) : base(name, optionalComment)
  152.         {
  153.             this.uniqueClassNum = uniqueClassNum;
  154.         }
  155.     }
  156.  
  157. public class Teacher : Human
  158.     {
  159.         private List<Discipline> listDisciplines;
  160.  
  161.         public List<Discipline> ListDisciplines
  162.         {
  163.             get
  164.             {
  165.                 return this.listDisciplines;
  166.             }
  167.         }
  168.  
  169.         public Teacher(List<Discipline> listDisciplines, string name, string optionalComment = null) : base(name,optionalComment)
  170.         {
  171.             this.listDisciplines = listDisciplines;
  172.         }
  173.     }
Advertisement
Add Comment
Please, Sign In to add comment