public virtual void Execute(Programmer inhabitant) { inhabitant.Display("{click clack, click clack} programming like a boss..."); if (counter == 0) { inhabitant.ChangeState(new ProgrammerDrinkSodaState()); counter++; } else { inhabitant.ChangeState(new ProgrammerSleepState()); counter = 0; } }
public virtual void OnExit(Programmer inhabitant) { Console.WriteLine("Sweet. Now I'm ready to program!"); }
public virtual void OnEnter(Programmer inhabitant) { Console.WriteLine("I love drinking soda!"); }
public virtual void Execute(Programmer inhabitant) { inhabitant.Display("{gulp gulp} That was delicious!"); inhabitant.ChangeState(new ProgrammerProgramState()); }
public virtual void OnExit(Programmer inhabitant) { Console.WriteLine("My code's not compiling!!!!!1!"); }
public virtual void OnEnter(Programmer inhabitant) { Console.WriteLine("Oh boy! It's time to work! :-)"); }
static void Main(string[] args) { // set how long to run the virtual world const int NUMBER_OF_MOVES = 5; // start with an empty list of generic inhabitants List<AbstractInhabitant> inhabitantList = new List<AbstractInhabitant>(); // add a new graduate student to the list GraduateStudent denise = new GraduateStudent("Graduate Student Denise"); inhabitantList.Add(denise); // add a new professor instance to the list Professor profCase = new Professor("Prof Case"); inhabitantList.Add(profCase); // add a new cat instance to the list Cat bill = new Cat("Bill the Cat"); inhabitantList.Add(bill); // add a programmer instance to the list Programmer josh = new Programmer("Josh"); inhabitantList.Add(josh); // add a new type of character to the list //TODO: add your code here // startup each inhabitant on the list foreach (AbstractInhabitant inhabitant in inhabitantList) { inhabitant.Start(); } //display a blank line just for readability Console.WriteLine(); // run the virtual world for (int i = 0; i <= NUMBER_OF_MOVES; i++) { //display what move we're on Console.WriteLine(i); // have each inhabitant execute their updated state foreach (AbstractInhabitant inhabitant in inhabitantList) inhabitant.Execute(); //display a blank line just for readability Console.WriteLine(); } // virtual world is winding down - have the inhabitants finish up foreach (AbstractInhabitant inhabitant in inhabitantList) { inhabitant.Finish(); } // keep the command window open Console.Read(); }
public virtual void OnExit(Programmer inhabitant) { Console.WriteLine("...zZzzz oh my, what time is it?!"); }
public virtual void OnEnter(Programmer inhabitant) { Console.WriteLine("I gotta fix this errorrr... zzZzzZZz..."); }
public virtual void Execute(Programmer inhabitant) { inhabitant.Display("...zZzzZzZ (dreaming of attacking the evil computer bugs, like a boss) zzzZzZ..."); inhabitant.ChangeState(new ProgrammerProgramState()); }