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, 21.06.2019 21:40
Which is a benefit of getting information from a government website? a. the information will be easy to understand. ob. the information will be the most current. oc. the information can be trusted.
Answers: 1
question
Computers and Technology, 22.06.2019 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
question
Computers and Technology, 22.06.2019 15:00
Atool that matches persoal skills qualities interests and talets to a career is called a
Answers: 1
question
Computers and Technology, 22.06.2019 16:20
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
You know the right answer?
Create an application in C# named CarDemo that declares at least two Car objects and demonstrates ho...
Questions
question
Mathematics, 03.02.2021 21:30
question
English, 03.02.2021 21:30
question
Mathematics, 03.02.2021 21:30
Questions on the website: 13722363