Question: Create a public class called MultiPass It should store in an instance variable a double that we term the value It should define a single

Create a public class called MultiPass

It should store in an instance variable a double that we term "the value"

It should define a single method called double function(). that behaves slightly differently depending upon which constructor was used to define a MultiPass instance.

It should define three different constructors. Each describes how function should respond

MultiPass()

"the value" should be a Randomly-generated in the constructor

function should simply return "the value" that was created when constructed

MultiPass(double val)

"the value" should be initialized to val

function should update "the value" by multiplying it by 2, It should return the updated version of "the value"

MultiPass(double val, int mult)

"the value" should be initialized to val

mult should also be stored

function should update "the value" by multiplying it by mult, It should return the updated version of "the value"

Examples:

MultiPass mp = new MultiPass();

execute the code: double x1 = mp.function(); double x2 = mp.function();

Then, x1 == x2 evaluates to true

MultiPass mp = new MultiPass(35);

execute the code: double x1 = mp.function(); double x2 = mp.function();

then x1 == 70 evaluates to true

and x2 == 140 evaluates to true

MultiPass mp = new MultiPass(35,3);

execute the code: double x1 = mp.function(); double x2 = mp.function();

then x1 == 105 evaluates to true

and x2 == 315 evaluates to true

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!