Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

state which program was used if its codelite or etc A Class Definition class thr

ID: 3846536 • Letter: S

Question

state which program was used if its codelite or etc

A Class Definition class throttle public: The highlighted code shows CONSTRUCTORS three inline member functions. throttle throttle (int size); MODIFICATION MEMBER FUNCTIONS void shut off C) position 0; void shift int amount); CONSTANT MEMBER FUNCTIONS double flow C const return position doubleCtop position) bool is on C const return Cposition 0) YF private: The type name "double" changes top position int top position; from an integer to a double number. The int position; change is called a "type cast," and it prevents an unintended integer division.

Explanation / Answer

public Throttle(int size,int initial)

{

if(size<=0)

throw new IllegalArgumentException("size<=0:"+size);

if(initial<=0)

throw new IllegalArgumentException("initial<=0:"+initial);

if(initial>size)

throw new IllegalArgumentException("initial too large:"+initial);

top=size;

position=initial;

}