コード例 #1
0
        static void Main(string[] args)
        {
            //Exercise 1
            Console.WriteLine("Exercise 1 display city and population via methods");
            City city = new City();                         //instantiate a City object

            Console.WriteLine(city.GetCity());              //show name of the city for exercise 1
            Console.WriteLine(city.GetPopulation() + "\n"); //show the population of the city exercise 1

            //Exercise 2
            Console.WriteLine("Exercise 2 display city and population via methods but country by a public property");
            City cityEx2 = new City();

            Console.WriteLine(cityEx2.GetCity());             //show name of the city for exercise 1
            Console.WriteLine(cityEx2.GetPopulation());       //show the population of the city exercise 1
            Console.WriteLine(cityEx2.Country + "\n");        //show the country for exercise 2

            //Exercise 3
            City.Version();
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //For the first exercise, intantiate a new City object with name and population
            City city = new City();

            Console.WriteLine(city.GetCity());
            Console.WriteLine(city.GetPopulation());
            Console.WriteLine("\n");

            //For the second exercise, intatiate a new City object with name, population, and country
            City city2 = new City();

            Console.WriteLine(city2.GetCity());
            Console.WriteLine(city2.GetPopulation());
            Console.WriteLine(city2.Country);
            Console.WriteLine("\n");

            //For the third exercise, display the version number
            City.VersionNumber();

            Console.ReadKey();
        }