diff --git a/pom.xml b/pom.xml index 69a3b87..870cb2e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,20 @@ com.zipcodewilmington froilans-farm 1.0-SNAPSHOT + + + junit + junit + 4.13.1 + test + + + org.junit.jupiter + junit-jupiter + RELEASE + compile + + \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Aircraft.java b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Aircraft.java new file mode 100644 index 0000000..e6377e5 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Aircraft.java @@ -0,0 +1,13 @@ +package com.zipcodewilmington.froilansfarm.abstractClasses; + +import com.zipcodewilmington.froilansfarm.interfaces.Pilot; +import com.zipcodewilmington.froilansfarm.interfaces.Vehicle; + +public abstract class Aircraft implements Vehicle { + + public boolean fly(){ + System.out.println("Flying~~~"); + return true; + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Crop.java b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Crop.java new file mode 100644 index 0000000..0fba4ea --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Crop.java @@ -0,0 +1,37 @@ +package com.zipcodewilmington.froilansfarm.abstractClasses; + + +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import com.zipcodewilmington.froilansfarm.interfaces.Produce; + +public abstract class Crop implements Produce { + public boolean hasBeenFertilized = false; + public boolean hasBeenHarvested = false; + public void setHasBeenFertilized(boolean hasBeenFertilized){ + this.hasBeenFertilized = hasBeenFertilized; + } + + public void setHasBeenHarvested(boolean hasBeenHarvested){ + this.hasBeenHarvested = hasBeenHarvested; + } + + + /* + * So here in Crop, Crop is also a generic, because we'll want each class + * inheriting it to specify what kind of Edible it will Produce, etc, etc. + * We went through a similar process with Eater. + * + * Anyway! The cool thing about Crop is that its + * type parameter upper bound is NOT Edible. + * It's EdibleCrops! + * By doing this, we'll be able to eliminate EdibleEgg as a possible thing + * our Crops can yield -- because EdibleEgg will not be inheriting EdibleCrops. + * AND we can still pass the EdibleCropsType into Produce because + * EdibleCropsType is an Edible! + * We are just using EdibleCrops to limit ourselves to a certain subset + * of Edibles we can use for Crops. + * + * >>> CornStalk + */ + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/EdibleStorage.java b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/EdibleStorage.java new file mode 100644 index 0000000..9208be0 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/EdibleStorage.java @@ -0,0 +1,9 @@ +package com.zipcodewilmington.froilansfarm.abstractClasses; + +import com.zipcodewilmington.froilansfarm.interfaces.Edible; + +import java.util.ArrayList; + +public abstract class EdibleStorage extends ArrayList { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Housing.java b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Housing.java new file mode 100644 index 0000000..429bfef --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Housing.java @@ -0,0 +1,38 @@ +package com.zipcodewilmington.froilansfarm.abstractClasses; + +import com.zipcodewilmington.froilansfarm.interfaces.Animal; + +import java.util.ArrayList; + +public abstract class Housing extends ArrayList { + + /* + * Housing is fun because you don't have to write anything in it + * and in the things that inherit it!!! :DDDDDDDD + * + * Housing is inheriting from ArrayList (extends ArrayList), + * so it inherits all of ArrayLists methods (add, remove, size, etc. etc.) + * + * The generics here are saying that Housing (and anything inheriting Housing) + * will hold (or be a list of, since it's inheriting from ArrayList) + * many certain somethings that is inheriting from Animal. + * That's this line here: Housing + * Since we want to be consistent, and since ArrayList itself is also a generic class, + * we put AnimalType as a type parameter for ArrayList (ArrayList) + * + * We put this generic here because we want Housing to only ever handle things that + * are Animals!!!! + * By doing this, we make it so that it can't handle + * other things like Corn or Tractors or etc, etc, etc. + * + * Note: AnimalType here works like a method parameter name... + * ... except instead of name, it's data type + * So if you have any methods in here that uses/returns the animal, + * you would use AnimalType as the data type + * + * The method signature for the add method inherited from ArrayList would look like this: + * public boolean add(AnimalType animalToAdd); + * + */ + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Person.java b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Person.java new file mode 100644 index 0000000..bf28363 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/abstractClasses/Person.java @@ -0,0 +1,22 @@ +package com.zipcodewilmington.froilansfarm.abstractClasses; + +import com.zipcodewilmington.froilansfarm.interfaces.Animal; +import com.zipcodewilmington.froilansfarm.interfaces.Edible; +import com.zipcodewilmington.froilansfarm.interfaces.Rideable; +import com.zipcodewilmington.froilansfarm.interfaces.Rider; + +public abstract class Person implements Animal { + @Override + public String makeNoise() { + return "What a great Day"; + } + + @Override + public boolean eat(Edible edible, EdibleStorage edibleStorage) { + if (edibleStorage.contains(edible)) { + return edibleStorage.remove(edible); + } + System.out.println("We don't got this!"); + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/CropRow.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/CropRow.java new file mode 100644 index 0000000..a736c8c --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/CropRow.java @@ -0,0 +1,10 @@ +package com.zipcodewilmington.froilansfarm.classes; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; + +import java.util.ArrayList; + +public class CropRow extends ArrayList { + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/Farm.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Farm.java new file mode 100644 index 0000000..734c829 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Farm.java @@ -0,0 +1,72 @@ +package com.zipcodewilmington.froilansfarm.classes; + +import com.zipcodewilmington.froilansfarm.classes.storage.*; + +import java.util.ArrayList; + +public class Farm { + ArrayList stables; + ArrayList coops; + FarmHouse farmHouse; + Field field; + TomatoStorage tomatoStorage; + PotatoStorage potatoStorage; + CornStorage cornStorage; + EggStorage eggStorage; + + public Farm(FarmHouse farmHouse){ + this.farmHouse = farmHouse; + this.stables = new ArrayList<>(); + this.coops = new ArrayList<>(); + } + + public void addStables(Stable stable){ + stables.add(stable); + } + + public void addCoops(ChickenCoop coop){ + coops.add(coop); + } + + public ArrayList getStables(){ return this.stables; } + public ArrayList getCoops(){ return this.coops; } + + public void setTomatoStorage(TomatoStorage tomatoStorage){ + this.tomatoStorage = tomatoStorage; + } + + public TomatoStorage getTomatoStorage(){ + return this.tomatoStorage; + } + + public void setPotatoStorage(PotatoStorage potatoStorage) { + this.potatoStorage = potatoStorage; + } + + public PotatoStorage getPotatoStorage() { + return potatoStorage; + } + + public void setCornStorage(CornStorage cornStorage) { + this.cornStorage = cornStorage; + } + + public CornStorage getCornStorage() { + return cornStorage; + } + + public void setEggStorage(EggStorage eggStorage) { + this.eggStorage = eggStorage; + } + + public EggStorage getEggStorage() { + return eggStorage; + } + + public Field getField(){ + return this.field; + } + public void setField(Field field){ + this.field = field; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/Farmer.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Farmer.java new file mode 100644 index 0000000..2c9139f --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Farmer.java @@ -0,0 +1,72 @@ +package com.zipcodewilmington.froilansfarm.classes; + +import com.zipcodewilmington.froilansfarm.classes.food.CornStalk; +import com.zipcodewilmington.froilansfarm.classes.food.PotatoPlant; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.interfaces.Botanist; +import com.zipcodewilmington.froilansfarm.abstractClasses.Person; +import com.zipcodewilmington.froilansfarm.interfaces.Rider; + +public class Farmer extends Person implements Botanist, Rider { + + @Override + public boolean mount(Tractor tractor) { + if(tractor.isIfMounted() == false){ // is false cause nobody is on the tractor + tractor.setIfMounted(true); // the tractor is mounted + return true; + } + return false; + } + + @Override + public boolean dismount(Tractor tractor) { + if(tractor.isIfMounted() == true){ // is true cause somebody is on the tractor + tractor.setIfMounted(false);// the tractor is not mounted + return true; + } + return false; + } + + + // boolean ifMounted = false; started the horse with nobody on the horse + @Override + public boolean mount(Horse horse) { + if(horse.getIfMounted() == false){ // is false cause nobody is on the horse + horse.setIfMounted(true); // the horse is mounted + return true; + } + return false; + } + + @Override + public boolean dismount(Horse horse) { + if(horse.getIfMounted() == true){ // is true cause somebody is on the horse + horse.setIfMounted(false);// the horse is not mounted + return true; + } + return false; + } + + // I forgot to ask dolio about theseeeee + // ideally you would not want to write plant n times like this + // supposed to use generics to make a general plant method + // for all types of valid crops + // i.e. plant(Crop crop, CropRow cropRow)... or something like this + // but it was giving us grief so we forced it like so below :D + @Override + public boolean plant(TomatoPlant crop, CropRow cropRow) { + return cropRow.add(crop); + } + + @Override + public boolean plant(PotatoPlant crop, CropRow cropRow) { + return cropRow.add(crop); + } + + @Override + public boolean plant(CornStalk crop, CropRow cropRow) { + return cropRow.add(crop); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/Field.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Field.java new file mode 100644 index 0000000..08f8fff --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Field.java @@ -0,0 +1,12 @@ +package com.zipcodewilmington.froilansfarm.classes; + +import com.zipcodewilmington.froilansfarm.classes.food.CornStalk; +import com.zipcodewilmington.froilansfarm.classes.food.PotatoPlant; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; + +import java.util.ArrayList; + +public class Field extends ArrayList { + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/Froilan.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Froilan.java new file mode 100644 index 0000000..0cb2131 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Froilan.java @@ -0,0 +1,5 @@ +package com.zipcodewilmington.froilansfarm.classes; + + +public class Froilan extends Farmer { +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/Froilanda.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Froilanda.java new file mode 100644 index 0000000..bfc1a62 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/Froilanda.java @@ -0,0 +1,51 @@ +package com.zipcodewilmington.froilansfarm.classes; +import com.zipcodewilmington.froilansfarm.abstractClasses.Person; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.interfaces.Pilot; + +public class Froilanda extends Person implements Pilot { + + boolean ifMounted = false; // no one mounted it + + @Override + public boolean mount(CropDuster cropDuster) { + if(cropDuster.getIfMouted() == false){ + cropDuster.setIfMouted(true); + return true; + } + + + return false; + } + + @Override + public boolean dismount(CropDuster cropDuster) { + if(cropDuster.getIfMouted() == true) { + cropDuster.setIfMouted(false); + return true; + + } + return false; + } + + @Override + public boolean mount(Horse horse) { + if(horse.getIfMounted() == false){ + horse.setIfMounted(true); + return true; + } + return false; + } + + @Override + public boolean dismount(Horse horse) { + if(horse.getIfMounted() == true){ + horse.setIfMounted(true); + return true; + } + return false; + } + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Chicken.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Chicken.java new file mode 100644 index 0000000..571fd6a --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Chicken.java @@ -0,0 +1,71 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.storage.PotatoStorage; +import com.zipcodewilmington.froilansfarm.interfaces.Animal; +import com.zipcodewilmington.froilansfarm.interfaces.Produce; + +import java.util.Random; + +public class Chicken implements Animal, Produce { + + /* + * DON'T LOOK AT METHODS THEY'RE MESSY :( + * I'm kidding. + * But ya, it's messy. + * + * Anyway, Chicken is inheriting Animal and Produce. + * These two interfaces are GENERIC. You can tell because <> beside them. + * You can see below that our Chicken's eat method has Potato as a + * parameter. (Ignore the storage, it's following the same pattern though) + * This method SIGNATURE was automatically made for us + * when we told intelliJ that we'd like to implement methods, + * and the reason why was written in Animal :D + * + */ + + + boolean hasBeenFertilized; + + public Chicken(){ + // setting hasBeenFertilized to random true or false + Random random = new Random(); + int num = random.nextInt(2); + if(num == 1){ + this.hasBeenFertilized = false; + } + else{ + this.hasBeenFertilized = true; + } + } + + public void setHasBeenFertilized(boolean hasBeenFertilized){ + this.hasBeenFertilized = hasBeenFertilized; + } + + @Override + public String makeNoise() { + + return "chrip"; + } + + @Override + public EdibleEgg yield() { + if (this.hasBeenFertilized == true){ + return null; + } + return new EdibleEgg(); + + } + + + @Override + public boolean eat(Potato edible, EdibleStorage edibleStorage) { + if (edibleStorage.contains(edible)) { + return edibleStorage.remove(edible); + } + System.out.println("We don't got this!"); + return false; + + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/CornStalk.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/CornStalk.java new file mode 100644 index 0000000..9b09825 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/CornStalk.java @@ -0,0 +1,24 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; + +public class CornStalk extends Crop { + + /* + * Here be Crop. + * You may change EarCorn in the <> to EdibileEgg. IntelliJ will + * yell at you and tell you that it's not within the bounds :) + * + */ + + @Override + public EarCorn yield() { + if(this.hasBeenFertilized && this.hasBeenHarvested){ + this.hasBeenHarvested = false; + this.hasBeenFertilized = false; + return new EarCorn(); + } + return null; + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/EarCorn.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/EarCorn.java new file mode 100644 index 0000000..0460116 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/EarCorn.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; + +public class EarCorn implements EdibleCrops { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/EdibleEgg.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/EdibleEgg.java new file mode 100644 index 0000000..b8522ef --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/EdibleEgg.java @@ -0,0 +1,12 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.interfaces.Edible; + +import java.util.Random; + +public class EdibleEgg implements Edible { + + + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Potato.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Potato.java new file mode 100644 index 0000000..9f2a96e --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Potato.java @@ -0,0 +1,10 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.interfaces.Edible; +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; + +public class Potato implements EdibleCrops { + + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/PotatoPlant.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/PotatoPlant.java new file mode 100644 index 0000000..0f14c70 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/PotatoPlant.java @@ -0,0 +1,17 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; + +public class PotatoPlant extends Crop { + + + @Override + public Potato yield() { + if(this.hasBeenFertilized && this.hasBeenHarvested){ + this.hasBeenHarvested = false; + this.hasBeenFertilized = false; + return new Potato(); + } + return null; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Tomato.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Tomato.java new file mode 100644 index 0000000..b136304 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/Tomato.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; + +public class Tomato implements EdibleCrops { + +} \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/TomatoPlant.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/TomatoPlant.java new file mode 100644 index 0000000..ad65109 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/food/TomatoPlant.java @@ -0,0 +1,17 @@ +package com.zipcodewilmington.froilansfarm.classes.food; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; + +public class TomatoPlant extends Crop { + + + @Override + public Tomato yield() { + if(this.hasBeenFertilized && this.hasBeenHarvested){ + this.hasBeenHarvested = false; // Begin the process again. + this.hasBeenFertilized = false; //Begin the process again. + return new Tomato(); + } + return null; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/CropDuster.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/CropDuster.java new file mode 100644 index 0000000..b6245c0 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/CropDuster.java @@ -0,0 +1,42 @@ +package com.zipcodewilmington.froilansfarm.classes.rideables; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Aircraft; +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; +import com.zipcodewilmington.froilansfarm.interfaces.Pilot; +import com.zipcodewilmington.froilansfarm.classes.Farm; +import com.zipcodewilmington.froilansfarm.interfaces.FarmVehicle; + +public class CropDuster extends Aircraft implements FarmVehicle { + + + boolean ifMouted = false; + + + public boolean getIfMouted() { + return this.ifMouted; + } + + + public boolean setIfMouted(boolean mounted) { + return this.ifMouted = mounted; + + } + + public void fertilize(CropRow cropRow){ + for(Crop c : cropRow){ + c.setHasBeenFertilized(true); + } + } + + @Override + public boolean operator(Farm farm) { + + return true; + } + + @Override + public String makeNoise() { + return "Whir~~~~!"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/Horse.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/Horse.java new file mode 100644 index 0000000..30a4d31 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/Horse.java @@ -0,0 +1,40 @@ +package com.zipcodewilmington.froilansfarm.classes.rideables; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.abstractClasses.Person; +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; +import com.zipcodewilmington.froilansfarm.interfaces.Animal; +import com.zipcodewilmington.froilansfarm.interfaces.Edible; +import com.zipcodewilmington.froilansfarm.interfaces.Rideable; +import com.zipcodewilmington.froilansfarm.interfaces.Rider; + +public class Horse implements Rideable,Animal { + + boolean ifMounted = false;// started the horse with nobody on the horse + + public boolean getIfMounted(){ + return this.ifMounted; + } + + public void setIfMounted(boolean mounted){ + this.ifMounted = mounted; + } + + + + @Override + public String makeNoise() { + return "Neighhhhhh"; + } + + + + @Override + public boolean eat(EarCorn edible, EdibleStorage edibleStorage) { + if (edibleStorage.contains(edible)) { + return edibleStorage.remove(edible); + } + System.out.println("We don't got this!"); + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/Tractor.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/Tractor.java new file mode 100644 index 0000000..75af2c4 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/rideables/Tractor.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.froilansfarm.classes.rideables; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.Farm; +import com.zipcodewilmington.froilansfarm.classes.Farmer; +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; +import com.zipcodewilmington.froilansfarm.interfaces.Edible; +import com.zipcodewilmington.froilansfarm.interfaces.FarmVehicle; + +public class Tractor implements FarmVehicle { + + boolean ifMouted = false; + + public boolean isIfMounted() { + return this.ifMouted; + } + + public void setIfMounted(boolean mouted) { + this.ifMouted = mouted; + } + + +// needs a havest crop method + + @Override + public boolean operator(Farm farm) { + return true; + } + + @Override + public String makeNoise() { + return "RrrooMMMMM"; + } + + public int harvestCrop(CropRow cropRow, EdibleStorage storage) { + int countCrop = 0; + + for (Crop c : cropRow) { + c.setHasBeenHarvested(true); + Edible e = c.yield(); + if( e != null){ + storage.add(e); + countCrop++; + } + } + return countCrop; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/ChickenCoop.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/ChickenCoop.java new file mode 100644 index 0000000..9b6e901 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/ChickenCoop.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Housing; +import com.zipcodewilmington.froilansfarm.classes.food.Chicken; + +public class ChickenCoop extends Housing { +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/CornStorage.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/CornStorage.java new file mode 100644 index 0000000..83aab3a --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/CornStorage.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; + +public class CornStorage extends EdibleStorage { +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/EggStorage.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/EggStorage.java new file mode 100644 index 0000000..edf3644 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/EggStorage.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.EdibleEgg; + +public class EggStorage extends EdibleStorage { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/FarmHouse.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/FarmHouse.java new file mode 100644 index 0000000..e3eade7 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/FarmHouse.java @@ -0,0 +1,9 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + + +import com.zipcodewilmington.froilansfarm.abstractClasses.Housing; +import com.zipcodewilmington.froilansfarm.abstractClasses.Person; + +public class FarmHouse extends Housing { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/PotatoStorage.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/PotatoStorage.java new file mode 100644 index 0000000..910697b --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/PotatoStorage.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.Potato; + +public class PotatoStorage extends EdibleStorage { +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/Stable.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/Stable.java new file mode 100644 index 0000000..3038063 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/Stable.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Housing; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; + +public class Stable extends Housing { +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/TomatoStorage.java b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/TomatoStorage.java new file mode 100644 index 0000000..47ea344 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/classes/storage/TomatoStorage.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.classes.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; + +public class TomatoStorage extends EdibleStorage { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Animal.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Animal.java new file mode 100644 index 0000000..1dcaddf --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Animal.java @@ -0,0 +1,24 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +public interface Animal extends Eater,NoiseMaker{ + + /* + * Animal is a generic interface that inherits from + * the generic interface Eater and the interface NoiseMaker. + * + * Animal has type parameter of something that extends Edible. + * This is because not every Animal will eat the same Edible, + * so we're making it so that when an Animal is created, we + * have to specify what Edible it eats, and we'll pass that onto Eater. + * (that's why Eater here has ) + * + * In the case of Braeburn's farm, Chickens can only eat Potatoes. + * You'll see later in Chicken that its signature will look like this: + * public class Chicken implements Animal... we're establishing in + * the code that all Chickens will eat Potatoes. + * That Potato will pass into this interface, then will be passed into Eater + * where it will be set as the type for the eat method there. + * + * Pls head to Chicken :) + */ +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Botanist.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Botanist.java new file mode 100644 index 0000000..2a35203 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Botanist.java @@ -0,0 +1,19 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.food.CornStalk; +import com.zipcodewilmington.froilansfarm.classes.food.PotatoPlant; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; + +public interface Botanist { + boolean plant(TomatoPlant crop, CropRow cropRow); + boolean plant(PotatoPlant crop, CropRow cropRow); + boolean plant(CornStalk crop, CropRow cropRow); + +} + + + + + + diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Eater.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Eater.java new file mode 100644 index 0000000..639661c --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Eater.java @@ -0,0 +1,18 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; + +public interface Eater< EdibleType extends Edible> { + public boolean eat(EdibleType edible, EdibleStorage edibleStorage); + + /* + * Eater is a generic interface with a type parameter of something + * extending Edible. + * Anything inheriting Eater will have to provide something that extends Edible + * and that something will be applied to the eat method (automatically!!!!) + * in whatever class is implementing the methods. + * For example, Chicken. + * + * But look at Animal first. + */ +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Edible.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Edible.java new file mode 100644 index 0000000..ecc7129 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Edible.java @@ -0,0 +1,12 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +public interface Edible { + + /* + * There's nothing here :D Just know it exists + * and things are inheriting it. + * + * >>> EdibleCrops + */ + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/EdibleCrops.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/EdibleCrops.java new file mode 100644 index 0000000..87d6ad0 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/EdibleCrops.java @@ -0,0 +1,34 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +public interface EdibleCrops extends Edible { + + /* + * But Braeburn why the heck do you have an EdibleCrops interface + * when we already have Edible??? + * + * Dolio told us to add it :D + * + * But really, it makes sense. + * We have 4 things inheriting Produce: Chicken + our Crops + * Our Produces have a type parameter extending Edible that + * will be used as the return type for their yield methods. + * So CornStalk will have a yield that returns EarCorn, + * TomatoPlant will have a yield that returns Tomato, + * etc. etc. etc. + * All good right? We made Produce generic! + * + * :DDDD Not really :DDDD + * + * Because the upper bound for the type in Produce is vague, + * when Crop inherits Produce, it'll allow the classes inheriting it to be able to yield + * things that they aren't supposed to be yielding. Like: + * TomatoPlant will have a yield that returns EdibleEgg. + * This is something that could happen because EdibleEgg is also an Edible! + * + * So! We have to create something that will only + * encapsulate all Edibles but EdibleEgg -- which is this EdibleCrops interface! + * (Our tomatoe, potato, and corn inherit this interface) + * + * >>> Crop + */ +} \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/FarmVehicle.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/FarmVehicle.java new file mode 100644 index 0000000..4821ad9 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/FarmVehicle.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +import com.zipcodewilmington.froilansfarm.classes.Farm; + +public interface FarmVehicle extends Vehicle { + + boolean operator(Farm farm); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/NoiseMaker.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/NoiseMaker.java new file mode 100644 index 0000000..335885d --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/NoiseMaker.java @@ -0,0 +1,5 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +public interface NoiseMaker { + String makeNoise(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Pilot.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Pilot.java new file mode 100644 index 0000000..6447679 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Pilot.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + + +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.interfaces.Rideable; +import com.zipcodewilmington.froilansfarm.interfaces.Rider; + +public interface Pilot extends Rider { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Produce.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Produce.java new file mode 100644 index 0000000..a7b22b7 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Produce.java @@ -0,0 +1,38 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +public interface Produce < EdibleType extends Edible> { + EdibleType yield(); + + /* + * Produce is a generic interface with a type parameter + * of something that extends Edible. + * That something will be the return type of the yield method. + * + * Generics are Great because it can stop us from allowing + * potentially silly things to happen in our code! + * + * For example, if we took out the generics, Produce would look like + * this: + * public interface Produce{ + * Edible yield(); + * } + * + * Silly things can happen here! + * We got 4 different things inheriting Produce, and we got + * 4 different Edibles. + * We could have TomatoPlants yielding Eggs + * or PotatoPlants yielding EarCorn + * or Chickens yielding Tomatoes + * + * !BECAUSE THIS CODE IS TOO VAGUE! + * + * With the generics, the code is saying, + * "we got a produce, and we'll give it a certain type of edible, + * and it'll only be able to yield that certain type of edible" + * + * ... and so Chickens never laid Tomatoes again :( + * unless, y'know, you set its edible type as Tomato + * + * >>> Edible + */ +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Rideable.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Rideable.java new file mode 100644 index 0000000..e888a76 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Rideable.java @@ -0,0 +1,4 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +public interface Rideable < RiderType1 extends Rider>{ +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Rider.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Rider.java new file mode 100644 index 0000000..1e715bb --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Rider.java @@ -0,0 +1,15 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + +import com.zipcodewilmington.froilansfarm.interfaces.Rideable; + +public interface Rider { + + boolean mount(RideableType rideableType); + boolean dismount(RideableType rideableType); + + boolean mount(RideableType2 rideableType2); + boolean dismount(RideableType2 rideableType2); + + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Vehicle.java b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Vehicle.java new file mode 100644 index 0000000..a96773e --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/interfaces/Vehicle.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.interfaces; + + +public interface Vehicle extends NoiseMaker, Rideable{ + + + // Note: might have to make another interface for riders of man-made vehicles. + // i.e., pilot, farmer + // because horseRider can only ride horses, the here is too vague + // it will include horseRiders as an acceptable Rider for Vehicles +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/CropRowTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/CropRowTests.java new file mode 100644 index 0000000..d1e7e37 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/CropRowTests.java @@ -0,0 +1,36 @@ +package com.zipcodewilmington.froilansfarm.classesTests; + +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class CropRowTests { + CropRow tomatoCropRow; + TomatoPlant tomatoPlant; + +@Before +public void setup(){ + tomatoCropRow = new CropRow<>(); + tomatoPlant = new TomatoPlant(); +} + + @Test + public void testCropRow (){ + CropRow tomato = new CropRow(); + assertNotNull(tomato); + } + @Test + public void getTest(){ + // if adding tomato plant to a croprow im get + // back a tomato plant + tomatoCropRow.add(tomatoPlant); + TomatoPlant actual = tomatoCropRow.get(0); + Assert.assertEquals(actual, tomatoPlant); + + } + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FarmTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FarmTests.java new file mode 100644 index 0000000..da41b8b --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FarmTests.java @@ -0,0 +1,18 @@ +package com.zipcodewilmington.froilansfarm.classesTests; + +import com.zipcodewilmington.froilansfarm.classes.Farm; +import com.zipcodewilmington.froilansfarm.classes.storage.FarmHouse; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class FarmTests { + + @Test + public void testFarm() { + FarmHouse farmHouse = new FarmHouse(); + Farm lilLake = new Farm(farmHouse); + assertNotNull(lilLake); + + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FarmerTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FarmerTest.java new file mode 100644 index 0000000..c3984be --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FarmerTest.java @@ -0,0 +1,71 @@ +package com.zipcodewilmington.froilansfarm.classesTests; + +import com.zipcodewilmington.froilansfarm.classes.food.CornStalk; +import com.zipcodewilmington.froilansfarm.classes.food.PotatoPlant; +import com.zipcodewilmington.froilansfarm.interfaces.Botanist; +import com.zipcodewilmington.froilansfarm.interfaces.Rider; +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.Farmer; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.*; + +public class FarmerTest { + + @Test + public void testFarmer() { + Farmer jean = new Farmer(); + assertNotNull(jean); + + } + + @Test + public void testFarmerExtends() { + Farmer luke = new Farmer(); + assertTrue(luke instanceof Botanist); + assertTrue(luke instanceof Rider); + + } + + @Test + public void testplant(){ + Farmer luis = new Farmer(); + TomatoPlant laura = new TomatoPlant(); + CropRow julius = new CropRow(); + assertEquals(true, luis.plant( laura,julius )); + + } + + @Test + public void testFarmerPlant(){ + Farmer farmer = new Farmer(); + TomatoPlant tomatoPlant = new TomatoPlant(); + CropRow cropRow = new CropRow<>(); + + Assert.assertTrue(farmer.plant(tomatoPlant, cropRow)); + } + + @Test + public void testFarmerPlantCorn(){ + Farmer farmer = new Farmer(); + CornStalk cornStalk = new CornStalk(); + CropRow cropRow = new CropRow<>(); + + Assert.assertTrue(farmer.plant(cornStalk, cropRow)); + } + + @Test + public void testFarmerPlantPotato(){ + Farmer farmer = new Farmer(); + PotatoPlant potatoPlant = new PotatoPlant(); + CropRow cropRow = new CropRow<>(); + + Assert.assertTrue(farmer.plant(potatoPlant, cropRow)); + } + + + + +} \ No newline at end of file diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FieldTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FieldTests.java new file mode 100644 index 0000000..087db7f --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FieldTests.java @@ -0,0 +1,26 @@ +package com.zipcodewilmington.froilansfarm.classesTests; + +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.Field; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class FieldTests { + + @Test + public void testField(){ + Field jardin = new Field(); + assertNotNull(jardin); + } + + @Test + public void testFieldAdd(){ + Field field = new Field(); + CropRow cropRow = new CropRow<>(); + + Assert.assertTrue(field.add(cropRow)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FroilanTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FroilanTests.java new file mode 100644 index 0000000..27f9c88 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FroilanTests.java @@ -0,0 +1,93 @@ +package com.zipcodewilmington.froilansfarm.classesTests; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.Froilan; +import com.zipcodewilmington.froilansfarm.classes.Froilanda; +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; +import com.zipcodewilmington.froilansfarm.classes.food.EdibleEgg; +import com.zipcodewilmington.froilansfarm.classes.food.Potato; +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.CornStorage; +import com.zipcodewilmington.froilansfarm.classes.storage.PotatoStorage; +import com.zipcodewilmington.froilansfarm.classes.storage.TomatoStorage; +import org.junit.Assert; +import org.junit.Test; + +public class FroilanTests { + + @Test + public void testFroilanConstructor(){ + Froilan froilan = new Froilan(); + Assert.assertNotNull(froilan); + } + + // we can't dismount a horse we're not even on + // so we have to check if the horse is being + // mounted first + + @Test + public void testFroilanMountTractor(){ + Froilan froilan = new Froilan(); + Tractor tractor = new Tractor(); + + Assert.assertTrue(froilan.mount(tractor)); + } + + @Test + public void testFroilanMountHorse(){ + Froilan froilan = new Froilan(); + Horse horse = new Horse(); + + Assert.assertTrue(froilan.mount(horse)); + } + + @Test + public void testFroilanDisountHorse(){ + Froilan froilan = new Froilan(); + Horse horse = new Horse(); + froilan.mount(horse); + + Assert.assertTrue(froilan.dismount(horse)); + } + @Test + public void TestIfFrolianEatEarCorn(){ + Froilan froilan = new Froilan(); + EarCorn earCorn = new EarCorn(); + CornStorage cornStorage = new CornStorage(); + cornStorage.add(earCorn); + Boolean eaten = froilan.eat(earCorn ,cornStorage); + Assert.assertTrue(eaten); + } + @Test + public void TestIfFrolianEatTomato(){ + Froilan froilan = new Froilan(); + Tomato tomato = new Tomato(); + TomatoStorage tomatoStorage = new TomatoStorage(); + tomatoStorage.add(tomato); + Boolean eaten = froilan.eat(tomato ,tomatoStorage); + Assert.assertTrue(eaten); + } + @Test + public void TestIfFrolianEatEdibleEgg(){ + Froilan froilan = new Froilan(); + EdibleEgg edibleEgg = new EdibleEgg(); + EdibleStorage edibleStorage = new EdibleStorage() { + }; + edibleStorage.add(edibleEgg); + Boolean eaten = froilan.eat(edibleEgg ,edibleStorage); + Assert.assertTrue(eaten); + } + @Test + public void TestIfFrolianEaPotato(){ + Froilan froilan = new Froilan(); + Potato potato = new Potato(); + PotatoStorage potatoStorage = new PotatoStorage() { + }; + potatoStorage.add(potato); + Boolean eaten = froilan.eat(potato ,potatoStorage); + Assert.assertTrue(eaten); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FroilandaTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FroilandaTest.java new file mode 100644 index 0000000..eb76b2e --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/FroilandaTest.java @@ -0,0 +1,68 @@ +package com.zipcodewilmington.froilansfarm.classesTests; + +import com.zipcodewilmington.froilansfarm.classes.Froilan; +import com.zipcodewilmington.froilansfarm.classes.Froilanda; +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.storage.TomatoStorage; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class FroilandaTest { + + @Test + + public void testFroilandaContructor(){ + Froilanda froilanda = new Froilanda(); + assertNotNull(froilanda); + } + + + @Test + public void testFroilandaMount (){ + Froilanda froilanda = new Froilanda(); + Horse horse = new Horse(); + assertTrue(froilanda.mount(horse)); + + } + + @Test + public void testFroilandaDismount(){ + Froilanda froilanda = new Froilanda(); + Horse horse = new Horse(); + froilanda.mount(horse); + assertTrue(froilanda.dismount(horse)); + } + + @Test + public void testCropDusterMounted(){ + Froilanda froilanda = new Froilanda(); + CropDuster cropDuster = new CropDuster(); + assertTrue(froilanda.mount(cropDuster)); + } + +@Test + public void testCropDusterDismounted(){ + Froilanda froilanda = new Froilanda(); + CropDuster cropDuster= new CropDuster(); + froilanda.mount(cropDuster); + assertTrue(froilanda.dismount(cropDuster)); +} + + + @Test + public void testifFroilandaEat(){ + + Froilanda froilanda = new Froilanda(); + TomatoStorage storageOfTomatoes = new TomatoStorage(); + Tomato tomato = new Tomato(); + storageOfTomatoes.add(tomato); + boolean eaten = froilanda.eat(tomato, storageOfTomatoes); + Assert.assertTrue(eaten); + } +} + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/ChickenTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/ChickenTests.java new file mode 100644 index 0000000..d69ca35 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/ChickenTests.java @@ -0,0 +1,56 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.Chicken; +import com.zipcodewilmington.froilansfarm.classes.food.EdibleEgg; +import com.zipcodewilmington.froilansfarm.classes.food.Potato; +import com.zipcodewilmington.froilansfarm.classes.storage.PotatoStorage; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ChickenTests { + Potato potato; + PotatoStorage potatoStorage; + EdibleEgg edibleEgg; + Chicken chicken; + @Before + public void setup(){ + chicken = new Chicken(); + edibleEgg = new EdibleEgg(); + potato = new Potato(); + potatoStorage = new PotatoStorage(); + } + + @Test + public void TestIsChicken(){ + Assert.assertNotNull(chicken); + } + // dose it lay an egg +@Test + public void TestYield(){ + chicken.setHasBeenFertilized(true); + EdibleEgg notEdibleEgg = chicken.yield(); + Assert.assertNull(notEdibleEgg); +} + @Test + public void TestYieldNot(){ + chicken.setHasBeenFertilized(false); + EdibleEgg edibleEgg1 = chicken.yield(); + Assert.assertNotNull(edibleEgg1); + } + + + // dose it make noise + @Test + public void TestWhatSoundchickenMake(){ + String expected= "chrip"; + String actual = chicken.makeNoise(); + } + // dose it eat potato + @Test + public void TestIfChickenEatPotato(){ + potatoStorage.add(potato); + boolean eaten = chicken.eat( potato,potatoStorage ); + Assert.assertTrue(eaten); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/CornStalkTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/CornStalkTests.java new file mode 100644 index 0000000..0908c5f --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/CornStalkTests.java @@ -0,0 +1,57 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.CornStalk; +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class CornStalkTests { + + // all plants check if fertilized make plant + + EarCorn earCorn; + CornStalk cornStalk; + @Before + public void setup(){ + earCorn = new EarCorn(); + cornStalk = new CornStalk(); + + } + @Test + public void testCornStalkPlant(){ + Assert.assertNotNull(cornStalk); + } + + @Test + public void testCornPlantYieldCrops1(){ + cornStalk.setHasBeenFertilized(true); + cornStalk.setHasBeenHarvested(true); + EdibleCrops earCornYeild = cornStalk.yield(); + Assert.assertNotNull(earCornYeild); + } + @Test + public void testCornPlantYieldCrops2(){ + cornStalk.setHasBeenFertilized(false); + cornStalk.setHasBeenHarvested(true); + EdibleCrops earCornYeild = cornStalk.yield(); + Assert.assertNull(earCornYeild); + } + @Test + public void testCornPlantYieldCrops3(){ + cornStalk.setHasBeenFertilized(true); + cornStalk.setHasBeenHarvested(false); + EdibleCrops earCornYeild = cornStalk.yield(); + Assert.assertNull(earCornYeild); + } + @Test + public void testCornStalkPlantYieldCrops4(){ + cornStalk.setHasBeenFertilized(false); + cornStalk.setHasBeenHarvested(false); + EdibleCrops earCornYeild = cornStalk.yield(); + Assert.assertNull(earCornYeild); + } + + // test that it only produce one type (corn ear) +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/EarCornTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/EarCornTests.java new file mode 100644 index 0000000..740dc09 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/EarCornTests.java @@ -0,0 +1,36 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + + +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; +import com.zipcodewilmington.froilansfarm.classes.food.Potato; +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class EarCornTests { + EarCorn earCorn; + + @Before + public void setup() { + earCorn = new EarCorn(); + } + + @Test + public void testPotato() { + earCorn = new EarCorn(); + + Assert.assertNotNull(earCorn); + } + + // test it method + + @Test + public void TestisEdible() { // test if edible + // test if it can be eaten + // call on tomato to see if the tomato is edible + + + Assert.assertTrue(earCorn instanceof EdibleCrops); + } +} \ No newline at end of file diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/EdibleEggTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/EdibleEggTests.java new file mode 100644 index 0000000..199f3be --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/EdibleEggTests.java @@ -0,0 +1,29 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.EdibleEgg; +import com.zipcodewilmington.froilansfarm.interfaces.Edible; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class EdibleEggTests { + EdibleEgg edibleEgg; + @Before + public void setup(){ + edibleEgg = new EdibleEgg(); + + } + + @Test + public void TestEdibleEgg(){ + Assert.assertNotNull(edibleEgg); + } + // test if edible + @Test + public void TestisEdible(){ + + Assert.assertTrue(edibleEgg instanceof Edible); + } + + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/PotatoPlantTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/PotatoPlantTests.java new file mode 100644 index 0000000..8ac9d35 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/PotatoPlantTests.java @@ -0,0 +1,54 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.Potato; +import com.zipcodewilmington.froilansfarm.classes.food.PotatoPlant; +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class PotatoPlantTests { + // all plants check if fertilized make plant + Potato potato; + PotatoPlant potatoPlant; + @Before + public void setup(){ + potato = new Potato(); + potatoPlant = new PotatoPlant(); + + } + @Test + public void testPotatoPlant(){ + Assert.assertNotNull(potatoPlant); + } + + @Test + public void testPotatoPlantYieldCrops1(){ + potatoPlant.setHasBeenHarvested(true); + potatoPlant.setHasBeenFertilized(true); + EdibleCrops potatoYield = potatoPlant.yield(); + Assert.assertNotNull(potatoYield); + } + @Test + public void testPotatoPlantYieldCrops2(){ + potatoPlant.setHasBeenHarvested(true); + potatoPlant.setHasBeenFertilized(false); + EdibleCrops potatoYield = potatoPlant.yield(); + Assert.assertNull(potatoYield); + } + @Test + public void testPotatoPlantYieldCrops3(){ + potatoPlant.setHasBeenHarvested(false); + potatoPlant.setHasBeenFertilized(true); + EdibleCrops potatoYield = potatoPlant.yield(); + Assert.assertNull(potatoYield); + } + @Test + public void testTomatoPlantYieldCrops4(){ + potatoPlant.setHasBeenHarvested(false); + potatoPlant.setHasBeenFertilized(false); + EdibleCrops potatoYield = potatoPlant.yield(); + Assert.assertNull(potatoYield); + } + // test that it only produce one type (potato) +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/PotatoTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/PotatoTests.java new file mode 100644 index 0000000..9d58eb7 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/PotatoTests.java @@ -0,0 +1,31 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.Potato; + +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import org.junit.Assert; +import org.junit.Test; + +public class PotatoTests { + @Test + public void testPotato(){ + Potato potato = new Potato(); + + Assert.assertNotNull(potato); + } + + // test it method + + @Test + public void TestisPotatoEdible(){ // test if edible + // test if it can be eaten + // call on tomato to see if the tomato is edible + Potato potato = new Potato(); + + Assert.assertTrue(potato instanceof EdibleCrops); + } + + + +} + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/TomatoPlantTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/TomatoPlantTests.java new file mode 100644 index 0000000..185fc56 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/TomatoPlantTests.java @@ -0,0 +1,55 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TomatoPlantTests { + // all plants check if fertilized make plant + + Tomato tomato; + TomatoPlant tomatoPlant; + @Before + public void setup(){ + tomato = new Tomato(); + tomatoPlant =new TomatoPlant(); + + } +@Test + public void testTomatoPlant(){ + Assert.assertNotNull(tomatoPlant); +} + +@Test + public void testTomatoPlantYieldCrops1(){ + tomatoPlant.setHasBeenHarvested(true); + tomatoPlant.setHasBeenFertilized(true); + EdibleCrops tomatoYield = tomatoPlant.yield(); + Assert.assertNotNull(tomatoYield); +} + @Test + public void testTomatoPlantYieldCrops2(){ + tomatoPlant.setHasBeenFertilized(false); + tomatoPlant.setHasBeenHarvested(true); + EdibleCrops tomatoYield = tomatoPlant.yield(); + Assert.assertNull(tomatoYield); + } + @Test + public void testTomatoPlantYieldCrops3(){ + tomatoPlant.setHasBeenFertilized(true); + tomatoPlant.setHasBeenHarvested(false); + EdibleCrops tomatoYield = tomatoPlant.yield(); + Assert.assertNull(tomatoYield); + } + @Test + public void testTomatoPlantYieldCrops4(){ + tomatoPlant.setHasBeenFertilized(false); + tomatoPlant.setHasBeenHarvested(false); + EdibleCrops tomatoYield = tomatoPlant.yield(); + Assert.assertNull(tomatoYield); + } + // test that it only produce one type (tomato) +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/TomatoTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/TomatoTests.java new file mode 100644 index 0000000..e7f4a7b --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/food/TomatoTests.java @@ -0,0 +1,31 @@ +package com.zipcodewilmington.froilansfarm.classesTests.food; + +import com.zipcodewilmington.froilansfarm.classes.food.Potato; +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; +import com.zipcodewilmington.froilansfarm.interfaces.Edible; +import com.zipcodewilmington.froilansfarm.interfaces.EdibleCrops; +import org.junit.Assert; +import org.junit.Test; + +public class TomatoTests { + // constructor + @Test + public void testTomato(){ + Tomato tomato = new Tomato(); + + Assert.assertNotNull(tomato); + } + + + // test it method + + @Test + public void TestisTomatoEdible(){ // test if edible + // test if it can be eaten + // call on tomato to see if the tomato is edible + Tomato tomato = new Tomato(); + + Assert.assertTrue(tomato instanceof EdibleCrops); + } + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/CropDusterTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/CropDusterTests.java new file mode 100644 index 0000000..57b2b72 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/CropDusterTests.java @@ -0,0 +1,66 @@ +package com.zipcodewilmington.froilansfarm.classesTests.rideables; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Aircraft; +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.Farm; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.storage.FarmHouse; +import com.zipcodewilmington.froilansfarm.interfaces.FarmVehicle; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class CropDusterTests { + + + @Test + public void testCropDuster() { + CropDuster john = new CropDuster(); + assertNotNull(john); + } + + @Test + public void testCropDustExtends() { + CropDuster Amy = new CropDuster(); + assertTrue(Amy instanceof FarmVehicle); + + assertTrue(Amy instanceof Aircraft); + } + + @Test + public void testoperator() { + FarmHouse farmHouse = new FarmHouse(); + Farm farm = new Farm(farmHouse); + CropDuster lily = new CropDuster(); + Assert.assertTrue(lily.operator(farm)); + } + + @Test + public void testmakeNoise() { + boolean james = true; + CropDuster James = new CropDuster(); + assertTrue(james); + } + + @Test + public void testCropDusterConstructor() { + CropDuster cropDuster = new CropDuster(); + assertNotNull(cropDuster); + } + + @Test + public void testCropDusterFertilize(){ + CropDuster cropDuster = new CropDuster(); + CropRow tomatoRow = new CropRow<>(); + tomatoRow.add(new TomatoPlant()); + tomatoRow.add(new TomatoPlant()); + tomatoRow.add(new TomatoPlant()); + + cropDuster.fertilize(tomatoRow); + + Assert.assertTrue(tomatoRow.get(0).hasBeenFertilized); + } + +} \ No newline at end of file diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/HorseTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/HorseTests.java new file mode 100644 index 0000000..f353052 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/HorseTests.java @@ -0,0 +1,46 @@ +package com.zipcodewilmington.froilansfarm.classesTests.rideables; + +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.storage.CornStorage; +import com.zipcodewilmington.froilansfarm.interfaces.Eater; +import com.zipcodewilmington.froilansfarm.interfaces.Rideable; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class HorseTests { + + @Test + public void testHorse(){ + Horse Emily = new Horse(); + assertNotNull(Emily); + } + + + @Test + public void testHorseExtends(){ + Horse Tin = new Horse(); + assertTrue( Tin instanceof Rideable); + } + + @Test + public void testAnimal(){ + boolean juju = true; + Assert.assertTrue(juju); + } + @Test + public void TestIfHorseEatEarCorn(){ + Horse horse = new Horse(); + EarCorn earCorn = new EarCorn(); + CornStorage cornStorage = new CornStorage(); + cornStorage.add(earCorn); + Boolean eaten = horse.eat(earCorn ,cornStorage); + Assert.assertTrue(eaten); + } + + + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/TractorTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/TractorTests.java new file mode 100644 index 0000000..84fb759 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/rideables/TractorTests.java @@ -0,0 +1,92 @@ +package com.zipcodewilmington.froilansfarm.classesTests.rideables; + +import com.zipcodewilmington.froilansfarm.classes.CropRow; +import com.zipcodewilmington.froilansfarm.classes.Farm; +import com.zipcodewilmington.froilansfarm.classes.Froilan; +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; +import com.zipcodewilmington.froilansfarm.classes.food.TomatoPlant; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.FarmHouse; +import com.zipcodewilmington.froilansfarm.classes.storage.TomatoStorage; +import com.zipcodewilmington.froilansfarm.interfaces.Vehicle; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class TractorTests { + Froilan froilan; + Tractor tractor; + CropRow cropRow; + TomatoPlant tomatoPlant; + TomatoStorage storage; +@Before +public void setup(){ + tractor = new Tractor(); + froilan = new Froilan(); + cropRow = new CropRow(); + tomatoPlant = new TomatoPlant(); + storage = new TomatoStorage(); +} + @Test + public void testTractor(){ + Tractor cropRowTractor = new Tractor(); + assertNotNull(cropRowTractor); + + } + + @Test + public void testFarmVehicleExtends (){ + Tractor gardenTractors = new Tractor(); + assertTrue(gardenTractors instanceof Vehicle); + + } + + @Test + public void testoperator(){ + FarmHouse farmHouse = new FarmHouse(); + Farm farm = new Farm(farmHouse); + Tractor kubato = new Tractor(); + assertTrue(kubato.operator(farm)); + + } + @Test + public void TestIfMountTractorAble(){ + Assert.assertTrue(froilan.mount(tractor)); + } + + @Test + public void TestIfDisMountTractor(){ + froilan.mount(tractor); + Assert.assertTrue(froilan.dismount(tractor)); + } + + @Test + public void TestTractorSound(){ + String actual = tractor.makeNoise(); + String expected = "RrrooMMMMM"; + Assert.assertSame(actual,expected); + } + + @Test + public void TestIfCropHasBeenHarvested(){ + TomatoPlant tomatoPlant2 = new TomatoPlant(); + TomatoPlant tomatoPlant3 = new TomatoPlant(); + tomatoPlant.setHasBeenFertilized(true); + tomatoPlant2.setHasBeenFertilized(true); + tomatoPlant3.setHasBeenFertilized(true); + // if cropRow have fruit count fruit per crop in row.array list + cropRow.add(tomatoPlant); + cropRow.add(tomatoPlant2); + cropRow.add(tomatoPlant3); + + int actual = tractor.harvestCrop(cropRow, storage); + int expected = 3; + Assert.assertEquals(expected,actual); + Assert.assertEquals(3, storage.size()); + + } +} + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/ChickenCoopTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/ChickenCoopTests.java new file mode 100644 index 0000000..6f92b5c --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/ChickenCoopTests.java @@ -0,0 +1,61 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Housing; +import com.zipcodewilmington.froilansfarm.classes.food.Chicken; +import com.zipcodewilmington.froilansfarm.classes.storage.ChickenCoop; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class ChickenCoopTests { + @Test + public void testChickenCoopConstructor(){ + ChickenCoop coop = new ChickenCoop(); + Assert.assertNotNull(coop); + } + + @Test + public void testChickenCoopExtendsHousingAndArrayList(){ + ChickenCoop coop = new ChickenCoop(); + + Assert.assertTrue(ArrayList.class.isAssignableFrom(coop.getClass())); + Assert.assertTrue(coop instanceof Housing); + } + + @Test + public void testChickenCoopAdd(){ + ChickenCoop coop = new ChickenCoop(); + Chicken chimkin = new Chicken(); + + Assert.assertTrue(coop.add(chimkin)); + } + + @Test + public void testChickenCoopRemove(){ + ChickenCoop coop = new ChickenCoop(); + Chicken chimkin = new Chicken(); + coop.add(chimkin); + + Assert.assertTrue(coop.remove(chimkin)); + } + + @Test + public void testChickenCoopSize(){ + ChickenCoop coop = new ChickenCoop(); + Chicken chimkin = new Chicken(); + coop.add(chimkin); + + Assert.assertEquals(1, coop.size()); + } + + @Test + public void testChickenCoopGet(){ + ChickenCoop coop = new ChickenCoop(); + Chicken chimkin = new Chicken(); + coop.add(chimkin); + + Assert.assertEquals(chimkin, coop.get(0)); + } + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/CornStorageTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/CornStorageTests.java new file mode 100644 index 0000000..833f099 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/CornStorageTests.java @@ -0,0 +1,61 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.EarCorn; +import com.zipcodewilmington.froilansfarm.classes.storage.CornStorage; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class CornStorageTests { + + @Test + public void testCornStorageConstructor(){ + CornStorage corns = new CornStorage(); + Assert.assertNotNull(corns); + } + + @Test + public void testCornStorageExtendsEdibleStorageAndArray(){ + CornStorage corns = new CornStorage(); + + Assert.assertTrue(ArrayList.class.isAssignableFrom(corns.getClass())); + Assert.assertTrue(corns instanceof EdibleStorage); + } + + @Test + public void testCornStorageAdd(){ + CornStorage corns = new CornStorage(); + EarCorn corn = new EarCorn(); + + Assert.assertTrue(corns.add(corn)); + } + + @Test + public void testCornStorageRemove(){ + CornStorage corns = new CornStorage(); + EarCorn corn = new EarCorn(); + corns.add(corn); + + Assert.assertTrue(corns.remove(corn)); + } + + @Test + public void testCornStorageSize(){ + CornStorage corns = new CornStorage(); + EarCorn corn = new EarCorn(); + corns.add(corn); + + Assert.assertEquals(1, corns.size()); + } + + @Test + public void testCornStorageGet(){ + CornStorage corns = new CornStorage(); + EarCorn corn = new EarCorn(); + corns.add(corn); + + Assert.assertEquals(corn, corns.get(0)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/EggStorageTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/EggStorageTests.java new file mode 100644 index 0000000..4de959b --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/EggStorageTests.java @@ -0,0 +1,62 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.EdibleEgg; +import com.zipcodewilmington.froilansfarm.classes.storage.EggStorage; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class EggStorageTests { + + @Test + public void testEggStorageConstructor(){ + EggStorage eggs = new EggStorage(); + Assert.assertNotNull(eggs); + } + + @Test + public void testEggStorageExtendsEdibleStorageAndArrayList(){ + EggStorage eggs = new EggStorage(); + + Assert.assertTrue(ArrayList.class.isAssignableFrom(eggs.getClass())); + Assert.assertTrue(eggs instanceof EdibleStorage); + } + + @Test + public void testEggStorageAdd(){ + EggStorage eggs = new EggStorage(); + EdibleEgg egg = new EdibleEgg(); + + Assert.assertTrue(eggs.add(egg)); + } + + @Test + public void testEggStorageRemove(){ + EggStorage eggs = new EggStorage(); + EdibleEgg egg = new EdibleEgg(); + eggs.add(egg); + + Assert.assertTrue(eggs.remove(egg)); + } + + @Test + public void testEggStorageSize(){ + EggStorage eggs = new EggStorage(); + EdibleEgg egg = new EdibleEgg(); + eggs.add(egg); + + Assert.assertEquals(1, eggs.size()); + } + + @Test + public void testEggStorageGet(){ + EggStorage eggs = new EggStorage(); + EdibleEgg egg = new EdibleEgg(); + eggs.add(egg); + + Assert.assertEquals(egg, eggs.get(0)); + } +} + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/FarmHouseTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/FarmHouseTests.java new file mode 100644 index 0000000..5c7b0d2 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/FarmHouseTests.java @@ -0,0 +1,23 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Housing; +import com.zipcodewilmington.froilansfarm.classes.storage.FarmHouse; +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +public class FarmHouseTests { + + @Test + public void testFarmHouseConstructor(){ + FarmHouse house = new FarmHouse(); + + Assert.assertNotNull(house); + } + + @Test + public void testFarmHouseExtendsHousing(){ + FarmHouse house = new FarmHouse(); + + Assert.assertTrue(house instanceof Housing); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/PotatoStorageTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/PotatoStorageTests.java new file mode 100644 index 0000000..13fa5e5 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/PotatoStorageTests.java @@ -0,0 +1,61 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.Potato; +import com.zipcodewilmington.froilansfarm.classes.storage.PotatoStorage; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class PotatoStorageTests { + + @Test + public void testPotatoStorageConstructor(){ + PotatoStorage potatoes = new PotatoStorage(); + Assert.assertNotNull(potatoes); + } + + @Test + public void testPotatoStorageExtendsEdibleStorageAndArrayList(){ + PotatoStorage potatoes = new PotatoStorage(); + + Assert.assertTrue(ArrayList.class.isAssignableFrom(potatoes.getClass())); + Assert.assertTrue(potatoes instanceof EdibleStorage); + } + + @Test + public void testPotatoStorageAdd(){ + PotatoStorage potatoes = new PotatoStorage(); + Potato potato = new Potato(); + + Assert.assertTrue(potatoes.add(potato)); + } + + @Test + public void testPotatoStorageRemove(){ + PotatoStorage potatoes = new PotatoStorage(); + Potato potato = new Potato(); + potatoes.add(potato); + + Assert.assertTrue(potatoes.remove(potato)); + } + + @Test + public void testPotatoStorageSize(){ + PotatoStorage potatoes = new PotatoStorage(); + Potato potato = new Potato(); + potatoes.add(potato); + + Assert.assertEquals(1, potatoes.size()); + } + + @Test + public void testPotatoStorageGet(){ + PotatoStorage potatoes = new PotatoStorage(); + Potato potato = new Potato(); + potatoes.add(potato); + + Assert.assertEquals(potato, potatoes.get(0)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/StableTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/StableTests.java new file mode 100644 index 0000000..75f5b31 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/StableTests.java @@ -0,0 +1,60 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Housing; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.storage.Stable; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class StableTests { + @Test + public void testStableConstructor(){ + Stable stable = new Stable(); + Assert.assertNotNull(stable); + } + + @Test + public void testStableExtendsEdibleStorageAndArrayList(){ + Stable stable = new Stable(); + + Assert.assertTrue(ArrayList.class.isAssignableFrom(stable.getClass())); + Assert.assertTrue(stable instanceof Housing); + } + + @Test + public void testStableAdd(){ + Stable stable = new Stable(); + Horse horse = new Horse(); + + Assert.assertTrue(stable.add(horse)); + } + + @Test + public void testStableRemove(){ + Stable stable = new Stable(); + Horse horse = new Horse(); + stable.add(horse); + + Assert.assertTrue(stable.remove(horse)); + } + + @Test + public void testStableSize(){ + Stable stable = new Stable(); + Horse horse = new Horse(); + stable.add(horse); + + Assert.assertEquals(1, stable.size()); + } + + @Test + public void testStableGet(){ + Stable stable = new Stable(); + Horse horse = new Horse(); + stable.add(horse); + + Assert.assertEquals(horse, stable.get(0)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/TomatoStorageTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/TomatoStorageTests.java new file mode 100644 index 0000000..560f28e --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/classesTests/storage/TomatoStorageTests.java @@ -0,0 +1,60 @@ +package com.zipcodewilmington.froilansfarm.classesTests.storage; + +import com.zipcodewilmington.froilansfarm.abstractClasses.EdibleStorage; +import com.zipcodewilmington.froilansfarm.classes.food.Tomato; +import com.zipcodewilmington.froilansfarm.classes.storage.TomatoStorage; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +public class TomatoStorageTests { + @Test + public void testTomatoStorageConstructor(){ + TomatoStorage tomatoes = new TomatoStorage(); + Assert.assertNotNull(tomatoes); + } + + @Test + public void testTomatoStorageExtendsEdibleStorageAndArrayList(){ + TomatoStorage tomatoes = new TomatoStorage(); + + Assert.assertTrue(ArrayList.class.isAssignableFrom(tomatoes.getClass())); + Assert.assertTrue(tomatoes instanceof EdibleStorage); + } + + @Test + public void testTomatoStorageAdd(){ + TomatoStorage tomatoes = new TomatoStorage(); + Tomato tomato = new Tomato(); + + Assert.assertTrue(tomatoes.add(tomato)); + } + + @Test + public void testTomatoStorageRemove(){ + TomatoStorage tomatoes = new TomatoStorage(); + Tomato tomato = new Tomato(); + tomatoes.add(tomato); + + Assert.assertTrue(tomatoes.remove(tomato)); + } + + @Test + public void testTomatoStorageSize(){ + TomatoStorage tomatoes = new TomatoStorage(); + Tomato tomato = new Tomato(); + tomatoes.add(tomato); + + Assert.assertEquals(1, tomatoes.size()); + } + + @Test + public void testTomatoStorageGet(){ + TomatoStorage tomatoes = new TomatoStorage(); + Tomato tomato = new Tomato(); + tomatoes.add(tomato); + + Assert.assertEquals(tomato, tomatoes.get(0)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/FridayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/FridayTests.java new file mode 100644 index 0000000..a29769d --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/FridayTests.java @@ -0,0 +1,278 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import com.zipcodewilmington.froilansfarm.classesTests.FieldTests; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class FridayTests { + static Field fieldTest; + static CropRow cropRow; + static CropRow cropRow2; + static CropRow cropRow3; + static CropRow cropRow4; + static CropRow cropRow5; + + static ChickenCoop coop; + static ChickenCoop coop2; + static ChickenCoop coop3; + static ChickenCoop coop4; + static Stable stable; + static Stable stable2; + static Stable stable3; + static Tractor tractor; + static CropDuster cropDuster; + static Froilan froilan; + static Froilanda froilanda; + static FarmHouse farmHouse; + + static Farm farm; + static TomatoStorage tomatoStorage; + static PotatoStorage potatoStorage; + static CornStorage cornStorage; + static EggStorage eggStorage; + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + froilanda = new Froilanda(); + cropDuster =new CropDuster(); + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up the frois + froilan = new Froilan(); + froilanda = new Froilanda(); + + // setting up farmhouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + + // setting up storages + tomatoStorage = new TomatoStorage(); + for(int i = 0; i < 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i = 0; i < 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i = 0; i < 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + // setting up farm + farm = new Farm(farmHouse); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + } + + @Test + public void test(){ + Assert.assertEquals(5,fieldTest.size()); + } + @Test + public void testFly(){ + Assert.assertTrue(cropDuster.fly()); + } + + @Test + public void testOperator(){ + Assert.assertTrue(cropDuster.operator(farm)); + } + @Test + public void testFroilandaMountingCropDuster(){ + Assert.assertTrue( froilanda.mount(cropDuster)); + + } + @Test + public void testFroilandaDismountingCropDuster(){ + froilanda.mount(cropDuster); + Assert.assertTrue(froilanda.dismount(cropDuster)); + } + @Test + public void testifCropDustmakeNoise(){ + String actual = cropDuster.makeNoise(); + String expected = "Whir~~~~!"; + Assert.assertEquals(actual,expected); + } + @Test + public void testIfCropRowHasNotBeenFertilized(){ + + for ( Crop crop: cropRow){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRowHasBeenFertilized(){ + cropDuster.fertilize(cropRow); + for ( Crop crop: cropRow){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow2HasNotBeenFertilized(){ + + for ( Crop crop: cropRow2){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRow2HasBeenFertilized(){ + cropDuster.fertilize(cropRow2); + for ( Crop crop: cropRow2){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow3HasNotBeenFertilized(){ + + for ( Crop crop: cropRow){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow3HasBeenFertilized(){ + cropDuster.fertilize(cropRow3); + for ( Crop crop: cropRow3){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow4HasNotBeenFertilized(){ + + for ( Crop crop: cropRow){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow4HasBeenFertilized(){ + cropDuster.fertilize(cropRow4); + for ( Crop crop: cropRow4){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRow5HasNotBeenFertilized(){ + + for ( Crop crop: cropRow5){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRow5HasBeenFertilized(){ + cropDuster.fertilize(cropRow5); + for ( Crop crop: cropRow5){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + +//his sister, Froilanda +// uses the CropDuster to fly over the Field and +// fertilizeeach of the CropRow +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/MondayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/MondayTests.java new file mode 100644 index 0000000..0b5338c --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/MondayTests.java @@ -0,0 +1,275 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + + + public class MondayTests { + Field fieldTest; + CropRow cropRow; + CropRow cropRow2; + CropRow cropRow3; + CropRow cropRow4; + CropRow cropRow5; + + ChickenCoop coop; + ChickenCoop coop2; + ChickenCoop coop3; + ChickenCoop coop4; + Stable stable; + Stable stable2; + Stable stable3; + Tractor tractor; + CropDuster cropDuster; + Froilan froilan; + Froilanda froilanda; + FarmHouse farmHouse; + + Farm farm; + TomatoStorage tomatoStorage; + PotatoStorage potatoStorage; + CornStorage cornStorage; + EggStorage eggStorage; + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + froilanda = new Froilanda(); + cropDuster =new CropDuster(); + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up the frois + froilan = new Froilan(); + froilanda = new Froilanda(); + + // setting up farmhouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + + // setting up storages + tomatoStorage = new TomatoStorage(); + for(int i = 0; i < 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i = 0; i < 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i = 0; i < 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + // setting up farm + farm = new Farm(farmHouse); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + } + + @Test + public void test(){ + Assert.assertEquals(5,fieldTest.size()); + } + @Test + public void testFly(){ + Assert.assertTrue(cropDuster.fly()); + } + @Test + public void testFroilandaMountingCropDuster(){ + Assert.assertTrue( froilanda.mount(cropDuster)); + + } + @Test + public void testFroilandaDismountingCropDuster(){ + froilanda.mount(cropDuster); + Assert.assertTrue(froilanda.dismount(cropDuster)); + } + @Test + public void testifCropDustmakeNoise(){ + String actual = cropDuster.makeNoise(); + String expected = "Whir~~~~!"; + Assert.assertEquals(actual,expected); + } + @Test + public void testIfCropRowHasNotBeenFertilized(){ + + for ( Crop crop: cropRow){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRowHasBeenFertilized(){ + cropDuster.fertilize(cropRow); + for ( Crop crop: cropRow){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow2HasNotBeenFertilized(){ + + for ( Crop crop: cropRow2){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRow2HasBeenFertilized(){ + cropDuster.fertilize(cropRow2); + for ( Crop crop: cropRow2){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow3HasNotBeenFertilized(){ + + for ( Crop crop: cropRow){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow3HasBeenFertilized(){ + cropDuster.fertilize(cropRow3); + for ( Crop crop: cropRow3){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow4HasNotBeenFertilized(){ + + for ( Crop crop: cropRow){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + + @Test + public void testIfCropRow4HasBeenFertilized(){ + cropDuster.fertilize(cropRow4); + for ( Crop crop: cropRow4){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRow5HasNotBeenFertilized(){ + + for ( Crop crop: cropRow5){ + Assert.assertFalse(crop.hasBeenFertilized); + } + } + @Test + public void testIfCropRow5HasBeenFertilized(){ + cropDuster.fertilize(cropRow5); + for ( Crop crop: cropRow5){ + Assert.assertTrue(crop.hasBeenFertilized); + } + } + + + } + + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/SaturdayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/SaturdayTests.java new file mode 100644 index 0000000..123176e --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/SaturdayTests.java @@ -0,0 +1,286 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class SaturdayTests { + static Field fieldTest; + static CropRow cropRow; + static CropRow cropRow2; + static CropRow cropRow3; + static CropRow cropRow4; + static CropRow cropRow5; + + static ChickenCoop coop; + static ChickenCoop coop2; + static ChickenCoop coop3; + static ChickenCoop coop4; + static Stable stable; + static Stable stable2; + static Stable stable3; + static Tractor tractor; + static CropDuster cropDuster; + static Froilan froilan; + static Froilanda froilanda; + static FarmHouse farmHouse; + + static Farm farm; + static TomatoStorage tomatoStorage; + static PotatoStorage potatoStorage; + static CornStorage cornStorage; + static EggStorage eggStorage; + + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up the frois + froilan = new Froilan(); + froilanda = new Froilanda(); + + // setting up farmhouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + // setting up storages + tomatoStorage = new TomatoStorage(); + for(int i = 0; i < 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i = 0; i < 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i = 0; i < 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + // setting up farm + farm = new Farm(farmHouse); + + farm.setField(fieldTest); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + } + + @Test + public void test(){ + Assert.assertEquals(4, farm.getCoops().get(0).size()); + Assert.assertEquals(20, tomatoStorage.size()); + } + + @Test + public void testFroilanRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilan.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilan.dismount(h)); + } + } + } + + @Test + public void testFroilandaRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilanda.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilanda.dismount(h)); + } + } + } + + @Test + public void testFeedHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(h.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(1), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(2), farm.getCornStorage())); + } + } + } + + @Test + public void testFroilanBreakfast(){ + // froilan eats 1 corn + Assert.assertTrue(froilan.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 2 tomatoes + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(1), farm.getTomatoStorage())); + // 5 eggs + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(2), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(3), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(4), farm.getEggStorage())); + + } + + @Test + public void testFroilandaBreakfast(){ + // froilanda eats 2 corn + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 1 tomato + Assert.assertTrue(froilanda.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + // 2 eggs + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + } + + @Test + public void testFroilanAndFroilandaMakeNoise(){ + Assert.assertEquals("What a great Day", froilan.makeNoise()); + Assert.assertEquals("What a great Day", froilanda.makeNoise()); + } + + @Test + public void testFroilanCannotDismount(){ + Assert.assertFalse(froilan.dismount(tractor)); + } + + @Test + public void testFroilanCannotMountAgain(){ + froilan.mount(tractor); + Assert.assertFalse(froilan.mount(tractor)); + } + + @Test + public void testFroilanRideTractor(){ + Assert.assertTrue(froilan.mount(tractor)); + Assert.assertTrue(froilan.dismount(tractor)); + } + + @Test + public void testTractorMakeNoise(){ + Assert.assertEquals("RrrooMMMMM", tractor.makeNoise()); + } + @Test + public void testTractorHarvestFail(){ + + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(0), cornStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(1), tomatoStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(2), potatoStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(3), tomatoStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(4), cornStorage)); + + } + + @Test + public void testTractorHarvestPass(){ + cropDuster.fertilize(farm.getField().get(0)); + cropDuster.fertilize(farm.getField().get(1)); + cropDuster.fertilize(farm.getField().get(2)); + cropDuster.fertilize(farm.getField().get(3)); + cropDuster.fertilize(farm.getField().get(4)); + + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(0), cornStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(1), tomatoStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(2), potatoStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(3), tomatoStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(4), cornStorage)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/SundayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/SundayTests.java new file mode 100644 index 0000000..3ad0866 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/SundayTests.java @@ -0,0 +1,257 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + + +public class SundayTests { + static Field fieldTest; + static CropRow cropRow; + static CropRow cropRow2; + static CropRow cropRow3; + static CropRow cropRow4; + static CropRow cropRow5; + + static ChickenCoop coop; + static ChickenCoop coop2; + static ChickenCoop coop3; + static ChickenCoop coop4; + static Stable stable; + static Stable stable2; + static Stable stable3; + static Tractor tractor; + static CropDuster cropDuster; + static Froilan froilan; + static Froilanda froilanda; + static FarmHouse farmHouse; + + static Farm farm; + static TomatoStorage tomatoStorage; + static PotatoStorage potatoStorage; + static CornStorage cornStorage; + static EggStorage eggStorage; + + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up the frois + froilan = new Froilan(); + froilanda = new Froilanda(); + + // setting up farmhouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + // setting up storages + tomatoStorage = new TomatoStorage(); + for(int i = 0; i < 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i = 0; i < 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i = 0; i < 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + // setting up farm + farm = new Farm(farmHouse); + + farm.setField(fieldTest); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + } + + @Test + public void test(){ + Assert.assertEquals(4, farm.getCoops().get(0).size()); + Assert.assertEquals(20, tomatoStorage.size()); + } + + @Test + public void testFroilanRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilan.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilan.dismount(h)); + } + } + } + + @Test + public void testFroilandaRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilanda.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilanda.dismount(h)); + } + } + } + + @Test + public void testFeedHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(h.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(1), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(2), farm.getCornStorage())); + } + } + } + + @Test + public void testFroilanBreakfast(){ + // froilan eats 1 corn + Assert.assertTrue(froilan.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 2 tomatoes + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(1), farm.getTomatoStorage())); + // 5 eggs + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(2), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(3), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(4), farm.getEggStorage())); + + } + + @Test + public void testFroilandaBreakfast(){ + // froilanda eats 2 corn + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 1 tomato + Assert.assertTrue(froilanda.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + // 2 eggs + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + } + + @Test + public void testFroilanAndFroilandaMakeNoise(){ + Assert.assertEquals("What a great Day", froilan.makeNoise()); + Assert.assertEquals("What a great Day", froilanda.makeNoise()); + } + + @Test + public void testFroilanPlant(){ + CornStalk cornStalk = new CornStalk(); + TomatoPlant tomatoPlant = new TomatoPlant(); + PotatoPlant potatoPlant = new PotatoPlant(); + Assert.assertTrue(froilan.plant(cornStalk, cropRow)); + Assert.assertTrue(froilan.plant(tomatoPlant, cropRow2)); + Assert.assertTrue(froilan.plant(potatoPlant, cropRow3)); + + Assert.assertEquals(21, farm.getField().get(0).size()); + Assert.assertEquals(21, farm.getField().get(1).size()); + Assert.assertEquals(21, farm.getField().get(2).size()); + Assert.assertEquals(20, farm.getField().get(3).size()); + Assert.assertEquals(20, farm.getField().get(4).size()); + } + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/ThursdayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/ThursdayTests.java new file mode 100644 index 0000000..3dd3944 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/ThursdayTests.java @@ -0,0 +1,211 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; + +import static com.zipcodewilmington.froilansfarm.weekTests.SundayTests.farmHouse; + + +public class ThursdayTests { + + + static Field fieldTest; + static CropRow cropRow; + static CropRow cropRow2; + static CropRow cropRow3; + static CropRow cropRow4; + static CropRow cropRow5; + + static ChickenCoop coop; + static ChickenCoop coop2; + static ChickenCoop coop3; + static ChickenCoop coop4; + static Stable stable; + static Stable stable2; + static Stable stable3; + static Tractor tractor; + static CropDuster cropDuster; + static Froilan froilan; + static Froilanda froilanda; + + static FarmHouse farmHouse; + static Farm farm; + + static TomatoStorage tomatoStorage; + static PotatoStorage potatoStorage; + static CornStorage cornStorage; + static EggStorage eggStorage; + + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + + cropRow = new CropRow<>(); + cropRow2 = new CropRow<>(); + cropRow3 = new CropRow<>(); + cropRow4 = new CropRow<>(); + + + cropRow5 = new CropRow<>(); + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up Froilan + da. + froilan = new Froilan(); + froilanda = new Froilanda(); + + // set farmHouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + //set farm + farm = new Farm (farmHouse); + + farm.setField(fieldTest); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + + tomatoStorage = new TomatoStorage(); + for(int i = 0; i< 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i= 0; i< 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i =0; i< 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + } + + @Test + public void test(){ + Assert.assertEquals(4,coop.size()); + } + + @Test + public void testFroilanRidesHorses(){ + for(Stable stable : farm.getStables()){ + for(Horse horse : stable){ + Assert.assertTrue(froilan.mount(horse)); + Assert.assertNotNull(horse.makeNoise()); + Assert.assertTrue(froilan.dismount(horse)); + } + } + } + + @Test + public void testFroilandaRidesHorses() { + for (Stable stable : farm.getStables()) { + for (Horse horse : stable) { + Assert.assertTrue(froilanda.mount(horse)); + Assert.assertNotNull(horse.makeNoise()); + Assert.assertTrue(froilanda.dismount(horse)); + } + } + } +} + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/TuesdayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/TuesdayTests.java new file mode 100644 index 0000000..5afca6d --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/TuesdayTests.java @@ -0,0 +1,292 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.abstractClasses.Crop; +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TuesdayTests { + static Field fieldTest; + static CropRow cropRow; + static CropRow cropRow2; + static CropRow cropRow3; + static CropRow cropRow4; + static CropRow cropRow5; + + static ChickenCoop coop; + static ChickenCoop coop2; + static ChickenCoop coop3; + static ChickenCoop coop4; + static Stable stable; + static Stable stable2; + static Stable stable3; + static Tractor tractor; + static CropDuster cropDuster; + static Froilan froilan; + static Froilanda froilanda; + static FarmHouse farmHouse; + + static Farm farm; + static TomatoStorage tomatoStorage; + static PotatoStorage potatoStorage; + static CornStorage cornStorage; + static EggStorage eggStorage; + + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up the frois + froilan = new Froilan(); + froilanda = new Froilanda(); + + // setting up farmhouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + // setting up storages + tomatoStorage = new TomatoStorage(); + for(int i = 0; i < 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i = 0; i < 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i = 0; i < 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + // setting up farm + farm = new Farm(farmHouse); + + farm.setField(fieldTest); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + } + + @Test + public void test(){ + Assert.assertEquals(4, farm.getCoops().get(0).size()); + Assert.assertEquals(20, tomatoStorage.size()); + } + + @Test + public void testFroilanRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilan.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilan.dismount(h)); + } + } + } + + @Test + public void testFroilandaRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilanda.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilanda.dismount(h)); + } + } + } + + @Test + public void testFeedHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(h.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(1), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(2), farm.getCornStorage())); + } + } + } + + @Test + public void testFroilanBreakfast(){ + // froilan eats 1 corn + Assert.assertTrue(froilan.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 2 tomatoes + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(1), farm.getTomatoStorage())); + // 5 eggs + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(2), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(3), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(4), farm.getEggStorage())); + + } + + @Test + public void testFroilandaBreakfast(){ + // froilanda eats 2 corn + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 1 tomato + Assert.assertTrue(froilanda.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + // 2 eggs + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + } + + @Test + public void testFroilanAndFroilandaMakeNoise(){ + Assert.assertEquals("What a great Day", froilan.makeNoise()); + Assert.assertEquals("What a great Day", froilanda.makeNoise()); + } + + @Test + public void testFroilanCannotDismount(){ + Assert.assertFalse(froilan.dismount(tractor)); + } + + @Test + public void testFroilanCannotMountAgain(){ + froilan.mount(tractor); + Assert.assertFalse(froilan.mount(tractor)); + } + + @Test + public void testFroilanRideTractor(){ + Assert.assertTrue(froilan.mount(tractor)); + Assert.assertTrue(froilan.dismount(tractor)); + } + + @Test + public void testTractorOperate(){ + Assert.assertTrue(tractor.operator(farm)); + } + + @Test + public void testTractorMakeNoise(){ + Assert.assertEquals("RrrooMMMMM", tractor.makeNoise()); + } + @Test + public void testTractorHarvestFail(){ + + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(0), cornStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(1), tomatoStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(2), potatoStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(3), tomatoStorage)); + Assert.assertEquals(0, tractor.harvestCrop(farm.getField().get(4), cornStorage)); + + } + + @Test + public void testTractorHarvestPass(){ + cropDuster.fertilize(farm.getField().get(0)); + cropDuster.fertilize(farm.getField().get(1)); + cropDuster.fertilize(farm.getField().get(2)); + cropDuster.fertilize(farm.getField().get(3)); + cropDuster.fertilize(farm.getField().get(4)); + + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(0), cornStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(1), tomatoStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(2), potatoStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(3), tomatoStorage)); + Assert.assertEquals(20, tractor.harvestCrop(farm.getField().get(4), cornStorage)); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/WednesdayTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/WednesdayTests.java new file mode 100644 index 0000000..ef3571f --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/weekTests/WednesdayTests.java @@ -0,0 +1,259 @@ +package com.zipcodewilmington.froilansfarm.weekTests; + +import com.zipcodewilmington.froilansfarm.classes.*; +import com.zipcodewilmington.froilansfarm.classes.food.*; +import com.zipcodewilmington.froilansfarm.classes.rideables.CropDuster; +import com.zipcodewilmington.froilansfarm.classes.rideables.Horse; +import com.zipcodewilmington.froilansfarm.classes.rideables.Tractor; +import com.zipcodewilmington.froilansfarm.classes.storage.*; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static com.zipcodewilmington.froilansfarm.weekTests.ThursdayTests.farm; + +public class WednesdayTests { static Field fieldTest; + static CropRow cropRow; + static CropRow cropRow2; + static CropRow cropRow3; + static CropRow cropRow4; + static CropRow cropRow5; + + static ChickenCoop coop; + static ChickenCoop coop2; + static ChickenCoop coop3; + static ChickenCoop coop4; + static Stable stable; + static Stable stable2; + static Stable stable3; + static Tractor tractor; + static CropDuster cropDuster; + static Froilan froilan; + static Froilanda froilanda; + static FarmHouse farmHouse; + + static Farm farm; + static TomatoStorage tomatoStorage; + static PotatoStorage potatoStorage; + static CornStorage cornStorage; + static EggStorage eggStorage; + + + @Before + public void setUp(){ + // setting up field + fieldTest = new Field(); + + cropRow = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow.add(new CornStalk()); + } + cropRow2 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow2.add(new TomatoPlant()); + } + cropRow3 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow3.add(new PotatoPlant()); + } + cropRow4 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow4.add(new TomatoPlant()); + } + cropRow5 = new CropRow<>(); + for(int i = 0; i < 20; i++){ + cropRow5.add(new CornStalk()); + } + + fieldTest.add(cropRow); + fieldTest.add(cropRow2); + fieldTest.add(cropRow3); + fieldTest.add(cropRow4); + fieldTest.add(cropRow5); + + // setting up chicken coops + coop = new ChickenCoop(); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + coop.add(new Chicken()); + + coop2 = new ChickenCoop(); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + coop2.add(new Chicken()); + + coop3 = new ChickenCoop(); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + coop3.add(new Chicken()); + + coop4 = new ChickenCoop(); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + coop4.add(new Chicken()); + + // setting up stables + stable = new Stable(); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + stable.add(new Horse()); + + stable2 = new Stable(); + stable2.add(new Horse()); + stable2.add(new Horse()); + + stable3 = new Stable(); + stable3.add(new Horse()); + stable3.add(new Horse()); + stable3.add(new Horse()); + + // setting up FarmVehicles + tractor = new Tractor(); + cropDuster = new CropDuster(); + + // setting up the frois + froilan = new Froilan(); + froilanda = new Froilanda(); + + // setting up farmhouse + farmHouse = new FarmHouse(); + farmHouse.add(froilan); + farmHouse.add(froilanda); + + // setting up storages + tomatoStorage = new TomatoStorage(); + for(int i = 0; i < 20; i++){ + tomatoStorage.add(new Tomato()); + } + potatoStorage = new PotatoStorage(); + for(int i = 0; i < 20; i++){ + potatoStorage.add(new Potato()); + } + cornStorage = new CornStorage(); + for(int i = 0; i < 40; i++){ + cornStorage.add(new EarCorn()); + } + eggStorage = new EggStorage(); + for(int i = 0; i < 20; i++){ + eggStorage.add(new EdibleEgg()); + } + + + // setting up farm + farm = new Farm(farmHouse); + + farm.setField(fieldTest); + + farm.addCoops(coop); + farm.addCoops(coop2); + farm.addCoops(coop3); + farm.addCoops(coop4); + + farm.addStables(stable); + farm.addStables(stable2); + farm.addStables(stable3); + + farm.setCornStorage(cornStorage); + farm.setEggStorage(eggStorage); + farm.setPotatoStorage(potatoStorage); + farm.setTomatoStorage(tomatoStorage); + + } + + @Test + public void test(){ + Assert.assertEquals(4, farm.getCoops().get(0).size()); + Assert.assertEquals(20, tomatoStorage.size()); + } + + @Test + public void testFroilanRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilan.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilan.dismount(h)); + } + } + } + + @Test + public void testFroilandaRidesHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(froilanda.mount(h)); + Assert.assertNotNull(h.makeNoise()); + Assert.assertTrue(froilanda.dismount(h)); + } + } + } + + @Test + public void testFeedHorses(){ + for(Stable s : farm.getStables()){ + for(Horse h : s){ + Assert.assertTrue(h.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(1), farm.getCornStorage())); + Assert.assertTrue(h.eat(farm.getCornStorage().get(2), farm.getCornStorage())); + } + } + } + + @Test + public void testFroilanBreakfast(){ + // froilan eats 1 corn + Assert.assertTrue(froilan.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 2 tomatoes + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + Assert.assertTrue(froilan.eat(farm.getTomatoStorage().get(1), farm.getTomatoStorage())); + // 5 eggs + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(2), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(3), farm.getEggStorage())); + Assert.assertTrue(froilan.eat(farm.getEggStorage().get(4), farm.getEggStorage())); + + } + + @Test + public void testFroilandaBreakfast(){ + // froilanda eats 2 corn + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + Assert.assertTrue(froilanda.eat(farm.getCornStorage().get(0), farm.getCornStorage())); + // 1 tomato + Assert.assertTrue(froilanda.eat(farm.getTomatoStorage().get(0), farm.getTomatoStorage())); + // 2 eggs + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(0), farm.getEggStorage())); + Assert.assertTrue(froilanda.eat(farm.getEggStorage().get(1), farm.getEggStorage())); + } + + + @Test + public void testFeedChickens(){ + for(ChickenCoop coop: farm.getCoops() ){ + for(Chicken c : coop ){ + Assert.assertTrue(c.eat(farm.getPotatoStorage().get(0), farm.getPotatoStorage())); + + } + } + } + + + @Test + public void testChickensMakeNoise(){ + Assert.assertEquals("chrip", coop.get(0).makeNoise()); + + } + + @Test + public void testChickenYield(){ + coop.get(0).setHasBeenFertilized(false); + Assert.assertNotNull(coop.get(0).yield()); + } + +}