Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading;
- namespace CarManufacturer
- {
- public class Car
- {
- public Car(string make, string model, int year, double fuelQuantity, double fuelConsumption, Engine engine, Tire[] tires)
- {
- this.Make = make;
- this.Model = model;
- this.Year = year;
- this.FuelQuantity = fuelQuantity;
- this.FuelConsumption = fuelConsumption;
- this.Engine = engine;
- this.Tire = tires;
- }
- public string Model { get; set; }
- public string Make { get; set; }
- public int Year { get; set; }
- public double FuelQuantity { get; set; }
- public double FuelConsumption { get; set; }
- public Engine Engine { get; set; }
- public Tire[] Tire { get; set; }
- public void Drive(double distance)
- {
- double consumption = 20 * this.FuelConsumption / 100;
- if (this.FuelQuantity - consumption <= 0)
- {
- Console.WriteLine("Not enough fuel to perform this trip!");
- }
- else
- {
- this.FuelQuantity -= consumption;
- }
- }
- public string WhoAmI()
- {
- return $"Make: {this.Make}\nModel: {this.Model}\nYear: {this.Year}\nHorsePowers: {this.Engine.HorsePower}\nFuelQuantity: {this.FuelQuantity}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement