Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            FuelGauge fuelGauge      = new FuelGauge();
            Odometer  odometer       = new Odometer(fuelGauge);
            int       litersFilled   = 0;
            int       milesTravelled = 0;

            Console.WriteLine("Please enter liters filled:");
            litersFilled = int.Parse(Console.ReadLine());

            Console.WriteLine("Please enter miles travelled:");
            milesTravelled = int.Parse(Console.ReadLine());

            Console.Clear();

            for (var i = 0; i < litersFilled; i++)
            {
                fuelGauge.Fill();
            }
            Console.WriteLine($"Fuel gauge report: {fuelGauge.ReportLevel()}");

            for (int i = 0; i < milesTravelled; i++)
            {
                if (odometer.Increment())
                {
                    odometer.Increment();
                    Console.WriteLine($"Mileage: {odometer.Report()}, Fuel Level: {fuelGauge.ReportLevel()}");
                }
                else
                {
                    break;
                }
            }
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("New odometer");
            FuelGauge fuelGauge = new FuelGauge();
            Odometer  odometer  = new Odometer(fuelGauge);

            int filledLiters         = 7;
            int killometersTravelled = 101;

            for (int i = 0; i < filledLiters; i++)
            {
                fuelGauge.IncreaseOfFuel();
            }

            Console.WriteLine($"Fuel level: {fuelGauge.ReportLevel()}");
            Console.WriteLine("running");

            for (int i = 0; i < killometersTravelled; i++)
            {
                odometer.MaxMileage();
                odometer.ReportMileage();
                Console.WriteLine($"Odometer report: {odometer.ReportMileage()} km, Fuel level: {fuelGauge.ReportLevel()}");
            }


            Console.ReadLine();
        }
Ejemplo n.º 3
0
 public void BurnFuel()
 {
     if (_milage % 10 == 0)
     {
         FuelGauge fuelGauge = new FuelGauge();
         fuelGauge.TakeFuel();
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("new odometer");
            var fuelGauge = new FuelGauge();//  jāuzpilda 10 reizes?

            for (int i = 0; i < 10; i++)
            {
                fuelGauge.Fill(); // fill strādā tikai priekš fuelGauge? Šī metode tiek izsaukta 10 reizes?
            }
            Console.WriteLine($"fuel level: {fuelGauge.ReportLevel()}");
            var odometer = new Odometer(fuelGauge);// odometra.cs jau ir rakstīts Odometer(fuelGauge). Kāpēc tas te tiek atkal rakstīts?

            Console.WriteLine("running...");

            for (int i = 0; i < 200; i++)
            {
                odometer.Increment();
                Console.WriteLine($"odometer report: {odometer.Report()}");
            }

            Console.ReadKey();//Kā redzēt kura darbība pēc kuras notiek? Ar breakpoint tikai apstājas tajā vietā
            //par ko ir jādomā lai šādies uzrakstītu? te viss ir 3 lapās.
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var fuelGauge = new FuelGauge();
            var odometr   = new Odometer(fuelGauge);



            for (var i = 0; i < 7; i++)
            {
                fuelGauge.Fill();
            }

            for (var i = 0; i < 101; i++)
            {
                odometr.Increment();
                Console.WriteLine(odometr.ReportMileage());
                Console.WriteLine(fuelGauge.ReportLevel() + "litri");

                Console.ReadKey();
            }


            Console.ReadKey();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            FuelGauge fuelGauge = new FuelGauge();
            Odometer  odometer  = new Odometer();

            fuelGauge.AddFuel(25);

            for (int i = 0; i < 20; i++)
            {
                odometer.ReportMilage();
                fuelGauge.ReportFuel();

                for (int j = 0; j < 15; j++)
                {
                    odometer.AddMilage();
                }

                fuelGauge.TakeFuel();

                Console.WriteLine();
            }

            Console.ReadKey();
        }
 public Odometer(FuelGauge fuelGauge)
 {
     _fuelGauge = fuelGauge;
 }
Ejemplo n.º 8
0
 public Odometer(FuelGauge _fuelGauge)
 {
     this._fuelGauge = new FuelGauge();
 }
 public Odometer(FuelGauge fuelGauge) // ko šinī gadījumā dara FuelGauge fuelGauge? kāpēc tam ir jābūt pie šīs metodes?
 {
     _fuelGauge = fuelGauge;          // to jau sākumā naugšā nevarēja deklarēt?
 }