Define classes Auto, Tank and Date to model an automobile with ID number, odometer, manufacture date, purchase date, miles per gallon, and drive functions, which fill the tank and drive the car respectively.

What will be an ideal response?


```
class Date {
public:
Date() {} // default constructor
Date(int, int, int); // initializing constructor
int getMonth() const; // accessor
int getDay() const; // accessor
int getYear() const; // accessor

private:
int month, day, year;

friend istream& operator>> (istream&, Date&);
};

class Tank {
public:
Tank() {} // default constructor
Tank(double, double); // initializing constructor
double fillUp(); // fills tank and reports # gallons needed
void decrease(double); // decreases level in tank
double getCapacity() const; // accessor
double getCurrent() const; // accessor

private:
double capacity, current;

friend istream& operator>> (istream&, Tank&);
};

class Auto {
public:
Auto() {} // default constructor
Auto(int, int, const Date, const Date, double, const Tank);
// constructor with component classes
Auto(int, int, int,int,int, int,int,int, double, double, double);
// constructor with all component values
void drive(int); // adjust fuel and odometer for given miles
double fillUpTank(); // fill the tank up

private:
int ID, odometer;
Date manufacture, purchase;
double mpg;
Tank fueltank;

friend istream& operator>> (istream&, Auto&);
friend ostream& operator<< (ostream&, const Auto&);
};

```

Computer Science & Information Technology

You might also like to view...

What is the output of the following code segment if the data entered are 3, 2 and 4?

int x, y, z; cout << “Enter three numbers: “; cin >> x >> y >> z; y = x + z; x = z + 1; cout << x << “ “ << y<< “ “ << z;

Computer Science & Information Technology

The box properties are used to ____.

A. set the width and height for the box B. add white space around the content C. add a border around the content D. all of the above

Computer Science & Information Technology

Item A in the accompanying figure is used to create a new document in InDesign.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The Show Markup list arrow lets you view markup by reviewer.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology