KechevD

oop.phone_2

Feb 17th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class phone {
  2. String brand;
  3. String color;
  4. double battery;
  5. double power;
  6.  
  7. void printInfo() {
  8. System.out.println("Phone's brand: " + this.brand);
  9. System.out.println("Phone's color: " + this.color);
  10. System.out.printf("Phone's battery capacity: %.2f\n", this.battery);
  11. System.out.printf("Phone's power: %.2f\n", this.power);
  12. }
  13.  
  14. void put (double mAh) throws Exception {
  15. if ((this.power + mAh) > this.battery) {
  16. throw new Exception();
  17. } else {
  18. this.power += mAh;
  19. }
  20. }
  21.  
  22.  
  23. }
Add Comment
Please, Sign In to add comment