Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Portable extends Technology
- {
- public int battery;
- public Portable()
- {
- battery = (int) ( Math.random()*100+0 );
- }
- public int battery()
- {
- return battery;
- }
- public void charge()
- {
- battery = 100;
- System.out.println("Your device's battery has been recharged to " + battery + "%");
- }
- public void charge(int percent)
- {
- if (battery < percent)
- {
- battery = percent;
- System.out.println("Your device's battery has been recharged to " + battery + "%");
- }
- else
- System.out.println("The battery is already at this level.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement