forked from Joberlye/CSC120-A4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.java
More file actions
58 lines (51 loc) · 1.44 KB
/
Copy pathEngine.java
File metadata and controls
58 lines (51 loc) · 1.44 KB
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
import javax.net.ssl.TrustManager;
import javax.swing.plaf.TreeUI;
/**
* The engine class which stores fuel type, max fuel, and current fuel in the engine.
*/
public class Engine {
private FuelType fuelType;
private double maxfuel;
private double currentfuel;
public Engine(FuelType fuelType, double currentfuel, double maxfuel) {
this.fuelType = fuelType;
this.currentfuel = currentfuel;
this.maxfuel = maxfuel;
}
/**
* Getter for fuel type
* @return this.fuelType
*/
public FuelType getfuelType() {
return this.fuelType;
}
/**
* Getter for max fuel that the engine can hold
* @return this.maxfuel
*/
public double getmaxfuel() {
return this.maxfuel;
}
/**
* Getter for the current fuel amount in the engine
* @return this.currentfuel
*/
public double getcurrentfuel() {
return this.currentfuel;
}
/**
* The refuel method resets the current fuel to the max fuel that the engine can hold.
*/
public void refuel() {
this.currentfuel = this.maxfuel;
}
/**
* The go method takes away fuel and prints the remaining fuel until there is no fuel left.
* @return this.currentfuel > 0 (Boolean)
*/
public boolean go() {
this.currentfuel--;
System.out.println("Remaining Fuel:" + this.currentfuel);
return this.currentfuel > 0;
}
}