diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java index 5ee3f13..f49fbea 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/CasaDeNarino.java @@ -1,16 +1,14 @@ package ca.cosc3p91.a2.gameobjects; -import java.util.ArrayList; - public class CasaDeNarino extends Building { private int goldCapacity = 0; private int ironCapacity = 0; private int woodCapacity = 0; - private int currentGold; - private int currentIron; - private int currentWood; + private int currentGold = 0; + private int currentIron = 0; + private int currentWood = 50; public CasaDeNarino(int lvl, VillageStage baseStage) { setLevel(lvl); @@ -41,23 +39,38 @@ public class CasaDeNarino extends Building { return currentGold; } - public void addCurrentGold(int currentGold) { - this.currentGold += currentGold; + public boolean addGold(int amount) { + int newGold = this.currentGold + amount; + if (newGold <= goldCapacity && this.currentGold + amount >= 0){ + this.currentGold += amount; + return true; + } + return false; } public int getCurrentIron() { return currentIron; } - public void addCurrentIron(int currentIron) { - this.currentIron += currentIron; + public boolean addIron(int amount) { + int newIron = this.currentIron + amount; + if (newIron <= ironCapacity && newIron >= 0) { + this.currentIron += amount; + return true; + } + return false; } public int getCurrentWood() { return currentWood; } - public void addCurrentWood(int currentWood) { - this.currentWood += currentWood; + public boolean addWood(int amount) { + int newWood = this.currentWood + amount; + if (newWood <= woodCapacity && newWood >= 0) { + this.currentWood += amount; + return true; + } + return false; } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java index e1d675d..b9a6859 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/IronMine.java @@ -11,6 +11,6 @@ public class IronMine extends ResourceBuilding { @Override protected ResourceHarvestHandler getHarvestHandler() { - return hall -> hall.addCurrentIron(getHarvestRate()); + return hall -> hall.addIron(getHarvestRate()); } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java index 420d219..0fd2086 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/LumberMine.java @@ -11,7 +11,7 @@ public class LumberMine extends ResourceBuilding { @Override protected ResourceHarvestHandler getHarvestHandler() { - return hall -> hall.addCurrentWood(getHarvestRate()); + return hall -> hall.addWood(getHarvestRate()); } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/SaulGoodMine.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/SaulGoodMine.java index ff56bfa..bb1e088 100644 --- a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/SaulGoodMine.java +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/SaulGoodMine.java @@ -11,6 +11,6 @@ public class SaulGoodMine extends ResourceBuilding { @Override protected ResourceHarvestHandler getHarvestHandler() { - return hall -> hall.addCurrentGold(getHarvestRate()); + return hall -> hall.addGold(getHarvestRate()); } } diff --git a/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java new file mode 100644 index 0000000..f222f87 --- /dev/null +++ b/Assignment 2/src/ca/cosc3p91/a2/gameobjects/VillageHallStages.java @@ -0,0 +1,4 @@ +package ca.cosc3p91.a2.gameobjects; + +public class VillageHallStages { +}