diff --git a/README.md b/README.md index 433e7ef4..597aa6d7 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ * Consider a system in which * `Eater` can `eat` an `Edible` object. * `NoiseMaker` can `makeNoise` - * `Animal` is a `NoiseMaker` and `Eater` - * `Horse` is an `Animal` and `Rideable` - * `Chicken` is an `Animal` and a `Produce` which `yield` an `EdibleEgg` if `hasBeenFertilized` flag is `false`. + * `com.zipcodewilmington.froilansfarm.Animal` is a `NoiseMaker` and `Eater` + * `Horse` is an `com.zipcodewilmington.froilansfarm.Animal` and `Rideable` + * `Chicken` is an `com.zipcodewilmington.froilansfarm.Animal` and a `Produce` which `yield` an `EdibleEgg` if `hasBeenFertilized` flag is `false`. * `Rider` can `mount` and `dismount` a `Rideable` object. * `Botanist` can `plant` a `Crop` in a `CropRow`. diff --git a/pom.xml b/pom.xml index 69a3b878..4808bf88 100644 --- a/pom.xml +++ b/pom.xml @@ -8,5 +8,28 @@ froilans-farm 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + + + junit + junit + 4.12 + test + + + + \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Animal.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Animal.java new file mode 100644 index 00000000..2041fcd2 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Animal.java @@ -0,0 +1,51 @@ +package com.zipcodewilmington.froilansfarm.Animal; + +import com.zipcodewilmington.froilansfarm.Eater; +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.NoiseMaker; + +public class Animal implements NoiseMaker, Eater { + String name; + Integer age; + Integer amountOfFoodEaten; + + public Animal(String name, Integer age, Integer amountOfFoodEaten) { + this.name = name; + this.age = age; + this.amountOfFoodEaten = amountOfFoodEaten; + } + + public Animal() { + this.name = ""; + this.age = 0; + this.amountOfFoodEaten = 0; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public void eat(Edible object) { + + } + + public boolean hasEaten() { + return false; + } + + public String noiseMaker() { + return null; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Barn.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Barn.java new file mode 100644 index 00000000..01d02284 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Barn.java @@ -0,0 +1,37 @@ +package com.zipcodewilmington.froilansfarm.Animal; + +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; + +import java.util.ArrayList; +import java.util.List; + +public abstract class Barn implements StorageInterface { + List animals; + + public Barn() { + animals = new ArrayList<>(); + } +// +// public Integer numberOfAnimals(){ +// return animals.size(); +// } +// +// +// public void add(T animal) { +// animals.add(animal); +// } +// +// public void remove(T animal) { +// animals.remove(animal); +// } + + public List getList() { + return animals; + } + + public void setAnimals(List animals) { + this.animals = new ArrayList<>(animals); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Chicken.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Chicken.java new file mode 100644 index 00000000..ccef6b05 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Chicken.java @@ -0,0 +1,34 @@ +package com.zipcodewilmington.froilansfarm.Animal; + +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.Produce; + +public class Chicken extends Animal implements Produce { + Boolean isFertilized = false; + Integer eggs; + + public Chicken() { + } + + public void yield(Edible object) { + if (this.isFertilized == true) { + this.eggs += 1; + } + } + + public boolean hasBeenFertilized() { + return false; + } + + public boolean hasBeenHarvested() { + return false; + } + + public String makeNoise() { + return "Cluck!"; + } + + public void eat(Edible Object) { + + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Farmer.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Farmer.java new file mode 100644 index 00000000..0693b937 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Farmer.java @@ -0,0 +1,96 @@ +package com.zipcodewilmington.froilansfarm.Animal; + +import com.zipcodewilmington.froilansfarm.Eater; +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.Rideable; +import com.zipcodewilmington.froilansfarm.Rider; +import com.zipcodewilmington.froilansfarm.Vehicle.Botanist; +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; + +import java.util.ArrayList; +import java.util.List; + +public class Farmer extends Person implements Rider, Eater, Botanist { + int numberOfRidesTaken; + int numberOfCropsPlanted; + int numberOfEdiblesEaten; + // List thingsEaten; + String name = "Froilan"; + Rideable vehicle; + + + public Farmer(Integer numberOfRidesTaken, Integer numberOfCropsPlanted, Integer numberOfEdiblesEaten + , String name, ArrayList thingsEaten) { + this.numberOfRidesTaken = numberOfRidesTaken; + this.numberOfCropsPlanted = numberOfCropsPlanted; + this.numberOfEdiblesEaten = numberOfEdiblesEaten; + this.name = name; + //this.thingsEaten = thingsEaten; + + } + + public Farmer() { + } + + public String getName() { + return name; + } + + public void mount(Rideable object) { + this.vehicle = object; + if (object.hasBeenRiden()) { + incrementRidesTaken(); + } + } + + public Integer getNumberOfRidesTaken() { + return numberOfRidesTaken; + } + + public void dismount(Rideable object) { + this.vehicle = null; + } + + public void eat(Edible object) { + if (object.isEaten()) { + incrementFoodEaten(); + } else { + throw new UnsupportedOperationException("No new produce to eat:("); + } + } + + public boolean hasEaten() { + return false; + } + + public void plant(CropRow cropRow, Crop crop) { + cropRow.add(crop); + incrementNumberOfPlants(); + + } + + public Integer getNumberOfCropsPlanted() { + return numberOfCropsPlanted; + } + + public void setNumberOfPlants(Integer num) { + this.numberOfCropsPlanted = num; + } + + public void setName(String name) { + this.name = name; + } + + public void incrementNumberOfPlants(){ + setNumberOfPlants(getNumberOfCropsPlanted()+1); + } + + public void incrementFoodEaten(){ + setAmountOfFoodEaten(getAmountOfFoodEaten()+1); + } + public void incrementRidesTaken(){ + numberOfRidesTaken++; + + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Horse.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Horse.java new file mode 100644 index 00000000..ca260d33 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Horse.java @@ -0,0 +1,30 @@ +package com.zipcodewilmington.froilansfarm.Animal; + +import com.zipcodewilmington.froilansfarm.Rideable; + +public class Horse extends Animal implements Rideable { + + String name; + Integer age; + Integer amountOfFoodEaten; + + public Horse(String name, Integer age, Integer amountOfFoodEaten) { + super(name, age, amountOfFoodEaten); + } + + + public Horse() { + this.name = ""; + this.age = 0; + this.amountOfFoodEaten = 0; + } + + + public boolean hasBeenRiden() { + return false; + } + + public String makeNoise() { + return "Neigh!"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Person.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Person.java new file mode 100644 index 00000000..31f81d18 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animal/Person.java @@ -0,0 +1,32 @@ +package com.zipcodewilmington.froilansfarm.Animal; + +public class Person { + String name; + int amountOfFoodEaten; + + public Person(String name, int amountOfFoodEaten) { + this.name = name; + this.amountOfFoodEaten = amountOfFoodEaten; + } + + public Person() { + this.name = ""; + this.amountOfFoodEaten = 0; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAmountOfFoodEaten() { + return amountOfFoodEaten; + } + + public void setAmountOfFoodEaten(int amountOfFoodEaten) { + this.amountOfFoodEaten = amountOfFoodEaten; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Eater.java b/src/main/java/com/zipcodewilmington/froilansfarm/Eater.java new file mode 100644 index 00000000..d8fd7aab --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Eater.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm; + +public interface Eater { + + void eat(Edible object); + + boolean hasEaten(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Edible.java b/src/main/java/com/zipcodewilmington/froilansfarm/Edible.java new file mode 100644 index 00000000..35ebe179 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Edible.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm; + +public interface Edible { + + boolean isEaten(); + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java b/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java index fd743ffc..821d5c96 100644 --- a/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java @@ -1,8 +1,54 @@ package com.zipcodewilmington.froilansfarm; +import com.zipcodewilmington.froilansfarm.Animal.Animal; +import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle; +import com.zipcodewilmington.froilansfarm.storage.*; + +import java.util.ArrayList; +import java.util.List; + /** * Created by leon on 2/26/18. */ -public class MainApplication { + public class MainApplication { + //holds a list of the days of the week + //each day is its own class + //each day class has its own "Runnable" schedule + //make fertilize method + //make check fertilization method (hasBeenFertilized) + //potentially make Farmer abstract so that Froilan and Froilanda can both be declared new Farmers + // + public static void main(String[] args) { + Farm farm = new Farm<>(); + Stable stable1= new Stable(); + Stable stable2 = new Stable(); + Stable stable3 = new Stable(); + farm.addShelter(stable1); + farm.addShelter(stable2); + farm.addShelter(stable3); + ChickenCoop coop1 = new ChickenCoop(); + ChickenCoop coop2= new ChickenCoop(); + ChickenCoop coop3= new ChickenCoop(); + ChickenCoop coop4 = new ChickenCoop(); + farm.addShelter(coop1); + farm.addShelter(coop2); + farm.addShelter(coop3); + farm.addShelter(coop4); + int size = farm.amountShelter(); + int coops = farm.getAmountofCoops(); + + System.out.println(size); + System.out.println(coops); + +} + public void createFarm(Field field, List shelters, List mammals, List vehicles){ + Farm instance = new Farm(field, shelters, mammals, vehicles); + ChickenCoop coop1 = new ChickenCoop(); + ChickenCoop coop2= new ChickenCoop(); + ChickenCoop coop3= new ChickenCoop(); + ChickenCoop coop4 = new ChickenCoop(); + shelters.add(coop1); + shelters.add(coop2); //this is a bit tedious + } } diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/NoiseMaker.java b/src/main/java/com/zipcodewilmington/froilansfarm/NoiseMaker.java new file mode 100644 index 00000000..50523652 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/NoiseMaker.java @@ -0,0 +1,6 @@ +package com.zipcodewilmington.froilansfarm; + +public interface NoiseMaker { + + String noiseMaker (); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Produce.java b/src/main/java/com/zipcodewilmington/froilansfarm/Produce.java new file mode 100644 index 00000000..04f4157c --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Produce.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm; + +public interface Produce { + + + void yield(Edible object); + + boolean hasBeenFertilized(); + + boolean hasBeenHarvested(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Rideable.java b/src/main/java/com/zipcodewilmington/froilansfarm/Rideable.java new file mode 100644 index 00000000..a63a49e7 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Rideable.java @@ -0,0 +1,6 @@ +package com.zipcodewilmington.froilansfarm; + +public interface Rideable { + + boolean hasBeenRiden(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Rider.java b/src/main/java/com/zipcodewilmington/froilansfarm/Rider.java new file mode 100644 index 00000000..66534ac4 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Rider.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm; + +public interface Rider { + + void mount(Rideable object); + + void dismount(Rideable object); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/SingleFarm.java b/src/main/java/com/zipcodewilmington/froilansfarm/SingleFarm.java new file mode 100644 index 00000000..4633704b --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/SingleFarm.java @@ -0,0 +1,14 @@ +package com.zipcodewilmington.froilansfarm; + +public class SingleFarm { + private static final SingleFarm INSTANCE = new SingleFarm(); + + + SingleFarm (){}; + + public static SingleFarm getInstance(){ + return INSTANCE; + } + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Aircraft.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Aircraft.java new file mode 100644 index 00000000..80ed677d --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Aircraft.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + +import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle; + +public interface Aircraft extends Vehicle { + + void fly(int distance); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Botanist.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Botanist.java new file mode 100644 index 00000000..c07c1fd5 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Botanist.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; + +public interface Botanist { + public void plant(CropRow cropRow, Crop crop); + + void setNumberOfPlants(Integer num); + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/CropDuster.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/CropDuster.java new file mode 100644 index 00000000..23d26d57 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/CropDuster.java @@ -0,0 +1,71 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + + +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; + +public class CropDuster extends FarmVehicle implements Aircraft { + + public boolean toBeFertilized; + public int numOfCropRows; + public int numOfCropFert; + + public CropDuster(boolean toBeFertilized, int numOfCropRows, int numOfCropFert) { + this.toBeFertilized = toBeFertilized; + this.numOfCropRows = numOfCropRows; + this.numOfCropFert = numOfCropFert; + } + + public boolean getToBeFertilized() { + return toBeFertilized; + } + + public void setToBeFertilized(boolean toBeFertilized) { + this.toBeFertilized = toBeFertilized; + } + + + + public void setNumOfCropRows(int numOfCropRows) { + this.numOfCropRows = numOfCropRows; + + } + + public int getNumOfCropRows() { + return this.numOfCropRows; + } + + public void setNumOfFertCrop(int numOfCropFert) { + this.numOfCropFert = numOfCropFert; + } + + public int getNumOfFertCrop() { + return this.numOfCropFert; + } + + public boolean needsToBeFertilized(CropRow cropRow) { + for (Crop crop : cropRow.getList()) { + if (crop.hasBeenFertilized()==false){ + return true; + } + } + return false; + } + + @Override + public void fly(int distance) { + + } + + @Override + public String noiseMaker() { + return "Ppbd Ppbd"; + } + + @Override + public boolean hasBeenRiden() { + return false; + } + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/FarmVehicle.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/FarmVehicle.java new file mode 100644 index 00000000..c001bc09 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/FarmVehicle.java @@ -0,0 +1,47 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + +public class FarmVehicle implements Vehicle { + String onFarm; + String offFarm; + String location; + + public FarmVehicle(String onFarm, String offFarm, String location) { + this.onFarm = onFarm; + this.offFarm = offFarm; + this.location = location; + } + + public FarmVehicle() { + + } + + public void setLocation(String expected) { + this.location = expected; + } + + public String getLocation() { + return this.location; + } + + public Boolean operation(String location) { + return location.equals(onFarm); + } + + @Override + public String noiseMaker() { + return null; + } + + @Override + public boolean hasBeenRiden() { + return false; + } + + public String getOnFarm() { + return onFarm; + } + + public void setOnFarm(String onFarm) { + this.onFarm = onFarm; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Pilot.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Pilot.java new file mode 100644 index 00000000..346d8b89 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Pilot.java @@ -0,0 +1,22 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + +import com.zipcodewilmington.froilansfarm.Animal.Person; +import com.zipcodewilmington.froilansfarm.Rideable; +import com.zipcodewilmington.froilansfarm.Rider; + +public class Pilot extends Person implements Rider { + public Pilot() { + super(); + } + + + @Override + public void mount(Rideable object) { + + } + + @Override + public void dismount(Rideable object) { + + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Tractor.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Tractor.java new file mode 100644 index 00000000..54213954 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Tractor.java @@ -0,0 +1,51 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; + +public class Tractor extends FarmVehicle { + boolean toBeHarvested; + int numOfFertCrop; + int numOfHarvCrop; + + public Tractor(boolean toBeHarvested, int numOfFertCrop, int numOfHarvCrop) { + super(); + this.toBeHarvested = toBeHarvested; + this.numOfFertCrop = numOfFertCrop; + this.numOfHarvCrop = numOfHarvCrop; + } + + public boolean isToBeHarvested() { + return toBeHarvested; + } + + public void setToBeHarvested(boolean toBeHarvested) { + this.toBeHarvested = toBeHarvested; + } + + public void setNumOfFertCrop(int numOfFertCrop) { + this.numOfFertCrop = numOfFertCrop; + } + + public void setNumOfHarvCrop(int numOfHarvCrop) { + this.numOfHarvCrop = numOfHarvCrop; + } + + public int getNumOfHarvCrop() { + return this.numOfHarvCrop; + } + + public int getNumOfFertCrop() { + return this.numOfFertCrop; + } + + public boolean needsToBeHarvested(CropRow cropRow) { + for (Crop crop : cropRow.getList()) { + if (crop.hasBeenHarvested() == false) { + return true; + } + } + return false; + } +} + diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Vehicle.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Vehicle.java new file mode 100644 index 00000000..6d227a9e --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Vehicle.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.Vehicle; + +import com.zipcodewilmington.froilansfarm.NoiseMaker; +import com.zipcodewilmington.froilansfarm.Rideable; + +public interface Vehicle extends Rideable, NoiseMaker { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/crops/CornPlant.java b/src/main/java/com/zipcodewilmington/froilansfarm/crops/CornPlant.java new file mode 100644 index 00000000..87179c85 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/crops/CornPlant.java @@ -0,0 +1,16 @@ +package com.zipcodewilmington.froilansfarm.crops; + +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.Produce; + +public class CornPlant extends Crop{ + + public CornPlant(Integer numOfEdiblesYielded, Integer numOfCropsHarvested, Integer numOfEdiblesEaten) { + super(numOfEdiblesYielded, numOfCropsHarvested, numOfEdiblesEaten); + } + + public CornPlant() { + super(); + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/crops/Crop.java b/src/main/java/com/zipcodewilmington/froilansfarm/crops/Crop.java new file mode 100644 index 00000000..4b04eaa8 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/crops/Crop.java @@ -0,0 +1,75 @@ +package com.zipcodewilmington.froilansfarm.crops; + +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.Produce; + +public abstract class Crop implements Produce { + Integer numOfEdiblesYielded; //once fertilized + Integer numOfEdiblesHarvested; //once harvested + Integer numOfEdiblesEaten; //decrement if eaten + Boolean hasBeenFertilized; + Boolean hasBeenHarvested; + + + public Crop(Integer numOfYield, Integer numOfCropsHarvested, Integer numOfEdiblesLeft, Boolean hasBeenFertilized, Boolean hasBeenHarvested) { + this.numOfEdiblesYielded = numOfYield; + this.numOfEdiblesHarvested = numOfCropsHarvested; + this.numOfEdiblesEaten = numOfEdiblesLeft; + this.hasBeenFertilized = hasBeenFertilized; + this.hasBeenHarvested = hasBeenHarvested; + } + + public Crop(Integer numOfYield, Integer numOfCropsHarvested, Integer numOfEdiblesLeft) { + this(numOfYield, numOfCropsHarvested, numOfEdiblesLeft, false, false); + } + + public Crop() { + this(0, 0, 0); + } + + public void fertilize() { + this.hasBeenFertilized = true; + } + + public void harvest() { + this.hasBeenHarvested = true; + numOfEdiblesHarvested++; + } + + public Integer getNumOfEdiblesYielded() { + return numOfEdiblesYielded; + } + + + public Integer getNumberofHarvest() { + if (hasBeenHarvested) { + return numOfEdiblesYielded; + } + + return numOfEdiblesHarvested; + } + + public void yield(Edible edible) { + if (hasBeenFertilized) { + numOfEdiblesYielded++; + } else { + throw new UnsupportedOperationException("Must be fertilized first!"); + } + } + + public boolean hasBeenFertilized() { + return hasBeenFertilized; + } + + public boolean hasBeenHarvested() { + return hasBeenHarvested; + } + + public Integer getFoodToEat() { + if (hasBeenHarvested) { + return numOfEdiblesHarvested - numOfEdiblesEaten; + } else { + throw new UnsupportedOperationException("Food must be harvested first!"); + } + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/crops/CropRow.java b/src/main/java/com/zipcodewilmington/froilansfarm/crops/CropRow.java new file mode 100644 index 00000000..c53e0f21 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/crops/CropRow.java @@ -0,0 +1,55 @@ +package com.zipcodewilmington.froilansfarm.crops; + +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; + +import java.util.ArrayList; +import java.util.List; + +public class CropRow implements StorageInterface { + List crops = new ArrayList<>(); + + @Override + public List getList() { + return crops; + } + + + +// public CropRow(List cropRow) { +// this.cropRow = cropRow; +// +// } +// +// public CropRow() { +// this.cropRow = new ArrayList<>(); +// } +// +// public int getNumberofCropsPlanted() {return cropRow.size();} + +// public List getCropRow() { +// return cropRow; +// } + + public void addCrop(Crop crop, Integer numberOfCrops){ + for (int i = 0; i < numberOfCrops; i++) { + add(crop); + } + } +// public void addCrop(Crop crop){ +// cropRow.add(crop); +// } +// +// public void removeCrop(Crop crop) { +// cropRow.remove(crop); +// } + + public int getNumberOfEdibles() { + int sum = 0; + for (Crop crop : crops) { + sum += crop.getNumOfEdiblesYielded(); + } + return sum; + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/crops/EarOfCorn.java b/src/main/java/com/zipcodewilmington/froilansfarm/crops/EarOfCorn.java new file mode 100644 index 00000000..2f56ba98 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/crops/EarOfCorn.java @@ -0,0 +1,10 @@ +package com.zipcodewilmington.froilansfarm.crops; + +import com.zipcodewilmington.froilansfarm.Edible; + +public class EarOfCorn implements Edible { + @Override + public boolean isEaten() { + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/crops/Tomato.java b/src/main/java/com/zipcodewilmington/froilansfarm/crops/Tomato.java new file mode 100644 index 00000000..f4ed5953 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/crops/Tomato.java @@ -0,0 +1,10 @@ +package com.zipcodewilmington.froilansfarm.crops; + +import com.zipcodewilmington.froilansfarm.Edible; + +public class Tomato implements Edible { + @Override + public boolean isEaten() { + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/crops/TomatoPlant.java b/src/main/java/com/zipcodewilmington/froilansfarm/crops/TomatoPlant.java new file mode 100644 index 00000000..502ac8ca --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/crops/TomatoPlant.java @@ -0,0 +1,24 @@ +package com.zipcodewilmington.froilansfarm.crops; + +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.Produce; + +public class TomatoPlant extends Crop{ + public TomatoPlant(Integer numOfEdiblesYielded, Integer numOfCropsHarvested, Integer numOfCropsFertilized) { + super(numOfEdiblesYielded, numOfCropsHarvested, numOfCropsFertilized); + } + + public TomatoPlant(Integer numberOfTomatoes) { + super(numberOfTomatoes,0,0); + } + + public TomatoPlant() { + super(); + } + + public Edible getYield(){ + return new Tomato(); + } + + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/storage/ChickenCoop.java b/src/main/java/com/zipcodewilmington/froilansfarm/storage/ChickenCoop.java new file mode 100644 index 00000000..fe73dd36 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/storage/ChickenCoop.java @@ -0,0 +1,16 @@ +package com.zipcodewilmington.froilansfarm.storage; + + +import com.zipcodewilmington.froilansfarm.Animal.Barn; +import com.zipcodewilmington.froilansfarm.Animal.Chicken; + + + +import java.util.ArrayList; +import java.util.List; + +public class ChickenCoop extends Barn { + + } + + diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/storage/Farm.java b/src/main/java/com/zipcodewilmington/froilansfarm/storage/Farm.java new file mode 100644 index 00000000..94d96019 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/storage/Farm.java @@ -0,0 +1,66 @@ +package com.zipcodewilmington.froilansfarm.storage; + +import com.zipcodewilmington.froilansfarm.Animal.Animal; +import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; + +import java.util.ArrayList; +import java.util.List; + +public class Farm { + + List farm = new ArrayList<>(); + Field field; + List vehicles = new ArrayList<>(); + List farmAnimals = new ArrayList<>(); + + public Farm () { + // This is a test, nerd + } + + public Farm (Field field, List farm, List farmAnimals, List vehicles){ + this.field = new Field(); + this.farm = new ArrayList<>(); + this.farmAnimals = new ArrayList<>(); + this.vehicles = new ArrayList<>(); + } + + + + public void addShelter(StorageInterface storage) { + farm.add(storage); + + } + + + public void removeShelter( StorageInterface storage) { + farm.remove(storage); + } + + + public int amountShelter() { + return farm.size(); + } + + public int getAmountofCoops(){ + int numOfOccurences = 0; + for (StorageInterface s : farm) { + if (s instanceof ChickenCoop){ + numOfOccurences++; + } + + } + return numOfOccurences; + } + + public int getAmountofStable(){ + int numOfOccurences = 0; + for (StorageInterface s : farm) { + if (s instanceof Stable){ + numOfOccurences++; + } + + } + return numOfOccurences; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/storage/Field.java b/src/main/java/com/zipcodewilmington/froilansfarm/storage/Field.java new file mode 100644 index 00000000..2164267d --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/storage/Field.java @@ -0,0 +1,15 @@ +package com.zipcodewilmington.froilansfarm.storage; + +import com.zipcodewilmington.froilansfarm.crops.CropRow; + +import java.util.ArrayList; +import java.util.List; + +public class Field implements StorageInterface { + private List list = new ArrayList<>(); + + @Override + public List getList() { + return list; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/storage/Stable.java b/src/main/java/com/zipcodewilmington/froilansfarm/storage/Stable.java new file mode 100644 index 00000000..6f97a9d3 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/storage/Stable.java @@ -0,0 +1,13 @@ +package com.zipcodewilmington.froilansfarm.storage; + + +import com.zipcodewilmington.froilansfarm.Animal.Barn; +import com.zipcodewilmington.froilansfarm.Animal.Horse; + + +import java.util.ArrayList; +import java.util.List; + +public class Stable extends Barn { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/storage/StorageInterface.java b/src/main/java/com/zipcodewilmington/froilansfarm/storage/StorageInterface.java new file mode 100644 index 00000000..2c1bec57 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/storage/StorageInterface.java @@ -0,0 +1,20 @@ +package com.zipcodewilmington.froilansfarm.storage; + +import java.util.List; + +public interface StorageInterface { + List getList(); + + default Integer getSize(){ + return getList().size(); + } + + + default void add(TypeToStore animal) { + getList().add(animal); + } + + default void remove(TypeToStore animal) { + getList().remove(animal); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/AnimalTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/AnimalTest.java new file mode 100644 index 00000000..03daf4d1 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/AnimalTest.java @@ -0,0 +1,88 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; +import com.zipcodewilmington.froilansfarm.Animal.Animal; +import org.junit.Test; +import org.junit.Assert; +public class AnimalTest { + + @Test + public void nullaryConstructorTest(){ + Animal animal=new Animal(); + //when + int actual=animal.getAge(); + + //then + Assert.assertEquals(0,actual); + } + //given + + @Test + public void nullaryConstructorTest2(){ + Animal animal=new Animal(); + //when + String actual=animal.getName(); + + //then + Assert.assertEquals("",actual); + } + + @Test + public void constructorTest(){ + String name = "Sitara"; + Integer age = 20; + Integer amountOfFoodEaten = 2; + Animal animal=new Animal(name,age,amountOfFoodEaten); + //when + String actual=animal.getName(); + + //then + Assert.assertEquals("Sitara",actual); + } + @Test + public void getAgeTest(){ + String name = "Sitara"; + Integer age = 20; + Integer amountOfFoodEaten = 2; + Animal animal=new Animal(name,age,amountOfFoodEaten); + //when + Integer actual=animal.getAge(); + + //then + Assert.assertEquals(age,actual); + } + + @Test + public void setAgeTest(){ + String name = "Sitara"; + Integer age = 20; + Integer expected = 24; + Integer amountOfFoodEaten = 2; + Animal animal=new Animal(name,age,amountOfFoodEaten); + animal.setAge(24); + //when + Integer actual=animal.getAge(); + + //then + Assert.assertEquals(expected,actual); + } + + @Test + public void setNameTest(){ + String name = "Sutara"; + Integer age = 20; + String expected = "Sitara"; + Integer amountOfFoodEaten = 2; + Animal animal=new Animal(name,age,amountOfFoodEaten); + animal.setName(expected); + //when + String actual=animal.getName(); + + //then + Assert.assertEquals(expected,actual); + } + + + + + + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/BarnTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/BarnTest.java new file mode 100644 index 00000000..3db0e1ee --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/BarnTest.java @@ -0,0 +1,80 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; + +import com.zipcodewilmington.froilansfarm.Animal.Animal; +import com.zipcodewilmington.froilansfarm.Animal.Barn; +import com.zipcodewilmington.froilansfarm.Animal.Horse; +import com.zipcodewilmington.froilansfarm.storage.ChickenCoop; +import com.zipcodewilmington.froilansfarm.storage.Stable; +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +public class BarnTest { + + @Test + public void numberOfAnimalsTest() { + Barn barn = new ChickenCoop(); + List animals = new ArrayList(); + ; + + //List animals = new ArrayList<>(); + animals.add((T) "chicken"); + animals.add((T) "horse"); + animals.add((T) "chick"); + Integer expected = 3; + barn.setAnimals(animals); + Assert.assertEquals(expected, barn.getSize()); + } + + @Test + public void addTest() { + Barn barn = new ChickenCoop(); + List animals = new ArrayList<>(); + animals.add("chicken"); + barn.setAnimals(animals); + //animals.toArray(); + Assert.assertEquals("chicken", barn.getList().get(0)); + + } + + @Test + public void removeTest() { + Barn barn = new Stable(); + List animals = new ArrayList<>(); + Animal horse = new Horse(); + Animal horse2 = new Horse(); + + animals.add(horse2); + animals.add(horse); + + barn.setAnimals(animals); + + barn.getList().remove(horse); + + Assert.assertEquals(1, barn.getList().size()); + } + + @Test + public void testGetAnimals() { + Barn barn = new Stable(); + List animals = new ArrayList<>(); + animals.add("chicken"); + animals.add("horse"); + barn.setAnimals(animals); + + Assert.assertEquals("chicken", barn.getList().get(0)); + } + + @Test + public void testSetAnimals() { + Barn barn = new ChickenCoop(); + List animals = new ArrayList<>(); + animals.add("chicken"); + animals.add("horse"); + barn.setAnimals(animals); + + Assert.assertEquals("horse", barn.getList().get(1)); + } +} \ No newline at end of file diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/ChickenTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/ChickenTest.java new file mode 100644 index 00000000..510a896a --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/ChickenTest.java @@ -0,0 +1,58 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; + +import com.zipcodewilmington.froilansfarm.Animal.Animal; +import com.zipcodewilmington.froilansfarm.Animal.Chicken; +import com.zipcodewilmington.froilansfarm.Edible; +import com.zipcodewilmington.froilansfarm.Produce; +import org.junit.Assert; +import org.junit.Test; + +public class ChickenTest { + + @Test + public void instanceOfAnimal () { + Chicken chicken = new Chicken(); + + Assert.assertTrue(chicken instanceof Animal); + } + + @Test + public void instanceOfProduce () { + Chicken chicken = new Chicken(); + + Assert.assertTrue(chicken instanceof Produce); + } + + @Test + public void hasBeenFertilisedTest(){ + Chicken chicken =new Chicken(); + Assert.assertFalse(chicken.hasBeenFertilized()); + } + @Test + public void hasBeenHarvestedTest(){ + Chicken chicken =new Chicken(); + Assert.assertFalse(chicken.hasBeenHarvested()); + } + + @Test + public void yieldTest(){ + Chicken chicken =new Chicken(); + Edible object = new Edible() { + @Override + public boolean isEaten() { + return false; + } + }; + chicken.yield(object); + Assert.assertTrue(true); + } + + @Test + public void makeNoiseTest(){ + Chicken chicken = new Chicken(); + String noise="Cluck!"; + String actual= chicken.makeNoise(); + Assert.assertEquals("Cluck!",actual); + } + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/FarmerTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/FarmerTest.java new file mode 100644 index 00000000..058514d2 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/FarmerTest.java @@ -0,0 +1,57 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; + +import com.zipcodewilmington.froilansfarm.Animal.Farmer; +import com.zipcodewilmington.froilansfarm.Rideable; +import com.zipcodewilmington.froilansfarm.crops.CornPlant; +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; +import org.junit.Assert; +import org.junit.Test; + +public class FarmerTest { + @Test + public void constructorTest() { + Farmer farmer = new Farmer(); + String actualName = "Froilan"; + Assert.assertEquals(farmer.getName(), actualName); + } + + @Test + public void hasEatenTest() { + Farmer farmer = new Farmer(); + Boolean actual = false; + Assert.assertFalse(farmer.hasEaten()); + } + + @Test + public void plantTest() { + Farmer farmer = new Farmer(); + CropRow cropRow = new CropRow(); + Integer numberOfCrops = 0; + Crop crop = new CornPlant(); + Integer expected = 1; +// cropRow.addCrop(crop); + farmer.plant(cropRow, crop); + Assert.assertEquals(expected, farmer.getNumberOfCropsPlanted()); + + } + + @Test + public void mountTest() { + Farmer farmer = new Farmer(); + Integer expected = 1; + + Rideable vehicle = new Rideable() { + @Override + public boolean hasBeenRiden() { + return true; + } + }; + farmer.mount(vehicle); + + Assert.assertEquals(expected, farmer.getNumberOfRidesTaken()); + + } + +} + diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/HorseTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/HorseTest.java new file mode 100644 index 00000000..9b1e34c8 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/HorseTest.java @@ -0,0 +1,29 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; + +import com.zipcodewilmington.froilansfarm.Animal.Horse; +import org.junit.Assert; +import org.junit.Test; + +public class HorseTest { + @Test + public void makeNoiseTest() { + Horse horse= new Horse(null,null,null); + String noise = "Neigh!"; + String actual = horse.makeNoise(); + Assert.assertEquals("Neigh!", actual); + } + + @Test + public void hadBeenRiddenTest(){ + Horse horse =new Horse(null,null,null); + Boolean actual=false; + Assert.assertEquals(horse.hasBeenRiden(),actual); + } + + @Test + public void constructorTest(){ + Horse horse= new Horse("robert",10,null); + String actual="robert"; + Assert.assertEquals(horse.getName(),actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/PersonTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/PersonTest.java new file mode 100644 index 00000000..b03166bd --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/PersonTest.java @@ -0,0 +1,58 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; + + +import com.zipcodewilmington.froilansfarm.Animal.Person; +import org.junit.Assert; +import org.junit.Test; + +public class PersonTest { + @Test + public void constructorTest(){ + Person person =new Person(); + String actualName=""; + Integer amountOfFoodEaten; + + String expectedName=person.getName(); + //then + Assert.assertEquals(expectedName,actualName); + } + + @Test + public void constructorTest2(){ + Person person =new Person(); + + Integer actualAmountOfFoodEaten=0; + + Integer expectedAmount=person.getAmountOfFoodEaten(); + //then + Assert.assertEquals(expectedAmount,actualAmountOfFoodEaten); + } + + @Test + public void setNameTest(){ + String name = "Sutara"; + String expected = "Sitara"; + Integer amountOfFoodEaten = 2; + Person person=new Person(name,amountOfFoodEaten); + person.setName(expected); + //when + String actual=person.getName(); + + //then + Assert.assertEquals(expected,actual); + } + + @Test + public void setAmountOfFoodTest(){ + String name = "Sitara"; + Integer amountOfFoodEaten = 2; + Integer expected = 2; + Person person=new Person(name,amountOfFoodEaten); + person.setAmountOfFoodEaten(expected); + //when + Integer actual=person.getAmountOfFoodEaten(); + + //then + Assert.assertEquals(expected,actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/PilotTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/PilotTest.java new file mode 100644 index 00000000..22e2b100 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalTest/PilotTest.java @@ -0,0 +1,24 @@ +package com.zipcodewilmington.froilansfarm.AnimalTest; + +import com.zipcodewilmington.froilansfarm.Animal.Person; +import com.zipcodewilmington.froilansfarm.Rider; +import com.zipcodewilmington.froilansfarm.Vehicle.Pilot; +import org.junit.Assert; +import org.junit.Test; + +public class PilotTest { + + @Test + public void instanceOfPerson () { + Pilot p = new Pilot(); + + Assert.assertTrue(p instanceof Person); + } + + @Test + public void instanceOfRider () { + Pilot p = new Pilot(); + + Assert.assertTrue(p instanceof Rider); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/MainApplicationTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/MainApplicationTest.java index 1a971b7f..a6e8897e 100644 --- a/src/test/java/com/zipcodewilmington/froilansfarm/MainApplicationTest.java +++ b/src/test/java/com/zipcodewilmington/froilansfarm/MainApplicationTest.java @@ -1,7 +1,32 @@ package com.zipcodewilmington.froilansfarm; +import com.zipcodewilmington.froilansfarm.storage.Farm; +import com.zipcodewilmington.froilansfarm.storage.Stable; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; +import org.junit.Assert; +import org.junit.Test; + /** * Created by leon on 2/26/18. */ public class MainApplicationTest { + + @Test + public void addStorageTest(){ + //given + Farm farm = new Farm<>(); + Stable stable1= new Stable(); + Stable stable2 = new Stable(); + Stable stable3 = new Stable(); + int expected = 3; + + //when + farm.addShelter(stable1); + farm.addShelter(stable2); + farm.addShelter(stable3); + int actual = farm.amountShelter(); + + //then + Assert.assertEquals(expected, actual); + } } diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/CropDusterTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/CropDusterTest.java new file mode 100644 index 00000000..7230f248 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/CropDusterTest.java @@ -0,0 +1,154 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Vehicle.Aircraft; +import com.zipcodewilmington.froilansfarm.Vehicle.CropDuster; +import com.zipcodewilmington.froilansfarm.Vehicle.FarmVehicle; +import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle; +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; +import com.zipcodewilmington.froilansfarm.crops.Tomato; +import com.zipcodewilmington.froilansfarm.crops.TomatoPlant; +import org.junit.Assert; +import org.junit.Test; + +public class CropDusterTest { + @Test + public void constructorTest(){ + //given + int numOfCropRows=93; + int numOfFertCrops=32; + boolean toBeFertilized=true; + //when + CropDuster crop = new CropDuster(false, 0, 0); + + //then + Assert.assertNotEquals(numOfCropRows, crop.getNumOfCropRows()); + Assert.assertNotEquals(numOfFertCrops, crop.getNumOfFertCrop()); + Assert.assertNotEquals(toBeFertilized, false); + } + @Test + public void nullaryConstructorTest(){ + //given + boolean expectedFertilizer=false; + int expectedNumOfCrop=895894; + int expectedNumOfFertCrop=4863826; + + //when + CropDuster crop = new CropDuster(true, 0, 0); + //then + Assert.assertNotEquals(expectedNumOfCrop, crop.getNumOfCropRows()); + Assert.assertNotEquals(expectedNumOfFertCrop, crop.getNumOfFertCrop()); + Assert.assertNotEquals(expectedFertilizer, crop.getToBeFertilized()); + + } + @Test + public void getCropsTest1(){ + int expected= 15; + CropDuster crop = new CropDuster(false,0, 0); + crop.setNumOfCropRows(expected); + //when + int actual = crop.getNumOfCropRows(); + //then + Assert.assertEquals(expected, actual); + } + @Test + public void needsToBeFertilizedTest1(){ + //given + int cropNum=20; + int fertCrop=4; + boolean expected= false; + CropRow cropRow = new CropRow(); + //when + CropDuster crop =new CropDuster(false, cropNum, fertCrop); + boolean actual= crop.needsToBeFertilized(cropRow); + //then + Assert.assertEquals(expected, actual ); + } + + @Test + public void getFertCropsTest1(){ + int expectedFertCrop = 5; + CropDuster crop = new CropDuster(false, 0, 0); + crop.setNumOfFertCrop(expectedFertCrop); + + int actual = crop.getNumOfFertCrop(); + + Assert.assertEquals(expectedFertCrop, actual); + } + @Test + public void inheritenceTest(){ + CropDuster crop = new CropDuster(false, 0, 0); + Assert.assertTrue(crop instanceof Vehicle); + } + @Test + public void inheritenceTest1(){ + CropDuster crop = new CropDuster(false, 0, 0); + Assert.assertTrue(crop instanceof Aircraft); + } + @Test + public void inheritenceTest2(){ + CropDuster crop = new CropDuster(false, 0, 0); + Assert.assertTrue(crop instanceof FarmVehicle); + } + + @Test + public void needsToBeFertilized () { + CropDuster cd = new CropDuster(false, + 0, 0); + Crop crop = new TomatoPlant(); + CropRow cropRow = new CropRow(); + Boolean expected = true; + crop.hasBeenFertilized(); + cropRow.add(crop); + + Boolean actual = cd.needsToBeFertilized(cropRow); + + Assert.assertEquals(expected, actual); + } + + @Test + public void noiseMakerTest () { + CropDuster cd = new CropDuster(false, + 0,0); + String expected = "Ppbd Ppbd"; + + String actual = cd.noiseMaker(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void hasbeenRidenTest () { + CropDuster cd = new CropDuster(false, + 0,0); + Boolean expected = false; + + Boolean actual = cd.hasBeenRiden(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getNumOfCropFertTest () { + CropDuster cd = new CropDuster(false, + 0 ,100); + Integer expected = 56; + + cd.setNumOfFertCrop(56); + Integer actual = cd.getNumOfFertCrop(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void fertilizedTest () { + CropDuster cd = new CropDuster(false, + 0, 0); + Boolean expected = true; + + cd.setToBeFertilized(true); + Boolean actual = cd.getToBeFertilized(); + + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/FarmVehicleTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/FarmVehicleTest.java new file mode 100644 index 00000000..5be484d9 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/FarmVehicleTest.java @@ -0,0 +1,88 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Rideable; +import com.zipcodewilmington.froilansfarm.Vehicle.CropDuster; +import com.zipcodewilmington.froilansfarm.Vehicle.FarmVehicle; +import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle; +import com.zipcodewilmington.froilansfarm.storage.Farm; +import org.junit.Assert; +import org.junit.Test; + +public class FarmVehicleTest { + + @Test + public void nullaryConstructorTest(){ + //given + String expected = null; + FarmVehicle farm = new FarmVehicle(); + farm.setLocation(expected); + //when + String actual= farm.getLocation(); + //then + Assert.assertEquals(expected, actual); + } + @Test + public void inheritenceCropDustTest(){ + FarmVehicle car = new FarmVehicle(); + Assert.assertTrue(car instanceof Vehicle); + } + @Test + public void inheritenceCropDustTest1(){ + FarmVehicle car = new FarmVehicle(); + Assert.assertTrue(car instanceof Rideable); + } + + @Test + public void getLocationTest () { + FarmVehicle thing = new FarmVehicle(); + String expected = "Over here"; + + thing.setLocation("Over here"); + String actual = thing.getLocation(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void noiseMakerTest () { + FarmVehicle thing = new FarmVehicle(); + String expected = null; + + String actual = thing.noiseMaker(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void hasBeenRiden () { + FarmVehicle thing = new FarmVehicle(); + Boolean expected = false; + + Boolean actual = thing.hasBeenRiden(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void operationOnFarmTest () { + FarmVehicle thing = new FarmVehicle(); + Boolean expected = true; + thing.setOnFarm("Is on farm?"); + + Boolean actual = thing.operation(thing.getOnFarm()); + + Assert.assertEquals(expected, actual); + } + + @Test (expected = AssertionError.class) + public void operationOffFarmTest () { + FarmVehicle thing = new FarmVehicle(); + Boolean expected = true; + thing.setOnFarm("Is on farm?"); + thing.setLocation("Not on the farm"); + + Boolean actual = thing.operation(thing.getLocation()); + + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/TractorTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/TractorTest.java new file mode 100644 index 00000000..0fae6183 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/Vehicles/TractorTest.java @@ -0,0 +1,100 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Vehicle.CropDuster; +import com.zipcodewilmington.froilansfarm.Vehicle.Tractor; +import com.zipcodewilmington.froilansfarm.crops.Crop; +import com.zipcodewilmington.froilansfarm.crops.CropRow; +import com.zipcodewilmington.froilansfarm.crops.Tomato; +import com.zipcodewilmington.froilansfarm.crops.TomatoPlant; +import org.junit.Assert; +import org.junit.Test; + +public class TractorTest { + + @Test + public void constructorTest() { + //given + int numOfHarvCrops = 93; + int numOfFertCrops = 32; + boolean toBeHarvested = true; + //when + Tractor crop = new Tractor(false, 0, 0); + + //then + Assert.assertNotEquals(numOfHarvCrops, crop.getNumOfHarvCrop()); + Assert.assertNotEquals(numOfFertCrops, crop.getNumOfFertCrop()); + Assert.assertNotEquals(toBeHarvested, false); + } + + @Test + public void nullaryConstructorTest() { + //given + boolean expectedHarvested = true; + int expectedNumOfHarvCrop = 895894; + int expectedNumOfFertCrop = 4863826; + + //when + Tractor crop = new Tractor(false, 0, 0); + //then + Assert.assertNotEquals(expectedNumOfHarvCrop, crop.getNumOfHarvCrop()); + Assert.assertNotEquals(expectedNumOfFertCrop, crop.getNumOfFertCrop()); + Assert.assertNotEquals(expectedHarvested, crop.isToBeHarvested()); + + } + + @Test + public void getCropsTest1() { + int expected = 15; + Tractor crop = new Tractor(false, 0, 0); + crop.setNumOfFertCrop(expected); + //when + int actual = crop.getNumOfFertCrop(); + //then + Assert.assertEquals(expected, actual); + } + + @Test + public void needsToBeFertilizedTest() { + //given + int cropNum = 20; + int fertCrop = 4; + boolean expected = false; + CropRow cropRow = new CropRow(); + //when + Tractor crop = new Tractor(false, cropNum, fertCrop); + boolean actual = crop.needsToBeHarvested(cropRow); + //then + Assert.assertEquals(expected, actual); + } + + @Test + public void doesNotNeedToBeHarvested () { + Tractor tractor = new Tractor(true, + 200, 10); + CropRow cr = new CropRow(); + Crop crop = new TomatoPlant(); + crop.fertilize(); + Boolean expected = true; + + cr.add(crop); + Boolean actual = tractor.needsToBeHarvested(cr); + + Assert.assertEquals(expected, actual); + } + + @Test + public void needsToBeHarvested () { + Tractor tractor = new Tractor(true, + 200, 10); + CropRow cr = new CropRow(); + Crop crop = new TomatoPlant(); + crop.fertilize(); + crop.harvest(); + Boolean expected = false; + + cr.add(crop); + Boolean actual = tractor.needsToBeHarvested(cr); + + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/croptests/CropRowTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/croptests/CropRowTest.java new file mode 100644 index 00000000..c1d05434 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/croptests/CropRowTest.java @@ -0,0 +1,151 @@ +package com.zipcodewilmington.froilansfarm.croptests; + +import com.zipcodewilmington.froilansfarm.crops.*; +import org.junit.Assert; +import org.junit.Test; + +public class CropRowTest { + @Test + public void defaultConstructorTest(){ + //given + CropRow testRow = new CropRow(); + + //when + int actual = testRow.getSize(); + + //then + int expected = 0; + Assert.assertEquals(expected, actual); + + } + + @Test + public void defaultConstructorTest2(){ + //given + CropRow testRow = new CropRow(); + + //when + int actual = testRow.getSize(); + + //then + int expected = 0; + Assert.assertEquals(expected, actual); + + } + + @Test + public void addCropTest(){ + //given + CropRow testRow = new CropRow(); + TomatoPlant tomato = new TomatoPlant(0); + + //when + testRow.addCrop(tomato, 2); + int actual = testRow.getSize(); + + //then + int expected = 2; + Assert.assertEquals(expected, actual); + + } + + @Test + public void removeCrop(){ + //given + CropRow testRow = new CropRow(); + TomatoPlant tomato = new TomatoPlant(0); + + //when + testRow.add(tomato); + testRow.remove(tomato); + int actual = testRow.getSize(); + + //then + int expected = 0; + Assert.assertEquals(expected, actual); + } + + @Test (expected = UnsupportedOperationException.class) + public void getTotalPlantsNegative(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Crop cornPlant = new CornPlant(); + tomatoPlant.yield(new Tomato()); + tomatoPlant.yield(new Tomato()); + cornPlant.yield(new EarOfCorn()); + + //when + CropRow testRow = new CropRow(); + testRow.add(tomatoPlant); + testRow.add(cornPlant); + int actual = testRow.getSize(); + + //then + Assert.assertEquals(2, actual); + + } + + @Test + public void getTotalPlantsPositive() { + //given + Crop tomatoPlant = new TomatoPlant(); + Crop cornPlant = new CornPlant(); + CropRow testRow = new CropRow(); + + //when + int before = testRow.getSize(); + Assert.assertEquals(0, before); + testRow.add(tomatoPlant); + testRow.add(cornPlant); + int actual = testRow.getSize(); + + //then + Assert.assertEquals(2, actual); + } + + @Test + public void getTotalEdibles(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Crop cornPlant = new CornPlant(); + CropRow testRow = new CropRow(); + testRow.add(tomatoPlant); + testRow.add(cornPlant); + tomatoPlant.fertilize(); + cornPlant.fertilize(); + + int expected = 3; + + //when + tomatoPlant.yield(new Tomato()); + tomatoPlant.yield(new Tomato()); + cornPlant.yield(new EarOfCorn()); + int actual = testRow.getNumberOfEdibles(); + + //then + Assert.assertEquals(expected, actual); + + } + + @Test (expected = UnsupportedOperationException.class) + public void getTotalEdiblesExceptionTest() { + //given + Crop tomatoPlant = new TomatoPlant(); + Crop cornPlant = new CornPlant(); + tomatoPlant.yield(new Tomato()); + tomatoPlant.yield(new Tomato()); + cornPlant.yield(new EarOfCorn()); + int expected = 3; + + //when + CropRow testRow = new CropRow(); + testRow.add(tomatoPlant); + testRow.add(cornPlant); + tomatoPlant.fertilize(); + cornPlant.fertilize(); + int actual = testRow.getNumberOfEdibles(); + + //then + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/croptests/CropTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/croptests/CropTest.java new file mode 100644 index 00000000..b0cd2f42 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/croptests/CropTest.java @@ -0,0 +1,164 @@ +package com.zipcodewilmington.froilansfarm.croptests; + +import com.zipcodewilmington.froilansfarm.crops.*; +import org.junit.Assert; +import org.junit.Test; + +public class CropTest { + + @Test + public void nullaryConstructorTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + + //when + int actual = tomatoPlant.getNumOfEdiblesYielded(); + + //then + int expected = 0; + Assert.assertEquals(expected, actual); + } + @Test + public void nullaryCornConstructorTest(){ + //given + Crop cornPlant = new CornPlant(); + + //when + int actual = cornPlant.getNumOfEdiblesYielded(); + + //then + int expected = 0; + Assert.assertEquals(expected, actual); + } + + @Test (expected = UnsupportedOperationException.class) + public void countFertilizedFalseTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Tomato tomato = new Tomato(); + int expected = 0; + + //when + tomatoPlant.yield(tomato); + int actual = tomatoPlant.getNumOfEdiblesYielded(); + + //then + Assert.assertEquals(expected, actual); + } + + @Test (expected = UnsupportedOperationException.class) + public void countHarvestFalseTest(){ + //given + Crop cornPlant = new CornPlant(); + EarOfCorn corn = new EarOfCorn(); + + int expected = 0; + + //when + cornPlant.yield(corn); + int actual = cornPlant.getNumberofHarvest(); + + //then + Assert.assertEquals(expected, actual); + } + + @Test (expected = UnsupportedOperationException.class) + public void AvailableToEatTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Tomato tomato = new Tomato(); + int expected = 0; + + //when + tomatoPlant.yield(tomato); + int actual = tomatoPlant.getFoodToEat(); + + //then + Assert.assertEquals(expected, actual); + + } + + @Test + public void countFertilizedTrueTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Tomato tomato = new Tomato(); + int expected = 1; + + //when + tomatoPlant.fertilize(); + tomatoPlant.yield(tomato); + int actual = tomatoPlant.getNumOfEdiblesYielded(); + + //then + Assert.assertEquals(expected, actual); + } + + @Test + public void countHarvestPossibleTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Tomato tomato = new Tomato(); + int expected = 0; + + //when + tomatoPlant.fertilize(); + tomatoPlant.yield(tomato); + int actual = tomatoPlant.getNumberofHarvest(); + + //then + Assert.assertEquals(expected, actual); + } + + @Test + public void postHarvestTest(){ + //given + Crop cornPlant = new CornPlant(); + EarOfCorn corn = new EarOfCorn(); + int expected = 1; + + //when + cornPlant.fertilize(); + cornPlant.yield(corn); + cornPlant.harvest(); + int actual = cornPlant.getNumberofHarvest(); + + //then + Assert.assertEquals(expected, actual); + + } + + @Test + public void AvailableToEatTrueTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Tomato tomato = new Tomato(); + int expected = 1; + + //when + tomatoPlant.fertilize(); //sets fertilized equal to true + tomatoPlant.yield(tomato); //preps for harvest + tomatoPlant.harvest(); //makes food available to eat + int actual = tomatoPlant.getFoodToEat(); + + //then + Assert.assertEquals(expected, actual); + + } + + @Test (expected = UnsupportedOperationException.class) + public void AvailableToEatImpossibleTest(){ + //given + Crop tomatoPlant = new TomatoPlant(); + Tomato tomato = new Tomato(); + int expected = 1; + + //when + tomatoPlant.fertilize(); //sets fertilized equal to true + tomatoPlant.yield(tomato); //preps for harvest + + //then + tomatoPlant.getFoodToEat(); + + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/ChickenCoopTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/ChickenCoopTest.java new file mode 100644 index 00000000..35b44873 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/ChickenCoopTest.java @@ -0,0 +1,92 @@ +package com.zipcodewilmington.froilansfarm.testStorage; + + +import com.zipcodewilmington.froilansfarm.Animal.Barn; +import com.zipcodewilmington.froilansfarm.Animal.Chicken; +import com.zipcodewilmington.froilansfarm.storage.ChickenCoop; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; +import org.junit.Assert; +import org.junit.Test; + +public class ChickenCoopTest { + + @Test + public void nullaryConstructorTest () { + ChickenCoop cc = new ChickenCoop(); + Integer expected = 0; + + Integer actual = cc.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void instanceOfBarnTest () { + ChickenCoop cc = new ChickenCoop(); + + Assert.assertTrue(cc instanceof Barn); + } + + @Test + public void implementTest () { + ChickenCoop cc = new ChickenCoop(); + + Assert.assertTrue(cc instanceof StorageInterface); + } + + @Test + public void addTest () { + ChickenCoop cc = new ChickenCoop(); + Chicken chicken = new Chicken(); + Integer expected = 1; + + cc.add(chicken); + Integer actual = cc.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void removeTest () { + ChickenCoop cc = new ChickenCoop(); + Chicken chicken = new Chicken(); + Chicken chicken1 = new Chicken(); + Integer expected = 1; + + cc.add(chicken); + cc.add(chicken1); + cc.remove(chicken); + Integer actual = cc.getSize(); + + Assert.assertEquals(expected, actual); + // I return an extra chicken, oops + } + + @Test + public void amountTest () { + ChickenCoop cc = new ChickenCoop(); + Chicken chicken = new Chicken(); + Chicken chicken1 = new Chicken(); + Integer expected = 2; + + cc.add(chicken); + cc.add(chicken1); + Integer actual = cc.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getChickenCoopTest () { + ChickenCoop cc = new ChickenCoop(); + Chicken chicken = new Chicken(); + Chicken chicken1 = new Chicken(); + Integer expected = 2; + + cc.add(chicken); + cc.add(chicken1); + Integer actual = cc.getSize(); + + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/FarmTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/FarmTest.java new file mode 100644 index 00000000..94d4e023 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/FarmTest.java @@ -0,0 +1,96 @@ +package com.zipcodewilmington.froilansfarm.testStorage; + +import com.zipcodewilmington.froilansfarm.Animal.Horse; +import com.zipcodewilmington.froilansfarm.storage.ChickenCoop; +import com.zipcodewilmington.froilansfarm.storage.Farm; +import com.zipcodewilmington.froilansfarm.storage.Stable; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; +import org.junit.Assert; +import org.junit.Test; + +public class FarmTest { + + + @Test + public void addTest () { + Farm farm = new Farm(); + Horse horse = new Horse(); + Horse horse1 = new Horse(); + Integer expected = 2; + + farm.addShelter(horse); + farm.addShelter(horse1); + Integer actual = farm.amountShelter(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void removeTest () { + Farm farm = new Farm(); + Horse horse = new Horse(); + Horse horse1 = new Horse(); + Integer expected = 1; + + farm.addShelter(horse); + farm.addShelter(horse1); + farm.removeShelter(horse1); + Integer actual = farm.amountShelter(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void amountTest () { + Farm farm = new Farm(); + Horse horse = new Horse(); + Horse horse1 = new Horse(); + Integer expected = 2; + + farm.addShelter(horse); + farm.addShelter(horse1); + Integer actual = farm.amountShelter(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getAmountOfCoopsTest () { + Farm farm = new Farm(); + ChickenCoop chicken = new ChickenCoop(); + ChickenCoop chicken1 = new ChickenCoop(); + Stable stable = new Stable(); + Stable stable1 = new Stable(); + Stable stable2 = new Stable(); + Integer expected = 2; + + farm.addShelter(chicken); + farm.addShelter(chicken1); + farm.addShelter(stable); + farm.addShelter(stable1); + farm.addShelter(stable2); + Integer actual = farm.getAmountofCoops(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getAmountOfStableTest () { + Farm farm = new Farm(); + ChickenCoop chicken = new ChickenCoop(); + ChickenCoop chicken1 = new ChickenCoop(); + Stable stable = new Stable(); + Stable stable1 = new Stable(); + Stable stable2 = new Stable(); + Integer expected = 3; + + farm.addShelter(chicken); + farm.addShelter(chicken1); + farm.addShelter(stable); + farm.addShelter(stable1); + farm.addShelter(stable2); + Integer actual = farm.getAmountofStable(); + + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/FieldTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/FieldTest.java new file mode 100644 index 00000000..6901818a --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/FieldTest.java @@ -0,0 +1,70 @@ +package com.zipcodewilmington.froilansfarm.testStorage; + +import com.zipcodewilmington.froilansfarm.crops.CropRow; +import com.zipcodewilmington.froilansfarm.storage.Field; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; +import org.junit.Assert; +import org.junit.Test; + +public class FieldTest { + + @Test + public void implementationTest() { + Field field = new Field(); + Assert.assertTrue(field instanceof StorageInterface); + } + + @Test + public void addTest() { + Field field = new Field(); + CropRow cr = new CropRow(); + CropRow cr2 = new CropRow(); + Integer expected = 2; + + field.add(cr); + field.add(cr2); + Integer actual = field.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void removeTest() { + Field field = new Field(); + CropRow cr = new CropRow(); + CropRow cr2 = new CropRow(); + Integer expected = 1; + + field.add(cr); + field.add(cr2); + field.remove(cr); + Integer actual = field.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getAmountTest() { + Field field = new Field(); + CropRow cr = new CropRow(); + CropRow cr2 = new CropRow(); + Integer expected = 1; + + field.add(cr); + field.add(cr2); + field.remove(cr); + Integer actual = field.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getListTest () { + Field field = new Field(); + Integer expected = 0; + + Integer actual = field.getSize(); + + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/StableTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/StableTest.java new file mode 100644 index 00000000..ffc555ee --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/testStorage/StableTest.java @@ -0,0 +1,69 @@ +package com.zipcodewilmington.froilansfarm.testStorage; + + +import com.zipcodewilmington.froilansfarm.Animal.Barn; +import com.zipcodewilmington.froilansfarm.Animal.Horse; +import com.zipcodewilmington.froilansfarm.storage.Stable; +import com.zipcodewilmington.froilansfarm.storage.StorageInterface; +import org.junit.Assert; +import org.junit.Test; + +public class StableTest { + + @Test + public void implementationTest() { + Stable stable = new Stable(); + Assert.assertTrue(stable instanceof StorageInterface); + } + + @Test + public void instanceOfBarn () { + Stable stable = new Stable(); + + Assert.assertTrue(stable instanceof Barn); + } + + @Test + public void addTest() { + Stable stable = new Stable(); + Horse horse = new Horse(); + Horse horse1 = new Horse(); + Integer expected = 2; + + stable.add(horse); + stable.add(horse1); + Integer actual = stable.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void removeTest() { + Stable stable = new Stable(); + Horse horse = new Horse(); + Horse horse1 = new Horse(); + Integer expected = 1; + + stable.add(horse); + stable.add(horse1); + stable.remove(horse); + Integer actual = stable.getSize(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getListOfHorsesTest() { + Stable stable = new Stable(); + Horse horse = new Horse(); + Horse horse1 = new Horse(); + Integer expected = 1; + + stable.add(horse); + stable.add(horse1); + stable.remove(horse); + Integer actual = stable.getSize(); + + Assert.assertEquals(expected, actual); + } +}