-
Notifications
You must be signed in to change notification settings - Fork 0
/
Droid.java
59 lines (44 loc) · 1.67 KB
/
Droid.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package Basics.OOP;
public class Droid{
public static double batteryLevel = 100;
public static double loadPerMinute = 3;
String name;
public Droid(String droidName) {
name = droidName;
}
public void dance() {
batteryLevel -= 20;
System.out.println(name + " is performing dancing!");
System.out.println("Remaining battery level: " + Droid.batteryLevel + "%");
}
public void coding() {
batteryLevel -= 5;
System.out.println(name + " is performing coding!");
System.out.println("Remaining battery level: " + Droid.batteryLevel + "%");
}
public void clean() {
batteryLevel -= 10;
System.out.println(name + " is performing cleaing!");
System.out.println("Remaining battery level: " + Droid.batteryLevel + "%");
}
public void loading(double inputTime) {
double loading = inputTime * Droid.loadPerMinute;
double loadingtime = (100 - Droid.batteryLevel)/loadPerMinute;
batteryLevel += loading;
System.out.println("Required loadingtime for 100% battery level for " + name + " is " + loadingtime + " minutes.");
System.out.println(name + " is loading battery for " + loadingtime + " minutes! - Loadingspeed: " + Droid.loadPerMinute + " % per minute!");
if (Droid.batteryLevel >= 100){
Droid.batteryLevel = 100;
System.out.println("Battery level at 100% ! Stopp loading.") ;
}else{
System.out.println("Remaining battery level after " + inputTime + " minutes loading time: " + Droid.batteryLevel + "% !");
}
}
public static void main(String[] args) {
Droid Codey = new Droid("Codey");
Codey.dance();
Codey.coding();
//Codey.clean();
Codey.loading(3.4);
}
}