resource: cleaned code
This commit is contained in:
parent
e52d16d01a
commit
3c343d002a
@ -7,7 +7,7 @@ package comp1110.ass2;
|
|||||||
*/
|
*/
|
||||||
public class Resource {
|
public class Resource {
|
||||||
private char type;
|
private char type;
|
||||||
private Coord coord;
|
private final Coord coord;
|
||||||
private boolean claimed;
|
private boolean claimed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,20 +35,14 @@ public class Resource {
|
|||||||
* @return String type of the resource
|
* @return String type of the resource
|
||||||
*/
|
*/
|
||||||
public String getTypeString() {
|
public String getTypeString() {
|
||||||
switch (type){
|
return switch (type) {
|
||||||
case 'C':
|
case 'C' -> "Coconut";
|
||||||
return "Coconut";
|
case 'B' -> "Bamboo";
|
||||||
case 'B':
|
case 'W' -> "Water";
|
||||||
return "Bamboo";
|
case 'P' -> "Precious Stone";
|
||||||
case 'W':
|
case 'S' -> "Statuette";
|
||||||
return "Water";
|
default -> "Invalid";
|
||||||
case 'P':
|
};
|
||||||
return "Precious Stone";
|
|
||||||
case 'S':
|
|
||||||
return "Statuette";
|
|
||||||
default:
|
|
||||||
return "Invalid";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,17 +61,9 @@ public class Resource {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the coordinate of the resource
|
|
||||||
* @param coord Coord coordinate of the resource
|
|
||||||
*/
|
|
||||||
public void setCoord(Coord coord) {
|
|
||||||
this.coord = coord;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the resource is equal to another resource
|
* Check if the resource is equal to another resource
|
||||||
* @param resource Resource resource to be compared
|
* @param resource resource to be compared
|
||||||
* @return boolean true if the resources are equal
|
* @return boolean true if the resources are equal
|
||||||
*/
|
*/
|
||||||
public boolean equals(Resource resource) {
|
public boolean equals(Resource resource) {
|
||||||
@ -96,8 +82,8 @@ public class Resource {
|
|||||||
* Check if the resource has been claimed
|
* Check if the resource has been claimed
|
||||||
* @return boolean true if the resource has been claimed
|
* @return boolean true if the resource has been claimed
|
||||||
*/
|
*/
|
||||||
public boolean isClaimed() {
|
public boolean isAvailable() {
|
||||||
return this.claimed;
|
return !this.claimed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user