Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace CarManufacturer
- {
- public class Car
- {
- public string make;
- public string model;
- public int year;
- public double fuelQuantity;
- public double fuelConsumption;
- public string Make
- {
- get
- {
- return this.make;
- }
- set
- {
- this.make = value;
- }
- }
- public string Model
- {
- get
- {
- return this.model;
- }
- set
- {
- this.model = value;
- }
- }
- public int Year
- {
- get
- {
- return this.year;
- }
- set
- {
- this.year = value;
- }
- }
- public double FuelQuantity
- {
- get
- {
- return this.fuelQuantity;
- }
- set
- {
- this.fuelQuantity = value;
- }
- }
- public double FuelConsumption
- {
- get
- {
- return this.fuelConsumption;
- }
- set
- {
- this.fuelConsumption = value;
- }
- }
- public void Drive(double distance)
- {
- if (this.FuelQuantity - ((this.FuelConsumption * distance) / 100) >= 0)
- {
- this.FuelQuantity -= ((distance* this.FuelConsumption) / 100);
- }
- else
- {
- Console.WriteLine($"Not enough fuel to perform this trip!");
- }
- }
- public string WhoAmI()
- {
- var carInfo = new StringBuilder();
- carInfo.AppendLine($"Make: {this.Make}");
- carInfo.AppendLine($"Model: {this.Model}");
- carInfo.AppendLine($"Year: {this.Year}");
- carInfo.Append($"Fuel: {this.FuelQuantity:F2}L");
- return carInfo.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement