Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class phone {
- String brand;
- String color;
- double battery;
- double power;
- void printInfo() {
- System.out.println("Phone's brand: " + this.brand);
- System.out.println("Phone's color: " + this.color);
- System.out.printf("Phone's battery capacity: %.2f\n", this.battery);
- System.out.printf("Phone's power: %.2f\n", this.power);
- }
- void put (double mAh) throws Exception {
- if ((this.power + mAh) > this.battery) {
- throw new Exception();
- } else {
- this.power += mAh;
- }
- }
- }
Add Comment
Please, Sign In to add comment