Skip to content

Commit

Permalink
updated check condition and error for harvestwheat and sellwheat
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTYH committed Oct 24, 2019
1 parent fa0f4c8 commit 6de1e3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/UserCode/Actions/HarvestWheatAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void execute(Ui ui, Storage storage, Farmer farmer, Simulation simulation
farmer.setTaskFailed();
simulation.animate("ErrorInExecution", 0);
if (!farmer.getWheatFarm().hasWheat()) {
ui.typeWriter("Error! you have attempted to harvest wheat despite not having any seedlings/\n");
ui.typeWriter("Error! you have attempted to harvest wheat despite not having any wheat/\n");
} else {
ui.typeWriter("Error! you have attempted to harvest wheat despite not being at the Wheatfarm/\n");
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/UserCode/Actions/SellWheatAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ public SellWheatAction() {

@Override
public void execute(Ui ui, Storage storage, Farmer farmer, Simulation simulation) throws FarmioFatalException, FarmioException {
if (!farmer.getWheatFarm().hasWheat() || !farmer.getLocation().equals("Market")) {
if (!farmer.getWheatFarm().hasGrain() || !farmer.getLocation().equals("Market")) {
farmer.setTaskFailed();
simulation.animate("ErrorInExecution", 0);
if (!farmer.getWheatFarm().hasWheat()) {
ui.typeWriter("Error! you have attempted to sell wheat despite not having any wheat/\n");
if (!farmer.getWheatFarm().hasGrain()) {
ui.typeWriter("Error! you have attempted to sell grain despite not having any grain/\n");
} else {
ui.typeWriter("Error! you have attempted to sell wheat despite not being at the market/\n");
ui.typeWriter("Error! you have attempted to sell grain despite not being at the market/\n");
}
throw new FarmioException("Task Error!");
}
try {
simulation.animate("SellWheatSimulation", 0, 6);
ui.show("Selling wheat!");
ui.show("Selling grain!");
farmer.earnMoney(farmer.getWheatFarm().sell());
simulation.animate(1000, "SellWheatSimulation", 7);
} catch (Exception e) {
Expand Down

0 comments on commit 6de1e3c

Please sign in to comment.