예제 #1
0
    static void Main(string[] args)
    {
        Car1 myCar = new Car1("Auto", "Black", "high", 2019, 4, 80, Car1.Model.M3, Car.CarType.Sedan);

        myCar.Calculate();

        WriteLine("The info about the vehicle:");
        WriteLine($"1. Type: {myCar.Name}.\n2. Color: {myCar.Color}\n3. Year of production: {myCar.YearMade}");
        WriteLine($"4. Model: {myCar.CurrentModel}\n5. Car Type: {myCar.CurrentType}\n6. Comfort level: {myCar.ComfortLevel}]n\n");
        WriteLine($"The price is {myCar.Price}\n\n");

        Car2 friendsCar = new Car2("Auto", "Silver", "medium", 2012, 4, 400, Car2.Model.W140, Car.CarType.Sedan);

        friendsCar.Calculate();

        WriteLine("The info about your friend's vehicle:");
        WriteLine($"1. Type: {friendsCar.Name}.\n2. Color: {friendsCar.Color}\n3. Year of production: {friendsCar.YearMade}");
        WriteLine($"4. Model: {friendsCar.CurrentModel}\n5. Car Type: {friendsCar.CurrentType}\n6. Comfort level: {friendsCar.ComfortLevel}\n\n");
        WriteLine($"The price is {friendsCar.Price}\n\n");

        Car yourCar1 = new Car1("Auto", "Black", "high", 2019, 4, 80, Car1.Model.M3, Car.CarType.Sedan);

        yourCar1.TestDrive();
        Car yourCar2 = new Car2("Auto", "Black", "high", 2019, 4, 80, Car1.Model.M3, Car.CarType.Sedan);

        yourCar2.TestDrive();
    }
예제 #2
0
    static void Main(string[] args)
    {
        Car1 myCar = new Car1("Auto", "Blue", "high", 2019, 4, 80, Car1.Model.M3, Car.CarType.Sedan);

        myCar.Calculate();

        WriteLine("The info about the vehicle:");
        WriteLine($"1. Type: {myCar.Name}.\n2. Color: {myCar.Color}\n3. Year of production: {myCar.YearMade}");
        WriteLine($"4. Model: {myCar.CurrentModel}\n5. Car Type: {myCar.CurrentType}\n6. Comfort level: {myCar.ComfortLevel}]n\n");
        WriteLine($"The price is {myCar.Price}\n\n");

        Car2 friendsCar = new Car2("Auto", "Silver", "medium", 2012, 4, 400, Car2.Model.W140, Car.CarType.Sedan);

        friendsCar.Calculate();

        WriteLine("The info about your friend's vehicle:");
        WriteLine($"1. Type: {friendsCar.Name}.\n2. Color: {friendsCar.Color}\n3. Year of production: {friendsCar.YearMade}");
        WriteLine($"4. Model: {friendsCar.CurrentModel}\n5. Car Type: {friendsCar.CurrentType}\n6. Comfort level: {friendsCar.ComfortLevel}\n\n");
        WriteLine("Additional functions\n\n");
        WriteLine("The program will show all models available:");
        myCar.ShowModels();
        friendsCar.ShowModels();

        IModels testCar = new Car1("Auto", "Green", "low", 2010, 4, 65, Car1.Model.X5, Car.CarType.SUV);

        testCar.Restore(testCar.Available);
        testCar.Buy(testCar.Available);
        WriteLine(testCar.Available);

        IMovable anotherCar = new Car2("Auto", "Silver", "medium", 2012, 4, 400, Car2.Model.W140, Car.CarType.Sedan);

        anotherCar.MaxSpeed = int.Parse(ReadLine());
        WriteLine("The time it takes the vehicle to get to destination point is: {0}", anotherCar.GetTime(250, anotherCar.MaxSpeed));
    }
예제 #3
0
    static void Main(string[] args)
    {
        Car1 myCar = new Car1("Auto", "Black", "high", 2019, 4, 80, Car1.Model.M3, Car.CarType.Sedan);

        myCar.Calculate();

        Car2 friendsCar = new Car2("Auto", "Silver", "medium", 2012, 4, 400, Car2.Model.W140, Car.CarType.Sedan);

        friendsCar.Calculate();

        Choose         choice  = WhoIsBetter;
        MessageHandler handler = delegate(string message) { Console.WriteLine("{0}", message); };

        handler("Enter the sum you would like to add:");
        int money;

        try
        {
            Int32.TryParse(Console.ReadLine(), out money);
            if (money <= 0)
            {
                throw new Exception("You've entered invalid data!");
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }

        myCar.Purchase(money);
        friendsCar.Purchase(money);

        var result = choice(myCar, friendsCar);

        handler("Nice choice!");
    }