subject

Write a class Battery that models a rechargeable battery. A battery has a constructor

public Battery(double capacity)
where capacity is a value measured in milliampere hours. A typical AA battery has a capacity of 2000 to 3000 mAh. The method

public void drain(double amount)
drains the capacity of the battery by the given amount. The method

public void charge()
charges the battery to its original capacity.

The method

public double getRemainingCapacity()
gets the remaining capacity of the battery.

Supply a Battery class that tests all methods. Make sure to print the remaining capacity.

If we create an instance of Battery class with 2000 mAh, call drain (500) and then call getRemainingCapacity(), it should print 1500mAh; now if we call charge() and then call getRemainingCapacity() it should print 2000mAh

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
Pthe price of tickets in a group when a purchased in bulk can be found with the equation c=px+24 were c is the cost, p is the number of people,and x is the price per ticket. what is price of of each ticket if it costs $189 to buy tickets for 15 people ? a $8 b $24c $9d $11 show work
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
question
Computers and Technology, 24.06.2019 00:20
The guy wire bd exerts on the telephone pole ac a force p directed along bd. knowing the p must have a 720-n component perpendicular to the pole ac, determine the magnitude of force p and its component along line ac.
Answers: 2
question
Computers and Technology, 24.06.2019 18:10
Most information security incidents will occur because of select one: a. users who do not follow secure computing practices and procedures b. increases in hacker skills and capabilities c. poorly designed network protection software d. increasing sophistication of computer viruses and worms
Answers: 1
You know the right answer?
Write a class Battery that models a rechargeable battery. A battery has a constructor

pu...
Questions
question
Mathematics, 01.07.2021 01:00