Define classes Auto, Tank and Date to model an automobile with ID number, odometer, manufacture date, purchase date, miles per gallon, and fuel level, with a driver to test the contructors, >>, <<, and fillUp 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...

Java requires a ________ call for every object that’s created.

a. constructor b. destructor c. parameterless d. parameterized

Computer Science & Information Technology

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

1. A Swing program does not end until it encounters a System.exit statement. 2. When using the BorderLayout manager you must specify all five regions. 3. One of the main functions of JPanel objects is to subdivide a JFrame (or other container) into different areas. 4. Events and listeners for menu items are handled in exactly the same way as they are for buttons. 5. A JMenu can not be a menu item in another menu.

Computer Science & Information Technology

The Replace Fonts command can replace all of one font in a presentation without the need to search for and select text on slides

Indicate whether the statement is true or false

Computer Science & Information Technology

Define the term topology, and draw a sketch of each wired and wireless network topology.

What will be an ideal response?

Computer Science & Information Technology