示例#1
0
        static void Main(string[] args)
        {
            //Let's make a city...
            City    metropolis = new City();
            Citizen Fred       = new Citizen("Fred Rogers");
            Citizen Pete       = new Citizen("Pete Tucker");
            Citizen Anne       = new Citizen("Anne Trefry");
            Police  Dexter     = new Police("Dexter");
            Vampire David      = new Vampire("David Boreanaz");

            //...and add some people to it, including one vampire named David Boreanaz!
            metropolis.addResident(Fred);
            metropolis.addResident(Pete);;
            metropolis.addResident(Anne);
            metropolis.addResident(Dexter);
            metropolis.addResident(David);

            metropolis.RegisterWithCity(OnCityEvent); //Running the event of the city

            string keep_playing = "Y";

            //Now, tour the city and play the game!
            while (keep_playing == "Y")
            {
                metropolis.tourResidents();
                Console.Write("Do you want to tour again (Y/N)? : ");
                keep_playing = Console.ReadLine();
            }
        }
示例#2
0
        //Speak method
        //Returns new object vampire
        //Adds the new name of the person as well
        public override Person speak()
        {
            Console.WriteLine("Ssssssss! <Bite!> <Bite!> <Bite!>");
            Console.WriteLine("You've been bitten by a vampire and now are a cursed undead.");
            Console.Write("What was your name in life, former mortal? : ");
            string name;

            name = Console.ReadLine();

            Vampire spawn = new Vampire(name);

            return(spawn);
        }