Beispiel #1
0
        public void Accelerate_WhenCalled_IncraseSpeed()
        {
            decimal expectedSpeed = 1;
            decimal actualSpeed;

            TestBike.Accelerate();
            actualSpeed = TestBike.GetCurrentSpeed();

            Assert.AreEqual(expectedSpeed, actualSpeed);
        }
Beispiel #2
0
    public void BicycleCase()
    {
        Console.WriteLine("Enter Details of the vehicle in the orde: No. Of Gears, Make, Year Of Manufacture, Model, Speed");
        Bicycle bicycle         = new Bicycle(int.Parse(Console.ReadLine()));
        string  operationChoice = null;

        do
        {
            Console.WriteLine("Now what operation you want to perform");
            Console.WriteLine("1. See Details");
            Console.WriteLine("2. Accelerate Vehicle");
            Console.WriteLine("3. Deaccelerate Vehicle");
            Console.WriteLine("4. Stop vehicle");
            Console.WriteLine("5. Check moving or stopped");
            int ch = int.Parse(Console.ReadLine());
            switch (ch)
            {
            case 1:
                bicycle.ShowDetails();
                bicycle.ShowNoOfGears();
                break;

            case 2:
                bicycle.Accelerate();
                Console.WriteLine("Vehicle Accelerated");
                break;

            case 3:
                bicycle.Deaccelerate();
                break;

            case 4:
                bicycle.Stop();
                Console.WriteLine("Vehicle Stopped");
                break;

            case 5:
                if (bicycle.isMoving())
                {
                    Console.WriteLine("Moving");
                }
                else
                {
                    Console.WriteLine("Stopped");
                }
                break;

            default:
                Console.WriteLine("Error");
                break;
            }
            Console.WriteLine("Do you want to perform another operation om this vehicle?(Yes/No)");
            operationChoice = Console.ReadLine();
        } while (string.Compare(operationChoice, "Yes") == 0);
    }
    private static void Main()
    {
        Bicycle bicycle = new Bicycle("Chicago Bicycle", 2011, "K-10", 100);

        bicycle.Color = "Red";
        bicycle.GetDetails();
        bicycle.Accelerate(50, bicycle);
        bicycle.Deaccelerate(10);
        if (bicycle.IsMoving())
        {
            Console.WriteLine("Bicycle is moving");
        }
        else
        {
            Console.WriteLine("Bicycle is not moving");
        }

        Console.WriteLine("");

        Bike bike = new Bike("Hero Bike", 2015, "H712", 200);

        bike.BikeColor = "Blue";
        bike.GetDetails();
        bike.Accelerate(30, bike);
        bike.Deaccelerate(40);
        bike.Stop();
        if (bike.IsMoving())
        {
            Console.WriteLine("Bike is moving");
        }
        else
        {
            Console.WriteLine("Bike is not moving");
        }

        Console.WriteLine("");

        Car car = new Car("Honda Amaze", 2016, "VXi", 250);

        car.CarColor = "White";
        car.GetDetails();
        car.Accelerate(10, car);
        car.Deaccelerate(10);
        if (car.IsMoving())
        {
            Console.WriteLine("Car is moving");
        }
        else
        {
            Console.WriteLine("Car is not moving");
        }

        Console.WriteLine("");

        Truck truck = new Truck("Aven", 2010, "Z-20", 200);

        truck.TruckColor = "Orange";
        truck.GetDetails();
        truck.Accelerate(10, truck);
        truck.Deaccelerate(250);
        if (truck.IsMoving())
        {
            Console.WriteLine("Truck is moving");
        }
        else
        {
            Console.WriteLine("Truck is not moving");
        }

        Console.ReadKey();
    }
