0% found this document useful (0 votes)
15 views2 pages

Untitled 2

Uploaded by

detoc49752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Untitled 2

Uploaded by

detoc49752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

class Car
{

private int year;


private string model;
private bool isDrivable;
private double price;

public Car(string model, int year, double price, bool isDrivable = true)
{

this.year = year;
this.model = model;
this.price = price;
this.isDrivable = isDrivable;

public override string ToString()


{

return ($"The model of the car is {model} of {year} year with the price of
${price} and the drivability of car is {isDrivable}.");

}
}

class Cars
{

public static void Main()


{

Car bmv = new Car("BMV I7", 2022, 80000);


Car tesla = new Car("Tesla Model X", 2023, 75500);
Car mclaren = new Car("Maclaren P1", 2017, 3000000);
Car zhigul = new Car("Zaporozes", 1987, 2000, false);
Console.WriteLine(bmv);
Console.WriteLine(tesla);
Console.WriteLine(mclaren);
Console.WriteLine(zhigul);

}
}

You might also like