Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2. public abstract class Portable extends Technology
  3. {
  4.  
  5. public int battery;
  6.  
  7. public Portable()
  8. {
  9. battery = (int) ( Math.random()*100+0 );
  10. }
  11.  
  12. public int battery()
  13. {
  14. return battery;
  15. }
  16.  
  17. public void charge()
  18. {
  19. battery = 100;
  20. System.out.println("Your device's battery has been recharged to " + battery + "%");
  21. }
  22.  
  23. public void charge(int percent)
  24. {
  25. if (battery < percent)
  26. {
  27. battery = percent;
  28. System.out.println("Your device's battery has been recharged to " + battery + "%");
  29. }
  30. else
  31. System.out.println("The battery is already at this level.");
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement