subject

Create an application in C# named CarDemo that declares at least two Car objects and demonstrates how they can be incremented using an overloaded ++ operator. Create a Car class that contains the following properties:

Model - The car model (as a string)

Mpg The car's miles per gallon (as a double)

Include two overloaded constructors. One accepts parameters for the model and miles per gallon; the other accepts a model and sets the miles per gallon to 20.

Overload the ++ operator that increases the miles per gallon value by 1. The CarDemo application creates at least one Car using each constructor and displays the Car values both before and after incrementation.

this is what i have:

using static System. Console;

class CarDemo

{

static void Main()

{

Car c1 = new Car("Camero", 25);

Car c2 = new Car("Mustang");

Display("Camero at beginning", c1);

++c1;

Display("Camero after prefix increment", c1);

Display("Mustang at beginning", c2);

++c2;

Display("Mustang after prefix increment", c2);

}

public static void Display(string message, Car)

{

WriteLine(Mpg);

}

class Car

{

private string Model

{

get

{

return model;

}

set

{

model = value;

}

}

private double Mpg

{

get

{

return mpg;

}

set

{

mpg = value;

}

}

public Car(string model, double mpg)

{

Model = model;

Mpg = mpg;

}

public Car(string model)

{

Model = model;

Mpg = 20;

}

public static Car operator++(Car c)

{

++c. Mpg;

return c;

}

}

}

what am i doing wrong?

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:10
Look at the far left lane in the picture. explain what the red car is doing and what it needs to do to travel safely.
Answers: 2
question
Computers and Technology, 23.06.2019 04:20
Which network media uses different regions of the electromagnetic spectrum to transmit signals through air? uses different regions of the electromagnetic spectrum to transmit signals through air.
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
What social factors affect your health
Answers: 3
You know the right answer?
Create an application in C# named CarDemo that declares at least two Car objects and demonstrates ho...
Questions
question
English, 16.12.2020 07:00
question
English, 16.12.2020 07:00
Questions on the website: 13722363