D
David
I am stumped ..how do I use the flag (secton c)
INHERITANCE
(a) Create a class Car that conatins two integer fields. One holds a flag
indicating whether the
ignition is on; the other holds the Car's current speed in miles per
hour. There are four member
functions: two functions that turns the igition on and off, a setSpeedO
function that sets the
Car's speed, and a showCarO function that displays a Car's states.
(b) The function that displays the values of a Car's fields uses the value
of the isIgnitionOn
flag to determine whether the Car is running. It also displays the
current speed of the Car.
(c) The two functions named turnIgnitionOnO and turnIgnitionOffO are
similar; each sets the value
of the isIgnitionOn flag using 1 to represent true and 0 to represent
false.
(d) The setSpeedO function takes an integer argument and uses it to set the
value of the speed
field. However, no Car is allowed to speed greater than 65 miles per
hour, and no Car is
allowed any speed other than 0 if the ignition is off.
(e) Add a mainO function that demonstrate the functions at work. The maninO
function declares
a Car object, turns the Car on and sets a speed. Show the car values as
well.
(f) Define the Convertible class as an extension of the Car class. The
Convertible class contains
one new data member named isTopUp that holds the status of the
Convertible's top.
Three functions work with this data field: one puts the top up ;
another puts it down and the
third prints a message regarding the top's status.
(g) The functions putTopUPO and putTopDownO set the isTopUp field to 1 and
0, respectively.
(h) The ShowTopStatusO function prints an appropriate message based on the
status of the
isTopUp field.
(i) Lastly, re-write the mainO program that declares a Convertible object
and uses the
functions to start the Convertible, set the spped, put the top down and
up and so on.*/
#include <iostream>
using namespace std;
class car
{
public:
void setSpeet(int mph)
void turnOn();
void turnOff();
void showCar
private:
int isIgnitionOn;
int speed;
/* Ignition On --> set isIgnitionOn =1
Ignition Off --> set isIgnitionOn =0
Ignition Off --> set speed =0 */
INHERITANCE
(a) Create a class Car that conatins two integer fields. One holds a flag
indicating whether the
ignition is on; the other holds the Car's current speed in miles per
hour. There are four member
functions: two functions that turns the igition on and off, a setSpeedO
function that sets the
Car's speed, and a showCarO function that displays a Car's states.
(b) The function that displays the values of a Car's fields uses the value
of the isIgnitionOn
flag to determine whether the Car is running. It also displays the
current speed of the Car.
(c) The two functions named turnIgnitionOnO and turnIgnitionOffO are
similar; each sets the value
of the isIgnitionOn flag using 1 to represent true and 0 to represent
false.
(d) The setSpeedO function takes an integer argument and uses it to set the
value of the speed
field. However, no Car is allowed to speed greater than 65 miles per
hour, and no Car is
allowed any speed other than 0 if the ignition is off.
(e) Add a mainO function that demonstrate the functions at work. The maninO
function declares
a Car object, turns the Car on and sets a speed. Show the car values as
well.
(f) Define the Convertible class as an extension of the Car class. The
Convertible class contains
one new data member named isTopUp that holds the status of the
Convertible's top.
Three functions work with this data field: one puts the top up ;
another puts it down and the
third prints a message regarding the top's status.
(g) The functions putTopUPO and putTopDownO set the isTopUp field to 1 and
0, respectively.
(h) The ShowTopStatusO function prints an appropriate message based on the
status of the
isTopUp field.
(i) Lastly, re-write the mainO program that declares a Convertible object
and uses the
functions to start the Convertible, set the spped, put the top down and
up and so on.*/
#include <iostream>
using namespace std;
class car
{
public:
void setSpeet(int mph)
void turnOn();
void turnOff();
void showCar
private:
int isIgnitionOn;
int speed;
/* Ignition On --> set isIgnitionOn =1
Ignition Off --> set isIgnitionOn =0
Ignition Off --> set speed =0 */