Question: [SCALA] Write a program with: class Battery with A constructor that takes a variable named charge of type Int . class BoomBox with A constructor

[SCALA]

Write a program with:

[SCALA] Write a program with: class Battery with A constructor that takes

class Battery with A constructor that takes a variable named "charge" of type Int . class BoomBox with A constructor that takes a variable named "battery" of type Battery A method named "use" that takes no parameters and returns Unit This method will decrease the charge of the BoomBox's battery by 3 If the charge of the battery is less than three, this method does nothing A method named "replaceBattery" that takes a Battery as a parameter and returns a Battery This method swaps the input Battery with the Battery currently stored in this BoomBox's state variable The returned Battery is the one that was in the state variable when the method is called class Battery with A constructor that takes a variable named "charge" of type Int . class BoomBox with A constructor that takes a variable named "battery" of type Battery A method named "use" that takes no parameters and returns Unit This method will decrease the charge of the BoomBox's battery by 3 If the charge of the battery is less than three, this method does nothing A method named "replaceBattery" that takes a Battery as a parameter and returns a Battery This method swaps the input Battery with the Battery currently stored in this BoomBox's state variable The returned Battery is the one that was in the state variable when the method is called

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!