Sunteți pe pagina 1din 1

Create a class based on the design shown below.

The default constructor would assign


specific details determined by the programmer for mileage and car number. The
overloaded constructor would assign values for mileage and car number when the object
is created. The setType and setTank functions assign values for type and tank respectively.
The readCarNumber() function returns the mirror image number with its digits in reverse
order. For example, if carNumber is 4079, the readCarNumber() function will return
9704. The toString() function is invoked to display values of all the data. Be wary about
using a double variable with string. Complete the program by creating objects of Car
using both the default constructor and overloaded constructor in the main function. Use
the objects to invoke the related functions.
Car
- mileage : double
- tank : boolean
- type : string
- carNumber : int
+ Car()
+ Car (m: double, cN : int)
+ setType (t : string) : void
+ setTank (tk : boolean) : void
+ getType() : string
+ readCarNumber() : int
+ toString :string

S-ar putea să vă placă și