Beispiel #1
0
        static void Main(string[] args)
        {
            // init of car
            Car car = new Car(30, Vehicle.FuelType.Gasoline);

            Console.WriteLine("{0}:\n" + car, nameof(car));

            car.Passengers = 6; // added 6 passengers, max capacity is 5
            Console.WriteLine("{0}:\n" + car, nameof(car));

            // init of lorry
            Lorry lorry = new Lorry(400, Vehicle.FuelType.Diesel);

            Console.WriteLine("{0}:\n" + lorry, nameof(lorry));

            // refuel car with 50 l of gasoline, tank capacity is 45
            car.Refuel(Vehicle.FuelType.Gasoline, 50);
            Console.WriteLine("{0}:\n" + car, nameof(car));

            // car radio
            car.RadioStatus(true);
            car.AddStation(1, 99.6);
            car.RadioSettings(1);
            Console.WriteLine(car.radioToString());

            // lorry radio
            lorry.RadioStatus(true);
            Console.WriteLine(lorry.radioToString());

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            try
            {
                PassengerCar pc = new PassengerCar(35, Car.TypeOfFuel.petrol, 5, 18, 7);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            PassengerCar p = new PassengerCar(35, Car.TypeOfFuel.petrol, 5, 18);
            Lorry        l = new Lorry(100, Car.TypeOfFuel.diesel, 50);

            Console.WriteLine(p);
            Console.WriteLine(l);
            p.TurnRadio(true);
            l.TurnRadio(true);
            Console.WriteLine(p);
            Console.WriteLine(l);
            p.SetElementOfPreset(2, 88.3);
            l.SetElementOfPreset(1, 105.85);
            p.SetElementOfPreset(1, 88.3);
            l.SetElementOfPreset(2, 105.85);
            l.SetElementOfPreset(1, 101.5);
            p.RetuneByIndex(2);
            l.RetuneByIndex(1);
            try
            {
                l.RetuneByIndex(3);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine(p);
            Console.WriteLine(l);
            p.RetuneByHand(85.3);
            Console.WriteLine(p);
            p.TurnRadio(false);
            l.TurnRadio(false);
            Console.WriteLine(p);
            Console.WriteLine(l);
            Console.WriteLine();
            p.refuel(Car.TypeOfFuel.petrol, 5.87);
            try
            {
                l.refuel(Car.TypeOfFuel.petrol, 80);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            try
            {
                p.refuel(Car.TypeOfFuel.petrol, 50);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine(p);
            Console.WriteLine(l);
            Console.WriteLine();
            l.refuel(Car.TypeOfFuel.diesel, 100);

            try
            {
                p.TransportedPersons = 20;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            try
            {
                l.TransportedLoad = 70;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            p.TransportedPersons = 2;
            l.TransportedLoad    = 40;
            Console.WriteLine(p);
            Console.WriteLine(l);



            Console.ReadLine();
        }