Beispiel #4
0
    static void Main()
    {
        Console.WriteLine("Which Vehicle do you have");
        Console.WriteLine("1.Bicycle");
        Console.WriteLine("2.Bike");
        Console.WriteLine("3.Car");
        Console.WriteLine("4.Truck");
        int Choice = int.Parse(Console.ReadLine());

        switch (Choice)
        {
        case 1:
        {
            Console.WriteLine("Enter Details of the vehicle in the orde: Make, Year Of Manufacture, Model, Speed, No. Of Gears");
            Bicycle B = new Bicycle(int.Parse(Console.ReadLine()));
            Console.WriteLine("Now what operation you want to perform");
            Console.WriteLine("1. See Details");
            Console.WriteLine("2. Accelerate Vehicle");
            Console.WriteLine("3. Deaccelerate Vehicle");
            Console.WriteLine("4. Stop vehicle");
            Console.WriteLine("5. Check moving or stopped");
            int ch = int.Parse(Console.ReadLine());
            switch (ch)
            {
            case 1:
                B.ShowDetails();
                B.ShowNoOfGears();
                break;

            case 2:
                B.Accelerate();
                Console.WriteLine("Vehicle Accelerated");
                break;

            case 3:
                B.Deaccelerate();
                Console.WriteLine("Vehicle Deaccelerated");
                break;

            case 4:
                B.Stop();
                Console.WriteLine("Vehicle Stopped");
                break;

            case 5:
                if (B.isMoving())
                {
                    Console.WriteLine("Moving");
                }
                else
                {
                    Console.WriteLine("Stopped");
                }
                break;

            default:
                Console.WriteLine("Error");
                break;
            }
        }
        break;

        case 2:
        {
            Console.WriteLine("Enter Details of the vehicle in the orde: Make, Year Of Manufacture, Model, Speed, Turn Radius");
            Bike B = new Bike(int.Parse(Console.ReadLine()));
            Console.WriteLine("Now what operation you want to perform");
            Console.WriteLine("1. See Details");
            Console.WriteLine("2. Accelerate Vehicle");
            Console.WriteLine("3. Deaccelerate Vehicle");
            Console.WriteLine("4. Stop vehicle");
            Console.WriteLine("5. Check moving or stopped");
            int ch = int.Parse(Console.ReadLine());
            switch (ch)
            {
            case 1:
                B.ShowDetails();
                B.ShowTurnRadius();
                break;

            case 2:
                B.Accelerate();
                Console.WriteLine("Vehicle Accelerated");
                break;

            case 3:
                B.Deaccelerate();
                Console.WriteLine("Vehicle Deaccelerated");
                break;

            case 4:
                B.Stop();
                Console.WriteLine("Vehicle Stopped");
                break;

            case 5:
                if (B.isMoving())
                {
                    Console.WriteLine("Moving");
                }
                else
                {
                    Console.WriteLine("Stopped");
                }
                break;

            default:
                Console.WriteLine("Error");
                break;
            }
        }
        break;

        case 3:
        {
            Console.WriteLine("Enter Details of the vehicle in the orde: Make, Year Of Manufacture, Model, Speed, type of Engine");
            Car C = new Car(Console.ReadLine());
            Console.WriteLine("Now what operation you want to perform");
            Console.WriteLine("1. See Details");
            Console.WriteLine("2. Accelerate Vehicle");
            Console.WriteLine("3. Deaccelerate Vehicle");
            Console.WriteLine("4. Stop vehicle");
            Console.WriteLine("5. Check moving or stopped");
            int ch = int.Parse(Console.ReadLine());
            switch (ch)
            {
            case 1:
                C.ShowDetails();
                C.ShowEngine();
                break;

            case 2:
                C.Accelerate();
                Console.WriteLine("Vehicle Accelerated");
                break;

            case 3:
                C.Deaccelerate();
                Console.WriteLine("Vehicle Deaccelerated");
                break;

            case 4:
                C.Stop();
                Console.WriteLine("Vehicle Stopped");
                break;

            case 5:
                if (C.isMoving())
                {
                    Console.WriteLine("Moving");
                }
                else
                {
                    Console.WriteLine("Stopped");
                }
                break;

            default:
                Console.WriteLine("Error");
                break;
            }
        }
        break;

        case 4:
        {
            Console.WriteLine("Enter Details of the vehicle in the orde: Make, Year Of Manufacture, Model, Speed, Capacity");
            Truck T = new Truck(int.Parse(Console.ReadLine()));
            Console.WriteLine("Now what operation you want to perform");
            Console.WriteLine("1. See Details");
            Console.WriteLine("2. Accelerate Vehicle");
            Console.WriteLine("3. Deaccelerate Vehicle");
            Console.WriteLine("4. Stop vehicle");
            Console.WriteLine("5. Check moving or stopped");
            int ch = int.Parse(Console.ReadLine());
            switch (ch)
            {
            case 1:
                T.ShowDetails();
                T.ShowCapacity();
                break;

            case 2:
                T.Accelerate();
                Console.WriteLine("Vehicle Accelerated");
                break;

            case 3:
                T.Deaccelerate();
                Console.WriteLine("Vehicle Deaccelerated");
                break;

            case 4:
                T.Stop();
                Console.WriteLine("Vehicle Stopped");
                break;

            case 5:
                if (T.isMoving())
                {
                    Console.WriteLine("Moving");
                }
                else
                {
                    Console.WriteLine("Stopped");
                }
                break;

            default:
                Console.WriteLine("Error");
                break;
            }
        }
        break;

        default:
            Console.WriteLine("error");
            break;
        }
    }