-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRocket.java
55 lines (53 loc) · 1.32 KB
/
Rocket.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
public class Rocket implements SpaceShip {
private int cost;
private int weight;
private int maxWeight;
private int currWeight;
Rocket(){
this.cost = 0;
this.weight = 0;
this.maxWeight = 0;
this.currWeight = 0;
}
Rocket(int cost, int weight, int maxW){
this.cost = cost;
this.weight = weight;
this.maxWeight = maxW;
this.currWeight = weight;
}
public int getCost(){
return this.cost;
}
public int getWeight(){
return this.weight;
}
public int getmaxWeight(){
return this.maxWeight;
}
public int getCurrWeight(){
return this.currWeight;
}
private void setCurrWeight(int newWeight){
this.currWeight = newWeight;
}
public boolean hasLaunched(){
return true;
}
public boolean hasLanded(){
return true;
}
@Override
public boolean canCarry(Item item){
if (getCurrWeight()+(item.getResourceWeight()) <= getmaxWeight()){
return true;
}
else{
return false;
}
}
@Override
public void carry(Item item){
int newWeight = getCurrWeight() + (item.getResourceWeight());
setCurrWeight(newWeight);
}
}