static void Main(string[] args)
        {
            FuelGauge firstCar = new FuelGauge(10);

            firstCar.PrintFuelGauge();
            firstCar.incrementFuelAmount();
            firstCar.decrementFuelAmount();

            Odometer firstOdometer = new Odometer(30);

            firstOdometer.PrintMileage();
            Odometer.incrementMileageByOneKm(ref firstOdometer, ref firstCar);



            Console.WriteLine("Time to fill up for a 5 liters!");
            for (var i = 1; i <= 5; i++)
            {
                firstCar.incrementFuelAmount();
            }


            for (var i = 0; i < 149; i++)
            {
                Odometer.incrementMileageByOneKm(ref firstOdometer, ref firstCar);
                firstCar.PrintFuelGauge();
                firstOdometer.PrintMileage();
            }
        }
Esempio n. 2
0
        public static void incrementMileageByOneKm(ref Odometer obj1, ref FuelGauge obj2)
        {
            if (obj1._mileage < obj1._maxMileage)
            {
                obj1._mileage++;
                if (obj1._mileage % 10 == 0)
                {
                    obj2.decrementFuelAmount();
                }
            }

            else
            {
                obj1._mileage = 0;
            }
        }