コード例 #1
0
        static void Main()
        {
            car currentcar = new car();

            while (true)
            {
                Console.WriteLine("Press A to Roll the Wheels baby");
                Console.WriteLine("Press N to switch to new model");
                char c = Convert.ToChar(Console.ReadLine());
                switch (c)
                {
                case 'a':
                {
                    currentcar.wheel();
                    break;
                }

                case 'n':
                {
                    currentcar = new newmodel();
                    break;
                }

                default:
                {
                    Console.WriteLine("Please Enter the Correct Input");
                    break;
                }
                }
            }
        }
コード例 #2
0
        static void Main()
        {
            //Instead of static methods you create a car object on
            //on which you invoke member functions
            car currentcar = new car();

            while (true)
            {
                Console.WriteLine("Press A to Roll the Wheels baby");
                Console.WriteLine("Press N to switch to new model");
                char c = Convert.ToChar(Console.ReadLine());
                switch (c)
                {
                case 'a':
                {
                    currentcar.wheel();
                    break;
                }

                case 'n':
                {
                    currentcar = new newmodel();
                    break;
                }

                default:
                {
                    Console.WriteLine("Please Enter the Correct Input");
                    break;
                }
                }
            }
        }
コード例 #3
0
        static void Main()
        {
            while (true)
            {
                Console.WriteLine("Press A to Roll the Wheels baby");
                Console.WriteLine("Press B to Open/Close the Doors");
                Console.WriteLine("Press C to Start the Car Engine");
                Console.WriteLine("Press D to Check the Oil in tank");
                Console.WriteLine("Press E to Rims/wheels");
                Console.WriteLine("Press F to Exit the vehicle");
                char c        = Convert.ToChar(Console.ReadLine());
                Car  standard = new standardcar(),
                     newModel = new newmodel();
                switch (c)
                {
                case 'a':
                {
                    standard.wheel();
                    break;
                }

                case 'b':
                {
                    standard.doors();
                    break;
                }

                case 'c':
                {
                    standard.engine();
                    break;
                }

                case 'd':
                {
                    standard.oil();
                    break;
                }

                case 'e':
                {
                    newModel.wheel();
                    break;
                }

                case 'f':
                {
                    Environment.Exit(0);
                    break;
                }

                default:
                {
                    Console.WriteLine("Please Enter the Correct Input");
                    break;
                }
                }
            }
        }