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); } }
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); } }
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(); } } }