Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package app;
- class Charger {
- public int getElectricity() {
- return 10;
- }
- }
- class Handphone {
- private Charger charger = new Charger();
- private Integer battery = 0;
- public void charge() {
- this.battery = this.battery + this.charger.getElectricity();
- }
- public int checkBatteryStatus() {
- return this.battery;
- }
- }
- public class Contoh1 {
- public static void main(String[] args) {
- Handphone hp = new Handphone();
- while (hp.checkBatteryStatus() < 100) {
- System.out.print("Mengisi daya...");
- System.out.println(hp.checkBatteryStatus());
- hp.charge();
- }
- System.out.print("Selesai...");
- System.out.println(hp.checkBatteryStatus());
- }
- }
Add Comment
Please, Sign In to add comment