예제 #1
0
 public void Drive(int km = 5)
 {
     // Checks if someone is sitting in the driver seat, if so it drives the car
     if (MaximumOccupancy[0].Occupied == false) // Would work with checking GetPassengers(), but wouldn't work if driver moved into passenger seat so I changed this.
     {
         Console.WriteLine("And who's supposed to drive?");
     }
     else
     {
         FuelTank.BurnFuel(km / Engine.FuelEfficiency);
         Odometer.Increment(km);
     }
 }
예제 #2
0
        public Car()
        {
            Make             = "Porsche";
            Model            = "Boxster";
            Color            = "Silver";
            Engine           = new Motor(10);
            Odometer         = new Odometer(0);
            FuelTank         = new FuelTank();
            MaximumOccupancy = new Seat[2];

            // Fill the car with passengers
            for (int i = 0; i < MaximumOccupancy.Length; i++)
            {
                MaximumOccupancy[i] = new Seat(true);
            }
        }
예제 #3
0
        public Car(string make, string model, string color, int maxOccupancy, int currentOccupancy, double fuelEfficiency, double fuelTankCapacity, double fuelLevel, int odometer)
        {
            Make             = make;
            Model            = model;
            Color            = color;
            MaximumOccupancy = new Seat[maxOccupancy];
            Engine           = new Motor(fuelEfficiency);
            Odometer         = new Odometer(odometer);
            FuelTank         = new FuelTank(fuelTankCapacity, fuelLevel);

            // Fill the car with passengers
            for (int i = 0; i < maxOccupancy; i++)
            {
                if (i < currentOccupancy)
                {
                    MaximumOccupancy[i] = new Seat(true);
                }
                else
                {
                    MaximumOccupancy[i] = new Seat();
                }
            }
        }