Пример #1
0
        static void Main(string[] args)
        {
            bool exit = false;

            Car thisCar = new Car();

            do
            {
                Console.WriteLine(StandardMessages.DisplayMenu());
                switch (Console.ReadLine())
                {
                case "1":
                    CarInformation.CreateCar(thisCar);
                    break;

                case "2":
                    thisCar.Accelerate();
                    break;

                case "3":
                    thisCar.Brake();
                    break;

                case "4":
                    exit = true;
                    break;

                default:
                    StandardMessages.DisplayChoiceError();
                    break;
                }
                Console.WriteLine(StandardMessages.DisplaySpeed(thisCar));
            } while (exit == false);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Car car = new Car();//creates a new instance of a car from the Car class


            car.SetMake("Honda", 2014);                                        //calls the SetMake method in order to create the make of the car

            WriteLine("Begnning speed of the car: " + car.current_speed());    //Prints the starting speed of the car, calls the current_speed method to display the speed of the car

            for (int i = 0; i < 5; i++)                                        //I created a for loop instead of having to call each method five times individually. Seemed easier so I hope that is okay
            {
                WriteLine("Acceleration in progress.");                        //Prints a message to show acceleration
                car.Accelerate();                                              //Calls the acceleration method from Car class
                WriteLine("Current speed of the car: " + car.current_speed()); //Prints the current speed of the car
            }


            for (int j = 0; j < 5; j++)                                        //for loop that makes the car brake five times
            {
                WriteLine("Braking in progress.");                             //Shows that the car is braking
                car.Brake();                                                   //Calls the brake method from the car class to slow the car down
                WriteLine("Current speed of the car: " + car.current_speed()); //Prints the current speed of the car
            }



            WriteLine("End of program"); //Just a message to show the completion of the program
        }
        static void Main(string[] args)
        {
            Car car  = new Car(null, 0);
            Car car1 = new Car(null, 0);

            car.AskData();
            car1.AskData();
            Console.WriteLine(car.ShowCarInfo());
            Console.WriteLine(car1.ShowCarInfo());
            car.Accelerate();
            car1.Accelerate();
            Console.WriteLine(car.ShowCarInfo());
            Console.WriteLine(car1.ShowCarInfo());
            car.Brake();
            car1.Brake();
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Car car = new Car();

            car.AskData();
            car.ShowCarInfo();
            car.Accelerate();
            car.Brake();

            Car car2 = new Car();

            car2.AskData();
            car2.ShowCarInfo();
            car2.Accelerate();
            car2.Brake();

            Console.ReadKey();
        }