1_9tdiMamkaMu

Truck

Apr 21st, 2021
653
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5.  
  6.  
  7. namespace Vehicles.Models
  8. {
  9.     public class Truck : Vehicle
  10.     {
  11.  
  12.         public Truck(double fuelQuantity, double fuelConsum, double tankCapacity) : base(fuelQuantity, fuelConsum + 1.6, tankCapacity)
  13.         {
  14.         }
  15.         public override void ReFuel(double fuel)
  16.         {
  17.             double availableSpace = this.TankCapacity - this.FuelQuantity;
  18.  
  19.             if (fuel <= 0)
  20.             {
  21.                 throw new ArgumentException("Fuel must be a positive number");
  22.             }
  23.             if (availableSpace < fuel)
  24.             {
  25.                 throw new ArgumentException($"Cannot fit {fuel} fuel in the tank");
  26.             }
  27.  
  28.             FuelQuantity += fuel * 0.95;
  29.         }
  30.     }
  31. }
  32.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×