Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public void OnEnter(Professor inhabitant)
 {
     inhabitant.Display("I need a cup of coffee.");
 }
Ejemplo n.º 3
0
 public void OnExit(Professor inhabitant)
 {
     inhabitant.Display("{{bright eyed}} Ready for work.");
 }
Ejemplo n.º 4
0
 public void Execute(Professor inhabitant)
 {
     inhabitant.Display("{{sllluuurrrppp}} Umm Umm coffee's good.");
     inhabitant.ChangeState(new ProfessorGradeHomeworkState());
 }