private void ExperimentalWay() { Console.WriteLine("Experimental Way"); PrincipalOffice princi = new PrincipalOffice(); Classrooms classroom1 = new Classrooms("Class 1", princi); Classrooms classroom2 = new Classrooms("Class 2", princi); Classrooms classroom3 = new Classrooms("Class 3", princi); Classrooms classroom4 = new Classrooms("Class 4", princi); Classrooms classroom5 = new Classrooms("Class 5", princi); Classrooms classroom6 = new Classrooms("Class 6", ref princi.RaiseAlarm); Classrooms classroom7 = new Classrooms("Class 7", ref princi.RaiseAlarm); Classrooms classroom8 = new Classrooms("Class 8", ref princi.RaiseAlarm); Classrooms classroom9 = new Classrooms("Class 9", ref princi.RaiseAlarm); Classrooms classroom10 = new Classrooms("Class 10", ref princi.RaiseAlarm); Classrooms classroom11 = new Classrooms(princi, "Class 11"); Classrooms classroom12 = new Classrooms(princi, "Class 12"); Classrooms classroom13 = new Classrooms(princi, "Class 13"); Classrooms classroom14 = new Classrooms(princi, "Class 14"); Classrooms classroom15 = new Classrooms(princi, "Class 15"); princi.RaiseRecessAlarmMethod(); princi.GivePunishment(); }
public Classrooms(PrincipalOffice principalOffice, string className) { this.ClassName = className; principalOffice.punishment += principalOffice_punishment; }
public Classrooms(string className, PrincipalOffice princi) { this.ClassName = className; princi.RaiseAlarm += new EventHandler(Classrooms_raiseAlarm); }