82.1k views
1 vote
Modify the definition of the throttle class on page 35, to create a new throttle ADT, which allows the user of the ADT to specify the number of shift levels when creating objects of that class. You don't need to provide an implementation of the new throttle ADT, just the class definition.

User HII
by
5.0k points

1 Answer

7 votes

Answer:

seeexplaination

Step-by-step explanation:

Code(header file):

#ifndef THROTTLESHIFTLVEL_H

#define THROTTLESHIFTLVEL_H

class throttle

{

int position;

public:

throttle()

{

position = 0;

}

// specify the number of shift levels when creating objects

throttle(int level)

{

position = level;

}

void shut_off()

{

position = 0;

}

void shift(int amount)

{

if(amount >= 0)

position = position + amount;

}

double flow() const

{

return position;

}

bool is_on() const

{

if (position > 0)

return true;

else

false;

}

};

#endif

Please kindly check attachment for screenshot

Modify the definition of the throttle class on page 35, to create a new throttle ADT-example-1
User Jeanaux
by
4.8k points