Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Vehicles.Models
- {
- public class Truck : Vehicle
- {
- public Truck(double fuelQuantity, double fuelConsum, double tankCapacity) : base(fuelQuantity, fuelConsum + 1.6, tankCapacity)
- {
- }
- public override void ReFuel(double fuel)
- {
- double availableSpace = this.TankCapacity - this.FuelQuantity;
- if (fuel <= 0)
- {
- throw new ArgumentException("Fuel must be a positive number");
- }
- if (availableSpace < fuel)
- {
- throw new ArgumentException($"Cannot fit {fuel} fuel in the tank");
- }
- FuelQuantity += fuel * 0.95;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement