diff --git a/Farm.puml b/Farm.puml new file mode 100644 index 00000000..ec6d8d7b --- /dev/null +++ b/Farm.puml @@ -0,0 +1,305 @@ +@startuml +'https://plantuml.com/class-diagram + +abstract class Animal { +eat (EdiblePlant obj) +makeNoise; +} +abstract class FarmVehicle { +operate; +makeNoise; +} +abstract class Aircraft { +fly; +makeNoise; +} + + +interface LivingThing {} +interface HorseFood { +hasBeenFertilized; +hasBeenHarvested; +} +interface ChickenFood { +hasBeenFertilized; +hasBeenHarvested; +} +interface EdiblePlant { +hasBeenFertilized; +hasBeenHarvested; +} +interface Edible{ +hasBeenFertilized; +} +interface Eater { +eat(Edible obj); +} +interface NoiseMaker { +makeNoise; +} +interface Rideable {} +interface Produce { +yield(Edible obj) if hasBeenFertilized; +} +interface Vehicle { +makeNoise; +} +interface Person { +eat(Edible obj); +makeNoise; +} +interface Rider { +mount(Rideable obj) +dismount(Rideable obj) +eat(Edible obj); +makeNoise; +} +interface Botanist { +plant (Crop crop, CropRow row); +eat(Edible obj); +makeNoise; +} +interface DailyRoutine { +mount (Horse horse) +dismount (Horse horse) +feed (Horse horse, int numOfCorn) +} +interface Housing { +store (LivingThing livingThing) +} + + +class Farm { +Collections for houses +} +class Horse { +makeNoise +eat (HorseFood obj) +} +class Chicken { +eat (ChickenFood obj) +makeNoise; +yield(EdibleEgg egg) if hasBeenFertilized == false +} +class EdibleEgg { +hasBeenFertilized; +} +class Field { +store(CropRow); +} +class CropRow { +store(Crop); +} +class Crop { +yield (EdiblePlant obj) if hasBeenFertilized && hasBeenHarvested; +} +class CornStalk { +yield(EarCorn); +} +class EarCorn { +hasBeenFertilized; +hasBeenHarvested; +} +class TomatoPlant { +yield(Tomato); +} +class Tomato { +hasBeenFertilized; +hasBeenHarvested; +} +class BeanStalk { +yield(Soybean soybean) +} +class SoyBean { +hasBeenFertilized; +hasBeenHarvested; +} +class PumpkinVines { +yield(Pumpkin pumpkin) +} +class Pumpkin { +hasBeenFertilized; +hasBeenHarvested; +} +class AppleTrees { +yield (Apple apple) +} +class Apple { +hasBeenFertilized; +hasBeenHarvested; +} +class Tractor { +harvest(Crop crop); +operate; +makeNoise; +} +class CropDuster { +fertilize(CropRow row); +fly; +makeNoise; +} +class Farmer { +mount(Rideable obj) +dismount(Rideable obj) +eat(Edible obj); +makeNoise; +plant (Crop crop, CropRow row); +} +class Pilot { +mount(Rideable obj) +dismount(Rideable obj) +eat(Edible obj); +makeNoise; +Fly (CropDuster duster); +} +class Stable { +store (Horse horse); +} +class FarmHouse { +store (Person person) +} +class ChickenCoop { +store (Chicken) +} +class Moonshine { +distill (Corn corn) +} +class ProduceStand { +addProduce (Produce) +} +class routineEngine { +Monday; +Tuesday; +Wednesday; +Thursday; +Friday; +Saturday; +Sunday; +} + + +'class Monday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'fly (CropDuster duster) +'} +'class Tuesday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'mount(Tractor tractor) +'harvest (Crop crop) +'dismount(Tractor tractor) +'} +'class Wednesday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'distill (Moonshine moonshine) +'} +'class Thursday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'} +'class Friday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'drink (Moonshine moonshine) +'work (ProduceStand produceStand) +'} +'class Saturday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'feed (Chicken chicken) +'} +'class Sunday { +'mount (Horse horse) +'dismount (Horse horse) +'feed (Horse horse, int numOfCorn) +'eat(Edible obj) +'plant (Crop crop, CropRow row) 3-5 +'} + + + +Eater <|-- Animal +NoiseMaker <|-- Animal + +Animal <|-- Horse +Rideable <|-- Horse + +Animal <|-- Chicken +Produce <|-- Chicken + +Person <|-- Rider +Person <|-- Botanist + +Field <|-- CropRow + +NoiseMaker <|--- Vehicle +Rideable <|--- Vehicle + +Vehicle <|--- Aircraft +Vehicle <|--- FarmVehicle + +Produce <|--- Crop + +Crop <|--- CornStalk +Crop <|--- TomatoPlant +Crop <|--- BeanStalk +Crop <|--- PumpkinVines +Crop <|--- AppleTrees + +Edible <|- EdiblePlant +Edible <|--- EdibleEgg + +EdiblePlant <|-- Tomato +EdiblePlant <|--- Pumpkin +EdiblePlant <|-- HorseFood +EdiblePlant <|-- ChickenFood + +HorseFood <|-- EarCorn +HorseFood <|-- Apple + +ChickenFood <|-- SoyBean +ChickenFood <|-- EarCorn + +NoiseMaker <|---- Person +Eater <|---- Person + +FarmVehicle <|-- Tractor +Aircraft <|-- CropDuster + +Botanist <|---- Farmer +Rider <|---- Farmer + +Housing <|-- FarmHouse +Housing <|-- ChickenCoop +Housing <|-- Stable + +Rider <|--- Pilot + +DailyRoutine <|-- routineEngine + +LivingThing <|---- Animal +LivingThing <|---- Person + +'DailyRoutine <|--- Monday +'DailyRoutine <|--- Tuesday +'DailyRoutine <|--- Wednesday +'DailyRoutine <|--- Thursday +'DailyRoutine <|--- Friday +'DailyRoutine <|--- Saturday +'DailyRoutine <|--- Sunday + +@enduml \ No newline at end of file diff --git a/pom.xml b/pom.xml index 69a3b878..403b67d4 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,14 @@ com.zipcodewilmington froilans-farm 1.0-SNAPSHOT + + + junit + junit + 4.12 + test + + \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Animal.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Animal.java new file mode 100644 index 00000000..06f9d049 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Animal.java @@ -0,0 +1,12 @@ +package com.zipcodewilmington.froilansfarm.Animals; + +import com.zipcodewilmington.froilansfarm.Eater; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.LivingThing; +import com.zipcodewilmington.froilansfarm.NoiseMaker; + +public abstract class Animal implements Eater, LivingThing, NoiseMaker { + public String eat(Edible obj) { + return null; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java new file mode 100644 index 00000000..92e53873 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java @@ -0,0 +1,41 @@ +package com.zipcodewilmington.froilansfarm.Animals; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.ChickenFood; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EarCorn; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Egg; +import com.zipcodewilmington.froilansfarm.Produce; + +import java.util.Random; + +public class Chicken extends Animal implements Produce { + private Egg egg = new Egg(); + + public String makeNoise() { + System.out.println("Bok Bok!"); + return "Bok Bok!"; + } + + public Egg yieldProd() { + return egg; + } + + + public String eat(ChickenFood chickyFood) { + System.out.println("Peck Peck"); + return "Peck Peck"; + } + + + + public String eat(Edible obj, int numOfFood) { + System.out.println("Peck Peck"); + return "Peck Peck"; + } + + public int numOfEggs() { + Random randomAmount = new Random(); + return randomAmount.nextInt(5) + 1; + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java b/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java new file mode 100644 index 00000000..bb6f8bfb --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java @@ -0,0 +1,27 @@ +package com.zipcodewilmington.froilansfarm.Animals; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.Persons.Farmer; +import com.zipcodewilmington.froilansfarm.Persons.Rider; +import com.zipcodewilmington.froilansfarm.Rideable; + +public class Horse extends Animal implements Rideable { + Farmer farmer = new Farmer(); + + public String eat(Edible obj, int numOfFood) { + System.out.println("munch munch munch"); + return "munch munch munch"; + } + + public String makeNoise() { + System.out.println("Neeeighhh!"); + return "Neeeighhh!"; + } + + public boolean isMounted(Rider riderObj) { + String mounted = riderObj.mount(this); + if (farmer.mounted) { return true; + } + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Crops/AppleTrees.java b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/AppleTrees.java new file mode 100644 index 00000000..0bb8d243 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/AppleTrees.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.Crops; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; + +public class AppleTrees extends Crop { + Apple apple = new Apple(); + + public Apple yieldProd() { + return apple; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Crops/BeanStalk.java b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/BeanStalk.java new file mode 100644 index 00000000..6af05ba1 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/BeanStalk.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.Crops; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.SoyBean; + +public class BeanStalk extends Crop { + SoyBean soyBean = new SoyBean(); + + public SoyBean yieldProd() { + return soyBean; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Crops/CornStalk.java b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/CornStalk.java new file mode 100644 index 00000000..4f3c909c --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/CornStalk.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.Crops; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.EarCorn; + +public class CornStalk extends Crop { + EarCorn earCorn = new EarCorn(); + + public EarCorn yieldProd() { + return earCorn; + } +} 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..108db3ee --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/Crop.java @@ -0,0 +1,44 @@ +package com.zipcodewilmington.froilansfarm.Crops; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import com.zipcodewilmington.froilansfarm.Produce; + +import java.lang.reflect.Array; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Random; + +public class Crop implements Produce { + + private LinkedHashMap basket; + public boolean isFertilized; + + public Crop() { + LinkedHashMap basket = new LinkedHashMap(); + } + + public boolean getFertilized(){ + return this.isFertilized; + } + + public void setFertilized(boolean fertilized){ + isFertilized = fertilized; + } + + public boolean yield(boolean isFertilized){ + if(isFertilized){ + return true; + } + return false; + } + public int howMuch(){ + Random randomAmount = new Random(); + return randomAmount.nextInt(10) + 1; + } + + public E yieldProd() { + return null; + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Crops/PumpkinVines.java b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/PumpkinVines.java new file mode 100644 index 00000000..08d2e786 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/PumpkinVines.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.Crops; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Pumpkin; + +public class PumpkinVines extends Crop{ + Pumpkin pumpkin = new Pumpkin(); + + public Pumpkin yieldProd() { + return pumpkin; + } +} 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..95433dab --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Crops/TomatoPlant.java @@ -0,0 +1,12 @@ +package com.zipcodewilmington.froilansfarm.Crops; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Tomato; + +public class TomatoPlant extends Crop { + Tomato tomato = new Tomato(); + + + public Tomato yieldProd() { + return tomato; + } +} 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..0aee06ed --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Eater.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; + +public interface Eater { + String eat(Edible obj, int numOfFood); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Apple.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Apple.java new file mode 100644 index 00000000..d4ee6b24 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Apple.java @@ -0,0 +1,16 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public class Apple implements HorseFood{ + + public boolean hasBeenFertilized() { + return false; + } + + public boolean hasBeenHarvested() { + return false; + } + + public String getKeyStr() { + return "Apple"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/ChickenFood.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/ChickenFood.java new file mode 100644 index 00000000..c5221143 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/ChickenFood.java @@ -0,0 +1,5 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public interface ChickenFood extends EdiblePlant{ + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/EarCorn.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/EarCorn.java new file mode 100644 index 00000000..5fb48bf8 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/EarCorn.java @@ -0,0 +1,15 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public class EarCorn implements HorseFood, ChickenFood { + public boolean hasBeenFertilized() { + return false; + } + + public boolean hasBeenHarvested() { + return false; + } + + public String getKeyStr() { + return "EarCorn"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Edible.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Edible.java new file mode 100644 index 00000000..fe57c3a3 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Edible.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public interface Edible { + + boolean hasBeenFertilized(); + + String getKeyStr(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/EdiblePlant.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/EdiblePlant.java new file mode 100644 index 00000000..595dfd9f --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/EdiblePlant.java @@ -0,0 +1,5 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public interface EdiblePlant extends Edible{ + boolean hasBeenHarvested(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Egg.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Egg.java new file mode 100644 index 00000000..928b3a81 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Egg.java @@ -0,0 +1,11 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public class Egg implements Edible{ + public boolean hasBeenFertilized() { + return false; + } + + public String getKeyStr() { + return "Eggs"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/HorseFood.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/HorseFood.java new file mode 100644 index 00000000..b4aa842b --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/HorseFood.java @@ -0,0 +1,5 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public interface HorseFood extends EdiblePlant{ + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Moonshine.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Moonshine.java new file mode 100644 index 00000000..cad3e4d3 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Moonshine.java @@ -0,0 +1,20 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +import java.util.ArrayList; + +public class Moonshine { + + public int numberOfGrowlers = 0; + + public void distill(int numOfGrowl){ + numberOfGrowlers+= numOfGrowl; + } + + public void removeGrowler(int growler){ + numberOfGrowlers -= growler; + } + + public int getNumberOfGrowlers(){ + return numberOfGrowlers; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Pumpkin.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Pumpkin.java new file mode 100644 index 00000000..29e930ad --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Pumpkin.java @@ -0,0 +1,15 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public class Pumpkin implements EdiblePlant{ + public boolean hasBeenFertilized() { + return false; + } + + public boolean hasBeenHarvested() { + return false; + } + + public String getKeyStr() { + return "Pumpkin"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/SoyBean.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/SoyBean.java new file mode 100644 index 00000000..bb3cc3e2 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/SoyBean.java @@ -0,0 +1,21 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public class SoyBean implements ChickenFood{ + public int numOfSoyBeans; + + public boolean hasBeenFertilized() { + return false; + } + + public boolean hasBeenHarvested() { + return false; + } + + public void setNumOfSoyBeans(int num) { + numOfSoyBeans = num; + } + + public String getKeyStr() { + return "Soy Bean"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Tomato.java b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Tomato.java new file mode 100644 index 00000000..9d6e9e98 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/EdiblePackage/Tomato.java @@ -0,0 +1,15 @@ +package com.zipcodewilmington.froilansfarm.EdiblePackage; + +public class Tomato implements EdiblePlant{ + public boolean hasBeenFertilized() { + return false; + } + + public boolean hasBeenHarvested() { + return false; + } + + public String getKeyStr() { + return "Tomato"; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/ChickenCoop.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/ChickenCoop.java new file mode 100644 index 00000000..f69fbf3b --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/ChickenCoop.java @@ -0,0 +1,35 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; + +import java.util.ArrayList; + +public class ChickenCoop extends Housing{ + ArrayList coop = new ArrayList(); + + public ChickenCoop() {} + + public ChickenCoop(int numOfChickens, Chicken chicken) { + for (int i = 0; i < numOfChickens; i++) { + store(chicken); + } + } + + public void killChicken(Chicken dinner) { + coop.remove(dinner); + } + + @Override + public void store(Chicken chicken) { + coop.add(chicken); + } + + @Override + public int size() { + return coop.size(); + } + + public ArrayList getCoop() { + return this.coop; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/CropRow.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/CropRow.java new file mode 100644 index 00000000..af224cdd --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/CropRow.java @@ -0,0 +1,46 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Crops.Crop; + +import java.util.ArrayList; + + +public class CropRow { + public ArrayList row; + + public CropRow() { + row = new ArrayList(); + } + + public CropRow(int numOfCrop, E crop) { + row = new ArrayList(); + for (int i = 0; i < numOfCrop; i++) { + plantCrops(crop); + } + } + + public void plantCrops(E crop) { + row.add(crop); + } + + public int harvestCrop(E crop) { + int numOfCrops = crop.howMuch(); + row.remove(crop); + return numOfCrops; + } + + + public int cropsPerRow() { + return row.size(); + } + + public Crop cropType (int num) { + return row.get(num); + } + + public void add (E crop, int numOfCrops) { + for (int i = 0; i < numOfCrops; i++) { + row.add(crop); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Farm.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Farm.java new file mode 100644 index 00000000..6fcd76fe --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Farm.java @@ -0,0 +1,27 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.Crops.Crop; + +import java.util.ArrayList; + +public class Farm { + CropRow row = new CropRow(); + Chicken chicken = new Chicken(); + Horse horse = new Horse(); + public Field field = new Field(5, row); + + public ChickenCoop coopOne = new ChickenCoop(4, chicken); + public ChickenCoop coopTwo = new ChickenCoop(4, chicken); + public ChickenCoop coopThree = new ChickenCoop(3, chicken); + public ChickenCoop coopFour = new ChickenCoop(4, chicken); + + public Stable stableOne = new Stable(4, horse); + public Stable stableTwo = new Stable(3, horse); + public Stable stableThree = new Stable(3, horse); + + public Field getField() { + return field; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/FarmHouse.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/FarmHouse.java new file mode 100644 index 00000000..e6911f3a --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/FarmHouse.java @@ -0,0 +1,31 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Persons.Person; + +import java.util.ArrayList; + +public class FarmHouse extends Housing { + ArrayList house = new ArrayList(); + + public FarmHouse() {} + + public FarmHouse(int numOfPeople, Person person) { + for (int i = 0; i < numOfPeople; i++) { + store(person); + } + } + + public void movedOut (Person person) { + house.remove(person); + } + + @Override + public void store(Person person) { + house.add(person); + } + + @Override + public int size() { + return house.size(); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Field.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Field.java new file mode 100644 index 00000000..0a8b9242 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Field.java @@ -0,0 +1,72 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Crops.Crop; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class Field { + private static Field field_instance = null; + + CropRow cropRow = new CropRow(); + public LinkedHashMap fieldMap; + + public Field() { + fieldMap = new LinkedHashMap(); + } + + public static Field getInstance() { + if (field_instance == null) { + field_instance = new Field(); + } + return field_instance; + } + + public Field(int numOfRows, CropRow row) { + fieldMap = new LinkedHashMap(); +// for (int i = 1; i <= numOfRows; i++) { +// tillLand(i, row); +// } + } + + public LinkedHashMap getHashMap(){ + return fieldMap; + } + + public void setFieldMap(LinkedHashMap map){ + this.fieldMap = map; + } + + public void tillLand(int rowNum, CropRow row) { + if (!Field.getInstance().getFieldMap().containsKey(rowNum)) { + Field.getInstance().getFieldMap().put(rowNum, row); + } else { + System.out.println("You already have crops there!"); + } + } + + public int fieldSize() { + return Field.getInstance().fieldSize(); + } + + public int harvestRow(int rowNum) { + int numOfVeg = 0; + for (int i = 0; i < fieldMap.get(rowNum).cropsPerRow(); i++) { + numOfVeg += cropRow.harvestCrop(fieldMap.get(rowNum).cropType(i)); + } + return numOfVeg; + } + + public CropRow getCropRow(Integer rowNum) { + return Field.getInstance().fieldMap.get(rowNum); + } + + public LinkedHashMap getFieldMap() { + return this.fieldMap; + } + + public void plantCrops(int key, CropRow row, Crop crop, int numOfCrop) { + Field.getInstance().fieldMap.put(key, row); + Field.getInstance().fieldMap.get(key).row.add(numOfCrop); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Housing.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Housing.java new file mode 100644 index 00000000..45a47dec --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Housing.java @@ -0,0 +1,17 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.LivingThing; + +import java.util.ArrayList; + +public abstract class Housing { + ArrayList livingStorage = new ArrayList(); + + public void store(E creature) { + livingStorage.add(creature); + } + + public int size() { + return livingStorage.size(); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/ProduceStand.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/ProduceStand.java new file mode 100644 index 00000000..f355973b --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/ProduceStand.java @@ -0,0 +1,54 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Crops.Crop; +import com.zipcodewilmington.froilansfarm.EdiblePackage.*; + +import java.security.Key; +import java.util.Arrays; +import java.util.LinkedHashMap; + +public class ProduceStand { + + private static ProduceStand produce_stand = null; + + public LinkedHashMap produceStand; + + private ProduceStand() { + this.produceStand = new LinkedHashMap(); + } + + public static ProduceStand getInstance() { + if (produce_stand == null) { + produce_stand = new ProduceStand(); + } + return produce_stand; + } + + public void addToStand(E produce, int quantity){ + if (produceStand.containsKey(produce)) { + Integer inventory = produceStand.get(produce); + inventory += quantity; + produceStand.put(produce, inventory); + } else { + produceStand.put(produce, quantity); + } + } + + public void sellProduce(E produce, int quantity) { + int currentStock = produceStand.get(produce); + currentStock -= quantity; + produceStand.put(produce, currentStock); + } + + public int produceInventory(E produce) { + return produceStand.get(produce); + } + + public void printMap() { + for (E key : produceStand.keySet()){ + String amount = produceStand.get(key).toString(); + System.out.println(key.getKeyStr() + " " + amount); + } + } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Stable.java b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Stable.java new file mode 100644 index 00000000..f7e49b5d --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Farm/Stable.java @@ -0,0 +1,36 @@ +package com.zipcodewilmington.froilansfarm.Farm; + +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.LivingThing; + +import java.util.ArrayList; + +public class Stable extends Housing{ + ArrayList stable = new ArrayList(); + + public Stable() {} + + public Stable(int numOfHorses, Horse horse) { + for (int i = 0; i < numOfHorses; i++) { + store(horse); + } + } + + public void brokenLeg (Horse horse) { + stable.remove(horse); + } + + public ArrayList getStable() { + return this.stable; + } + + @Override + public int size() { + return stable.size(); + } + + @Override + public void store(Horse horse) { + stable.add(horse); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/LivingThing.java b/src/main/java/com/zipcodewilmington/froilansfarm/LivingThing.java new file mode 100644 index 00000000..e6e05cd6 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/LivingThing.java @@ -0,0 +1,4 @@ +package com.zipcodewilmington.froilansfarm; + +public interface LivingThing { +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java b/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java index fd743ffc..06ad6707 100644 --- a/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java +++ b/src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java @@ -1,8 +1,18 @@ package com.zipcodewilmington.froilansfarm; +import com.zipcodewilmington.froilansfarm.Routines.RoutineEngine; + +import java.util.ArrayList; +import java.util.Comparator; + /** * Created by leon on 2/26/18. */ public class MainApplication { + public static void main(String[] args) { + RoutineEngine farmWeek = new RoutineEngine(); + farmWeek.run(); + } + } 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..ba1f1e20 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/NoiseMaker.java @@ -0,0 +1,5 @@ +package com.zipcodewilmington.froilansfarm; + +public interface NoiseMaker { + String makeNoise(); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Botanist.java b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Botanist.java new file mode 100644 index 00000000..9a977d69 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Botanist.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.Persons; + +import com.zipcodewilmington.froilansfarm.Crops.Crop; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; + +public interface Botanist extends Person { + void plant(int key, Crop crop, CropRow cropRow, int numOfCrop); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Farmer.java b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Farmer.java new file mode 100644 index 00000000..bf3b9de1 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Farmer.java @@ -0,0 +1,91 @@ +package com.zipcodewilmington.froilansfarm.Persons; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.Crops.Crop; +import com.zipcodewilmington.froilansfarm.EdiblePackage.ChickenFood; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.HorseFood; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Moonshine; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import com.zipcodewilmington.froilansfarm.Farm.ProduceStand; +import com.zipcodewilmington.froilansfarm.Rideable; + + +import java.util.LinkedHashMap; + +public class Farmer implements Rider, Botanist, Person { + ProduceStand produceStand = ProduceStand.getInstance(); + LinkedHashMap fieldMap = Field.getInstance().fieldMap; + Moonshine shine = new Moonshine(); + Chicken chicken = new Chicken(); + public String name; + public boolean mounted = false; + + public Farmer() {} + + public Farmer(String name) { + this.name = name; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public String eat(Edible obj, int numOfFood) { + System.out.println("This food is downright edible!"); + return "This food is downright edible!"; + } + + public String makeNoise() { + System.out.println("E-I-E-I-O"); + return "E-I-E-I-O"; + } + + public String mount(Rideable rideableObj) { + System.out.println(this.name + " gets on the " + rideableObj + "."); + mounted = true; + return this.name + " gets on the " + rideableObj + "."; + } + + public String dismount(Rideable obj) { + System.out.println(this.name + " gets off the " + obj + "."); + mounted = false; + return this.name + " gets on the " + obj + "."; + } + + public void plant(int key, Crop crop, CropRow cropRow, int numOfCrop) { + Field.getInstance().plantCrops(key, cropRow, crop, numOfCrop); + } + + public boolean drankShine() { + return true; + } + + public boolean isDrunk(boolean drank){ + shine.removeGrowler(1); + System.out.println("You're not on mute!"); + return true; + } + + public void feedHorse(Horse horse, HorseFood food) { + horse.eat(food); + } + public void feedChicken(Chicken chicken, ChickenFood food) { + chicken.eat(food); + } + + public void workFarmStand() { + System.out.println("Fresh Produce 4 Sale"); + } + + public void getEggs() { + int eggs = chicken.numOfEggs(); + produceStand.addToStand(chicken.yieldProd(), chicken.numOfEggs()); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Person.java b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Person.java new file mode 100644 index 00000000..6222e34f --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Person.java @@ -0,0 +1,14 @@ +package com.zipcodewilmington.froilansfarm.Persons; + +import com.zipcodewilmington.froilansfarm.Eater; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.LivingThing; +import com.zipcodewilmington.froilansfarm.NoiseMaker; + +public interface Person extends LivingThing, Eater, NoiseMaker{ + + boolean drankShine(); + + String eat(Edible obj, int numOfFood); +} + diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Pilot.java b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Pilot.java new file mode 100644 index 00000000..0aadad80 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Pilot.java @@ -0,0 +1,37 @@ +package com.zipcodewilmington.froilansfarm.Persons; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Moonshine; + +import com.zipcodewilmington.froilansfarm.Rideable; + +public class Pilot implements Rider, Person { + Moonshine shine = new Moonshine(); + public String eat(Edible obj, int numOfFood) { + System.out.println("Yum, this food is tasty"); + return "Yum, this food is tasty"; + } + + public String makeNoise() { + System.out.println("Everyone has oceans to fly, if they have the heart to do it. Is it reckless? Maybe. But what do dreams know of boundaries?"); + return "Everyone has oceans to fly, if they have the heart to do it. Is it reckless? Maybe. But what do dreams know of boundaries?"; + } + + public String mount(Rideable obj) { + return null; + } + + public String dismount(Rideable obj) { + return null; + } + + public boolean drankShine() { + return true; + } + + public boolean isDrunk(boolean drank){ + shine.removeGrowler(1); + return true; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Rider.java b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Rider.java new file mode 100644 index 00000000..23793921 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Persons/Rider.java @@ -0,0 +1,9 @@ +package com.zipcodewilmington.froilansfarm.Persons; + +import com.zipcodewilmington.froilansfarm.Rideable; + +public interface Rider extends Person { + String mount(Rideable obj); + String dismount(Rideable obj); + +} 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..d005db44 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Produce.java @@ -0,0 +1,9 @@ +package com.zipcodewilmington.froilansfarm; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; + +public interface Produce { + + E yieldProd(); + +} 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..b4b39e41 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Rideable.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm; + +import com.zipcodewilmington.froilansfarm.Persons.Rider; + +public interface Rideable { + boolean isMounted(Rider obj); +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Routines/DailyRoutine.java b/src/main/java/com/zipcodewilmington/froilansfarm/Routines/DailyRoutine.java new file mode 100644 index 00000000..af115f22 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Routines/DailyRoutine.java @@ -0,0 +1,10 @@ +package com.zipcodewilmington.froilansfarm.Routines; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.EdiblePackage.ChickenFood; +import com.zipcodewilmington.froilansfarm.EdiblePackage.HorseFood; + +public interface DailyRoutine { + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Routines/RoutineEngine.java b/src/main/java/com/zipcodewilmington/froilansfarm/Routines/RoutineEngine.java new file mode 100644 index 00000000..d94f50d6 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Routines/RoutineEngine.java @@ -0,0 +1,153 @@ +package com.zipcodewilmington.froilansfarm.Routines; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.Crops.*; +import com.zipcodewilmington.froilansfarm.EdiblePackage.*; +import com.zipcodewilmington.froilansfarm.Farm.*; +import com.zipcodewilmington.froilansfarm.Persons.Farmer; +import com.zipcodewilmington.froilansfarm.Persons.Pilot; +import com.zipcodewilmington.froilansfarm.Vehicles.CropDuster; +import com.zipcodewilmington.froilansfarm.Vehicles.Tractor; + +public class RoutineEngine{ + Farmer froiland = new Farmer(); + Pilot froilanda = new Pilot(); + Farm farm = new Farm(); + Egg egg = new Egg(); + EarCorn earCorn = new EarCorn(); + Tomato tomato = new Tomato(); + Apple apple = new Apple(); + Pumpkin pumpkin = new Pumpkin(); + SoyBean soyBean = new SoyBean(); + CropDuster cropDuster = new CropDuster(); + Tractor tractor = new Tractor(); + Moonshine moonshine = new Moonshine(); + CornStalk cornStalk = new CornStalk(); + BeanStalk beanStalk = new BeanStalk(); + AppleTrees appleTrees = new AppleTrees(); + PumpkinVines pumpkinVines = new PumpkinVines(); + TomatoPlant tomatoPlant = new TomatoPlant(); + Field oldField = new Field(); + Field field = oldField.getInstance(); + ProduceStand produceStand = ProduceStand.getInstance(); + + + public void dailyRoutine() { + for (Horse horse : farm.stableOne.getStable()){ + froiland.mount(horse); + froiland.dismount(horse); + froiland.feedHorse(horse, apple); + froiland.feedHorse(horse, earCorn); + } + for (Horse horse : farm.stableTwo.getStable()){ + froiland.mount(horse); + froiland.dismount(horse); + froiland.feedHorse(horse, apple); + froiland.feedHorse(horse, earCorn); + } + for (Horse horse : farm.stableThree.getStable()){ + froiland.mount(horse); + froiland.dismount(horse); + froiland.feedHorse(horse, apple); + froiland.feedHorse(horse, earCorn); + } + for (Chicken chicken : farm.coopOne.getCoop()) { + froiland.feedChicken(chicken, earCorn); + froiland.feedChicken(chicken, soyBean); + } + for (Chicken chicken : farm.coopTwo.getCoop()) { + froiland.feedChicken(chicken, earCorn); + froiland.feedChicken(chicken, soyBean); + } + for (Chicken chicken : farm.coopThree.getCoop()) { + froiland.feedChicken(chicken, earCorn); + froiland.feedChicken(chicken, soyBean); + } + for (Chicken chicken : farm.coopFour.getCoop()) { + froiland.feedChicken(chicken, earCorn); + froiland.feedChicken(chicken, soyBean); + } + froiland.eat(egg, 5); + froiland.eat(tomato, 2); + froiland.eat(earCorn, 1); + froilanda.eat(egg, 2); + froilanda.eat(earCorn,2); + froilanda.eat(tomato,1); + } + + public void Monday () { + dailyRoutine(); + froilanda.mount(cropDuster); + cropDuster.fly(); + cropDuster.fertilizeField(); + froilanda.dismount(cropDuster); + } + public void Tuesday () { + dailyRoutine(); + froiland.mount(tractor); + tractor.harvestField(); + produceStand.printMap(); + froiland.dismount(tractor); + } + public void Wednesday () { + dailyRoutine(); + moonshine.distill(4); + } + public void Thursday () { + dailyRoutine(); + for (Chicken chicken : farm.coopOne.getCoop()) { + froiland.getEggs(); + } + for (Chicken chicken : farm.coopTwo.getCoop()) { + froiland.getEggs(); + } + for (Chicken chicken : farm.coopThree.getCoop()) { + froiland.getEggs(); + } + for (Chicken chicken : farm.coopFour.getCoop()) { + froiland.getEggs(); + } + } + public void Friday () { + dailyRoutine(); + // System.out.println(produceStand.produceStand); + produceStand.printMap(); + froiland.workFarmStand(); + froiland.isDrunk(froiland.drankShine()); + froilanda.isDrunk(froilanda.drankShine()); + } + public void Saturday () { + froiland.isDrunk(froiland.drankShine()); + froilanda.isDrunk(froilanda.drankShine()); + dailyRoutine(); + } + public void Sunday () { + dailyRoutine(); + CropRow cropRow = new CropRow(); + field.getInstance().tillLand(1, cropRow); + cropRow.add(appleTrees, 5); + CropRow cropRowTwo = new CropRow(); + field.getInstance().tillLand(2, cropRowTwo); + cropRowTwo.add(cornStalk, 5); + CropRow cropRowThree = new CropRow(); + field.getInstance().tillLand(3, cropRowThree); + cropRowThree.add(beanStalk, 5); + CropRow cropRowFour = new CropRow(); + field.getInstance().tillLand(4, cropRowFour); + cropRowFour.add(tomatoPlant, 5); + CropRow cropRowFive = new CropRow(); + field.getInstance().tillLand(5, cropRowFive); + cropRowFive.add(pumpkinVines, 5); + } + + public void run() { + Sunday(); + Monday(); + Tuesday(); + Wednesday(); + Thursday(); + Friday(); + Saturday(); + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Aircraft.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Aircraft.java new file mode 100644 index 00000000..6d072e34 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Aircraft.java @@ -0,0 +1,13 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Persons.Rider; + +public abstract class Aircraft implements Vehicle { + public String fly() { + return "I am serious... and don't call me Shirley"; + } + + public boolean isMounted(Rider obj) { + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/CropDuster.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/CropDuster.java new file mode 100644 index 00000000..26ab5ae9 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/CropDuster.java @@ -0,0 +1,23 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Crops.Crop; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; + + +public class CropDuster extends Aircraft { + + Field field = Field.getInstance(); + + public String makeNoise() { + return "NnNnNn"; + } + + public void fertilizeField (){ + for (CropRow row : field.fieldMap.values()) { + for (Crop s : row.row) { + s.setFertilized(true); + } + } + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/FarmVehicle.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/FarmVehicle.java new file mode 100644 index 00000000..0e9536fc --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/FarmVehicle.java @@ -0,0 +1,13 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Persons.Rider; + +public abstract class FarmVehicle implements Vehicle { + boolean operate(boolean bool) { + return false; + } + + public boolean isMounted(Rider obj) { + return false; + } +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Tractor.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Tractor.java new file mode 100644 index 00000000..76698053 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Tractor.java @@ -0,0 +1,88 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Crops.Crop; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import com.zipcodewilmington.froilansfarm.Farm.ProduceStand; +import com.zipcodewilmington.froilansfarm.Produce; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class Tractor extends FarmVehicle{ + Field field = Field.getInstance(); + ProduceStand produceStand = ProduceStand.getInstance(); + Crop crop = new Crop(); + private boolean readyToHarvest = false; + + + public String makeNoise() { + return "Clack-Clunk"; + } + +// public void setFieldMap(LinkedHashMap fieldMap){ +// this.fieldMap = fieldMap; +// } + + public boolean getReadyToHarvest(){ + if(crop.isFertilized){ + return true; + } + return false; + } + +// public void harvestRow(int rowNum){ +// CropRow cropRow = field.fieldMap.get(rowNum); +// Integer rowKey = getRowKey(field.fieldMap, cropRow); +// EdiblePlant ePlant = crop.yieldProd(); +// Integer numOfEPlant = field.harvestRow(rowKey); +// produceStand.addToStand(ePlant, numOfEPlant); +// } + + public void harvestField() { + for (CropRow row : field.fieldMap.values()) { + EdiblePlant current = null; + int count = 0; + for (Crop s : row.row) { + current = s.yieldProd(); + count += s.howMuch(); + } + produceStand.addToStand(current, count); +// for (int i = 0; i < field.fieldMap.size(); i++) { +// CropRow row = field.getCropRow(i); +// int count = 0; +// Edible veg = null; +// for (int j = 0; j < row.cropsPerRow(); j++) { +// count += row.row.get(j).howMuch(); +// veg = row.row.get(j).yieldProd(); +// } +// produceStand.addToStand(veg, count); + } + } + + + + public Integer getRowKey(Map map, CropRow value) { + Integer rowKey = null; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue().equals(value)) { + rowKey = entry.getKey(); + } + } + return rowKey; + } + + +// public Integer getRowKey(Map map, CropRow value) { +// int rowKey = 0; +// for (Map.Entry entry : map.entrySet()) { +// if (entry.getValue().equals(value)) { +// rowKey = entry.getKey(); +// } +// } +// return rowKey; +// } + +} diff --git a/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Vehicle.java b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Vehicle.java new file mode 100644 index 00000000..4956e400 --- /dev/null +++ b/src/main/java/com/zipcodewilmington/froilansfarm/Vehicles/Vehicle.java @@ -0,0 +1,7 @@ +package com.zipcodewilmington.froilansfarm.Vehicles; + +import com.zipcodewilmington.froilansfarm.Rideable; + +public interface Vehicle extends Rideable { + String makeNoise(); +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalsTest/ChickenTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalsTest/ChickenTest.java new file mode 100644 index 00000000..28cc5648 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalsTest/ChickenTest.java @@ -0,0 +1,65 @@ +package com.zipcodewilmington.froilansfarm.AnimalsTest; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EarCorn; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Egg; +import org.junit.Assert; +import org.junit.Test; + +public class ChickenTest { + + @Test + public void eatTestEarCorn() { + // Arrange + String expected = "Peck Peck"; + Chicken testChicky = new Chicken(); + EarCorn testCorn = new EarCorn(); + // Act + String returned = testChicky.eat(testCorn); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestEgg() { // Chicken should not be able to eat an egg + // Arrange + String expected = "Peck Peck"; + Chicken testChicky = new Chicken(); + Egg testEgg = new Egg(); + // Act + String returned = testChicky.eat(testEgg); + // Assert + Assert.assertNotEquals(expected, returned); + } + + @Test + public void makeNoiseTest1() { + // Arrange + String expected = "Bok Bok!"; + Chicken testChicky = new Chicken(); + // Act + String returned = testChicky.makeNoise(); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void makeNoiseTest2() { + // Arrange + String expected = "Woof!"; + Chicken testChicky = new Chicken(); + // Act + String returned = testChicky.makeNoise(); + // Assert + Assert.assertNotEquals(expected, returned); + } + + @Test + public void addProduce() { + // Arrange + + // Act + + // Assert + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/AnimalsTest/HorseTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalsTest/HorseTest.java new file mode 100644 index 00000000..d52d6998 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/AnimalsTest/HorseTest.java @@ -0,0 +1,84 @@ +package com.zipcodewilmington.froilansfarm.AnimalsTest; + + +import com.zipcodewilmington.froilansfarm.Animals.Horse; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EarCorn; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Egg; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Tomato; +import org.junit.Assert; +import org.junit.Test; + +public class HorseTest { + + @Test + public void makeNoiseTest1() { + // Arrange + String expected = "Neeeighhh!"; + Horse testHorsey = new Horse(); + // Act + String returned = testHorsey.makeNoise(); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void makeNoiseTest2BokBok() { + // Arrange + String expected = "Bok Bok!"; + Horse testHorsey = new Horse(); + // Act + String returned = testHorsey.makeNoise(); + // Assert + Assert.assertNotEquals(expected, returned); + } + + @Test + public void eatTestEgg() { + // Arrange + String expected = "munch munch munch"; + Horse testHorsey = new Horse(); + Egg testEgg = new Egg(); + // Act + String returned = testHorsey.eat(testEgg); + // Assert + Assert.assertNotEquals(expected, returned); + } + + @Test + public void eatTestEarCorn() { + // Arrange + String expected = "munch munch munch"; + Horse testHorsey = new Horse(); + EarCorn testEarCorn = new EarCorn(); + // Act + String returned = testHorsey.eat(testEarCorn); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestApple() { + // Arrange + String expected = "munch munch munch"; + Horse testHorsey = new Horse(); + Apple testApple = new Apple(); + // Act + String returned = testHorsey.eat(testApple); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestTomato() { + // Arrange + String expected = "munch munch munch"; + Horse testHorsey = new Horse(); + Tomato testTomato = new Tomato(); + // Act + String returned = testHorsey.eat(testTomato); + // Assert + Assert.assertNotEquals(expected, returned); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/ChickenCoopTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/ChickenCoopTest.java new file mode 100644 index 00000000..37427275 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/ChickenCoopTest.java @@ -0,0 +1,74 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.Animals.Chicken; +import com.zipcodewilmington.froilansfarm.Farm.ChickenCoop; +import com.zipcodewilmington.froilansfarm.Farm.Housing; +import org.junit.Assert; +import org.junit.Test; + +public class ChickenCoopTest { + Chicken chicken = new Chicken(); + + @Test + public void coopSizeOne() { + //Given + ChickenCoop chickenCoop = new ChickenCoop(4, chicken); + int expected = 4; + + //When + int actual = chickenCoop.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void coopSizeTwo() { + //Given + ChickenCoop chickenCoop = new ChickenCoop(12, chicken); + int expected = 12; + + //When + int actual = chickenCoop.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void addChickenOne() { + //Given + ChickenCoop chickenCoop = new ChickenCoop(12, chicken); + chickenCoop.store(chicken); + int expected = 13; + + //When + int actual = chickenCoop.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void removeChicken() { + //Given + ChickenCoop chickenCoop = new ChickenCoop(12, chicken); + chickenCoop.killChicken(chicken); + int expected = 11; + + //When + int actual = chickenCoop.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void inheritance() { + //Given + ChickenCoop chickenCoop = new ChickenCoop(); + + //Then + Assert.assertTrue(chickenCoop instanceof Housing); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/CropRowTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/CropRowTest.java new file mode 100644 index 00000000..ac686744 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/CropRowTest.java @@ -0,0 +1,69 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.Crops.BeanStalk; +import com.zipcodewilmington.froilansfarm.Crops.Crop; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import org.junit.Assert; +import org.junit.Test; + +public class CropRowTest { + Crop crop = new Crop(); + Crop bean = new BeanStalk(); + + + @Test + public void rowSize() { + //Given + CropRow row = new CropRow(12, crop); + int expected = 12; + + //When + int actual = row.cropsPerRow(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void addCrop() { + //Given + CropRow row = new CropRow(5, bean); + int expected = 7; + + //When + row.plantCrops(bean); + row.plantCrops(bean); + int actual = row.cropsPerRow(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void removeCrop() { + //Given + CropRow row = new CropRow(2, bean); + row.harvestCrop(bean); + int expected = 1; + + //When + int actual = row.cropsPerRow(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void cropType() { + //Given + CropRow row = new CropRow(3, bean); + + Crop expected = bean; + + //When + Crop actual = row.cropType(1); + + //Then + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FarmHouseTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FarmHouseTest.java new file mode 100644 index 00000000..10d3e0cb --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FarmHouseTest.java @@ -0,0 +1,61 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.Farm.FarmHouse; +import com.zipcodewilmington.froilansfarm.Farm.Housing; +import com.zipcodewilmington.froilansfarm.Persons.Farmer; +import com.zipcodewilmington.froilansfarm.Persons.Person; +import org.junit.Assert; +import org.junit.Test; + +public class FarmHouseTest { + Person person = new Farmer(); + + @Test + public void houseSizeOne() { + //Given + FarmHouse farmHouse = new FarmHouse(3, person); + int expected = 3; + + //When + int actual = farmHouse.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void houseSizeTwo() { + //Given + FarmHouse farmHouse = new FarmHouse(56, person); + int expected = 56; + + //When + int actual = farmHouse.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void removePersonOne() { + //Given + FarmHouse farmHouse = new FarmHouse(4, person); + int expected = 3; + + //When + farmHouse.movedOut(person); + int actual = farmHouse.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void inheritance() { + //Given + FarmHouse farmHouse = new FarmHouse(); + + //Then + Assert.assertTrue(farmHouse instanceof Housing); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FieldRowTests.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FieldRowTests.java new file mode 100644 index 00000000..458b915b --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FieldRowTests.java @@ -0,0 +1,86 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.Crops.BeanStalk; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import org.junit.Assert; +import org.junit.Test; + +public class FieldRowTests { + BeanStalk bean = new BeanStalk(); + CropRow row = new CropRow(5, bean); + CropRow emptyRow = new CropRow(); + + @Test + public void fieldConstructor() { + //Given + Field field = new Field(1, row); + int expected = 1; + + //When + int actual = field.fieldSize(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void fieldConstructorTwo() { + //Given + Field field = new Field(); + field.tillLand(1, emptyRow); + emptyRow.plantCrops(bean); + emptyRow.plantCrops(bean); + emptyRow.plantCrops(bean); + int expected = 3; + + //When + int actual = field.fieldMap.get(1).cropsPerRow(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void harvestRowOne() { + //Given + Field field = new Field(1, row); + field.fieldMap.get(1).plantCrops(bean); + + //When + int actual = field.harvestRow(1); + + //Then + Assert.assertTrue(actual < 50 && actual > 5); + } + + @Test + public void harvestRowTwo() { + //Given + Field field = new Field(); + field.tillLand(1, emptyRow); + field.fieldMap.get(1).plantCrops(bean); + field.fieldMap.get(1).plantCrops(bean); + field.fieldMap.get(1).plantCrops(bean); + + //When + int actual = field.harvestRow(1); + + //Then + Assert.assertTrue(actual > 2 && actual < 34); + } + + @Test + public void tillLand() { + //Given + Field field = new Field(); + field.tillLand(1, emptyRow); + field.tillLand(2, emptyRow); + + //When + int actual = field.fieldSize(); + + //Then + Assert.assertTrue(actual == 2); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FieldTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FieldTest.java new file mode 100644 index 00000000..3ae9922a --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/FieldTest.java @@ -0,0 +1,39 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import org.junit.Assert; +import org.junit.Test; + +public class FieldTest { + CropRow row = new CropRow(); + + @Test + public void fieldSize() { + //Given + Field field = new Field(5, row); + int expected = 5; + + //When + int actual = field.fieldSize(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void addRow() { + //Given + Field field = new Field(); + int expected = 3; + + //When + field.tillLand(1, row); + field.tillLand(2, row); + field.tillLand(3, row); + int actual = field.fieldSize(); + + //Then + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/ProduceStandTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/ProduceStandTest.java new file mode 100644 index 00000000..7921f4f8 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/ProduceStandTest.java @@ -0,0 +1,41 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.SoyBean; +import com.zipcodewilmington.froilansfarm.Farm.ProduceStand; +import org.junit.Assert; +import org.junit.Test; + +public class ProduceStandTest { + SoyBean bean = new SoyBean(); + Apple apple = new Apple(); + + @Test + public void addProduce() { + //Given + ProduceStand produceStand = ProduceStand.getInstance(); + produceStand.addToStand(bean, 7); + int expected = 7; + + //When + int actual = produceStand.produceInventory(bean); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void sellProduce() { + //Given + ProduceStand produceStand = ProduceStand.getInstance(); + produceStand.addToStand(apple, 12); + produceStand.sellProduce(apple, 5); + int expected = 7; + + //When + int actual = produceStand.produceInventory(apple); + + //Then + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/StableTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/StableTest.java new file mode 100644 index 00000000..89e19169 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/HousingTest/StableTest.java @@ -0,0 +1,74 @@ +package com.zipcodewilmington.froilansfarm.HousingTest; + +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.Farm.Housing; +import com.zipcodewilmington.froilansfarm.Farm.Stable; +import org.junit.Assert; +import org.junit.Test; + +public class StableTest { + Horse horse = new Horse(); + + @Test + public void stableSizeOne() { + //Given + Stable stable = new Stable(83, horse); + int expected = 83; + + //When + int actual = stable.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void stableSizeTwo() { + //Given + Stable stable = new Stable(8, horse); + int expected = 8; + + //When + int actual = stable.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void horseDiedOne() { + //Given + Stable stable = new Stable(8, horse); + int expected = 7; + + //When + stable.brokenLeg(horse); + int actual = stable.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void addHorse() { + //Given + Stable stable = new Stable(8, horse); + int expected = 9; + + //When + stable.store(horse); + int actual = stable.size(); + + //Then + Assert.assertEquals(expected, actual); + } + + @Test + public void inheritance() { + //Given + Stable stable = new Stable(); + + //Then + Assert.assertTrue(stable instanceof Housing); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/PersonsTest/FarmerTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/PersonsTest/FarmerTest.java new file mode 100644 index 00000000..33cdc338 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/PersonsTest/FarmerTest.java @@ -0,0 +1,247 @@ +package com.zipcodewilmington.froilansfarm.PersonsTest; + +import com.zipcodewilmington.froilansfarm.Animals.Horse; +import com.zipcodewilmington.froilansfarm.Crops.AppleTrees; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Egg; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Pumpkin; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import com.zipcodewilmington.froilansfarm.Farm.ProduceStand; +import com.zipcodewilmington.froilansfarm.Persons.Farmer; +import org.junit.Assert; +import org.junit.Test; + +public class FarmerTest { + + @Test + public void nulleryContructor1() { + // Arrange + Farmer testFarmer = new Farmer(); + String expectedName = "Sally"; + // Act + testFarmer.setName(expectedName); + String returnedName = testFarmer.getName(); + // Assert + Assert.assertEquals(expectedName, returnedName); + } + + @Test + public void nulleryContructor2() { + // Arrange + Farmer testFarmer = new Farmer(); + String expectedName = "Sally"; + // Act + testFarmer.setName(expectedName); + String returnedName = testFarmer.getName(); + // Assert + Assert.assertNotEquals("Jim-Bob Jr.", returnedName); + } + + @Test + public void ConstructorTestName1() { + // Arrange + String expectedName = "Darrell"; + Farmer testFarmer = new Farmer(expectedName); + // Act + String returnedName = testFarmer.getName(); + // Assert + Assert.assertEquals(expectedName, returnedName); + } + + @Test + public void ConstructorTestName2() { + // Arrange + String expectedName = "Darrell"; + Farmer testFarmer = new Farmer(expectedName); + // Act + String returnedName = testFarmer.getName(); + // Assert + Assert.assertNotEquals("Bobby Joe", returnedName); + } + + @Test + public void setNameTest1() { + // Arrange + String givenName = "Darrell"; + Farmer testFarmer = new Farmer(givenName); + // Act + testFarmer.setName("Dolly"); + String returnedName = testFarmer.getName(); + // Assert + Assert.assertEquals("Dolly", returnedName); + } + + @Test + public void setNameTest2() { + // Arrange + String expectedName = "Darrell"; + Farmer testFarmer = new Farmer(expectedName); + // Act + testFarmer.setName("Dolly"); + String returnedName = testFarmer.getName(); + // Assert + Assert.assertNotEquals("Bobby Joe", returnedName); + } + + @Test + public void getNameTest1() { + // Arrange + String expectedName = "Darrell"; + Farmer testFarmer = new Farmer(expectedName); + // Act + String returnedName = testFarmer.getName(); + // Assert + Assert.assertEquals("Darrell", returnedName); + } + + @Test + public void getNameTest2() { + // Arrange + String expectedName = "Darrell"; + Farmer testFarmer = new Farmer(expectedName); + // Act + String returnedName = testFarmer.getName(); + // Assert + Assert.assertNotEquals("Bobby Joe", returnedName); + } + + @Test + public void makeNoiseTest1() { + // Arrange + String expected = "E-I-E-I-O"; + Farmer testFarmer = new Farmer(); + // Act + String returned = testFarmer.makeNoise(); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void makeNoiseTest2() { + // Arrange + String expected = "I'm on a boat"; + Farmer testFarmer = new Farmer(); + // Act + String returned = testFarmer.makeNoise(); + // Assert + Assert.assertNotEquals(expected, returned); + } + + @Test + public void eatTestEgg() { + // Arrange + String expected = "This food is downright edible!"; + Farmer testFarmer = new Farmer(); + Egg testEgg = new Egg(); + // Act + String returned = testFarmer.eat(testEgg, 2); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestApple() { + // Arrange + String expected = "This food is downright edible!"; + Farmer testFarmer = new Farmer(); + Apple testApple = new Apple(); + // Act + String returned = testFarmer.eat(testApple, 2); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestPumpkin() { + // Arrange + String expected = "This food is downright edible!"; + Farmer testFarmer = new Farmer(); + Pumpkin testPumpkin = new Pumpkin(); + // Act + String returned = testFarmer.eat(testPumpkin, 2); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void mountTest1() { + // Arrange + String expected = "";//this.name + " gets on the " + obj + "."; + Farmer testFarmer = new Farmer("George"); + Horse testHorse = new Horse(); + // Act + String returned = testFarmer.mount(testHorse); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void mountTest2() { + // Arrange + Farmer testFarmer = new Farmer("Geralt"); + Horse testHorse = new Horse(); + String expected = "Geralt" + " gets on the " + testHorse + "."; + // Act + String returned = testFarmer.mount(testHorse); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void dismountTest1() { + // Arrange + + Farmer testFarmer = new Farmer("Geralt"); + Horse testHorse = new Horse(); + // Act + String returned = testFarmer.dismount(testHorse); + String expected = "";//this.name + " gets on the " + obj + "."; + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void dismountTest2() { + // Arrange + + Farmer testFarmer = new Farmer("Geralt"); + Horse testHorse = new Horse(); + // Act + String returned = testFarmer.dismount(testHorse); + String expected = "";//this.name + " gets on the " + obj + "."; + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void plant() { + Field field = new Field(); + CropRow row = new CropRow(); + Farmer farmer = new Farmer(); + AppleTrees appleTrees = new AppleTrees(); + field.tillLand(1, row); + farmer.plant(1, appleTrees, field.getCropRow(1), 5); + int expected = 5; + System.out.println(Field.getInstance().fieldMap); + + int actual = field.getCropRow(1).cropsPerRow(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getEggsTest() { + //Given + ProduceStand produceStand = ProduceStand.getInstance(); + Farmer farmer = new Farmer(); + int expected = 1; + + //When + farmer.getEggs(); + int actual = produceStand.produceStand.size(); + + //Then + Assert.assertEquals(expected, actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/PersonsTest/PilotTest.java b/src/test/java/com/zipcodewilmington/froilansfarm/PersonsTest/PilotTest.java new file mode 100644 index 00000000..a5dd89aa --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/PersonsTest/PilotTest.java @@ -0,0 +1,69 @@ +package com.zipcodewilmington.froilansfarm.PersonsTest; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Egg; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Pumpkin; +import com.zipcodewilmington.froilansfarm.Persons.Pilot; +import org.junit.Assert; +import org.junit.Test; + +public class PilotTest { + + @Test + public void makeNoiseTest1() { + // Arrange + String expected = "Everyone has oceans to fly, if they have the heart to do it. Is it reckless? Maybe. But what do dreams know of boundaries?"; + Pilot testPilot = new Pilot(); + // Act + String returned = testPilot.makeNoise(); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void makeNoiseTest2() { + // Arrange + String expected = "I'm on a boat"; + Pilot testPilot = new Pilot(); + // Act + String returned = testPilot.makeNoise(); + // Assert + Assert.assertNotEquals(expected, returned); + } + + @Test + public void eatTestEgg() { + // Arrange + String expected = "Yum, this food is tasty"; + Pilot testPilot = new Pilot(); + Egg testEgg = new Egg(); + // Act + String returned = testPilot.eat(testEgg, 2); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestApple() { + // Arrange + String expected = "Yum, this food is tasty"; + Pilot testPilot = new Pilot(); + Apple testApple = new Apple(); + // Act + String returned = testPilot.eat(testApple,2 ); + // Assert + Assert.assertEquals(expected, returned); + } + + @Test + public void eatTestPumpkin() { + // Arrange + String expected = "Yum, this food is tasty"; + Pilot testPilot = new Pilot(); + Pumpkin testPumpkin = new Pumpkin(); + // Act + String returned = testPilot.eat(testPumpkin, 2); + // Assert + Assert.assertEquals(expected, returned); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestApple.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestApple.java new file mode 100644 index 00000000..5559ec07 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestApple.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import org.junit.Assert; +import org.junit.Test; + +public class TestApple { + @Test + public void testImplementsEdible(){ + //Arrange + Apple apple = new Apple(); + + //Assertion + Assert.assertTrue(apple instanceof Edible); + } + @Test + public void testImplementsEdiblePlant(){ + //Arrange + Apple apple = new Apple(); + + //Assertion + Assert.assertTrue(apple instanceof EdiblePlant); + } + @Test + public void testHasBeenFertilized(){ + //Arrange + Apple apple = new Apple(); + + //Action + boolean test = apple.hasBeenFertilized(); + + //Assertion + Assert.assertFalse(test); + } + @Test + public void testHasBeenHarvested(){ + //Arrange + Apple apple = new Apple(); + + //Action + boolean test = apple.hasBeenHarvested(); + + //Assertion + Assert.assertFalse(test); + } + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestChickenFood.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestChickenFood.java new file mode 100644 index 00000000..d0cfdf37 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestChickenFood.java @@ -0,0 +1,8 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.ChickenFood; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import org.junit.Assert; + +public class TestChickenFood { +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestEarCorn.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestEarCorn.java new file mode 100644 index 00000000..46d6f9f6 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestEarCorn.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EarCorn; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import org.junit.Assert; +import org.junit.Test; + +public class TestEarCorn { + @Test + public void testImplementsEdible(){ + //Arrange + EarCorn corn = new EarCorn(); + + //Assertion + Assert.assertTrue(corn instanceof Edible); + } + @Test + public void testImplementsEdiblePlant(){ + //Arrange + EarCorn corn = new EarCorn(); + + //Assertion + Assert.assertTrue(corn instanceof EdiblePlant); + } + @Test + public void testHasBeenFertilized(){ + //Arrange + EarCorn corn = new EarCorn(); + + //Action + boolean test = corn.hasBeenFertilized(); + + //Assertion + Assert.assertFalse(test); + } + @Test + public void testHasBeenHarvested(){ + //Arrange + EarCorn corn = new EarCorn(); + + //Action + boolean test = corn.hasBeenHarvested(); + + //Assertion + Assert.assertFalse(test); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestEgg.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestEgg.java new file mode 100644 index 00000000..21349477 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestEgg.java @@ -0,0 +1,30 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Egg; +import org.junit.Assert; +import org.junit.Test; + +public class TestEgg { + @Test + public void testImplementsEdiblePlant(){ + //Arrange + Egg egg = new Egg(); + + //Assertion + Assert.assertTrue(egg instanceof Edible); + } + @Test + public void testHasBeenFertilized(){ + //Arrange + Egg egg = new Egg(); + + //Action + boolean test = egg.hasBeenFertilized(); + + //Assertion + Assert.assertFalse(test); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestMoonshine.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestMoonshine.java new file mode 100644 index 00000000..43d48a63 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestMoonshine.java @@ -0,0 +1,35 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Moonshine; +import org.junit.Assert; +import org.junit.Test; + +public class TestMoonshine { + @Test + public void testDistill(){ + //Arrange + Moonshine moonshine = new Moonshine(); + + //Action + moonshine.distill(3); + int expected = 3; + int actual = moonshine.getNumberOfGrowlers(); + + //Assert + Assert.assertEquals(expected,actual); + } + @Test + public void testRemoveGrowler(){ + //Arrange + Moonshine moonshine = new Moonshine(); + moonshine.distill(3); + + //Action + moonshine.removeGrowler(1); + int expected = 2; + int actual = moonshine.getNumberOfGrowlers(); + + //Assert + Assert.assertEquals(expected,actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestPumpkin.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestPumpkin.java new file mode 100644 index 00000000..f22b2eaa --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestPumpkin.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Pumpkin; +import org.junit.Assert; +import org.junit.Test; + +public class TestPumpkin { + @Test + public void testImplementsEdible(){ + //Arrange + Pumpkin pumpkin = new Pumpkin(); + + //Assertion + Assert.assertTrue(pumpkin instanceof Edible); + } + @Test + public void testImplementsEdiblePlant(){ + //Arrange + Pumpkin pumpkin = new Pumpkin(); + + //Assertion + Assert.assertTrue(pumpkin instanceof EdiblePlant); + } + @Test + public void testHasBeenFertilized(){ + //Arrange + Pumpkin pumpkin = new Pumpkin(); + + //Action + boolean test = pumpkin.hasBeenFertilized(); + + //Assertion + Assert.assertFalse(test); + } + @Test + public void testHasBeenHarvested(){ + //Arrange + Pumpkin pumpkin = new Pumpkin(); + + //Action + boolean test = pumpkin.hasBeenHarvested(); + + //Assertion + Assert.assertFalse(test); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestSoyBean.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestSoyBean.java new file mode 100644 index 00000000..13ba1248 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestSoyBean.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import com.zipcodewilmington.froilansfarm.EdiblePackage.SoyBean; +import org.junit.Assert; +import org.junit.Test; + +public class TestSoyBean { + @Test + public void testImplementsEdible(){ + //Arrange + SoyBean bean = new SoyBean(); + + //Assertion + Assert.assertTrue(bean instanceof Edible); + } + @Test + public void testImplementsEdiblePlant(){ + //Arrange + SoyBean bean = new SoyBean(); + + //Assertion + Assert.assertTrue(bean instanceof EdiblePlant); + } + @Test + public void testHasBeenFertilized(){ + //Arrange + SoyBean bean = new SoyBean(); + + //Action + boolean test = bean.hasBeenFertilized(); + + //Assertion + Assert.assertFalse(test); + } + @Test + public void testHasBeenHarvested(){ + //Arrange + SoyBean bean = new SoyBean() ; + + //Action + boolean test = bean.hasBeenHarvested(); + + //Assertion + Assert.assertFalse(test); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestTomato.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestTomato.java new file mode 100644 index 00000000..d6bd1a6b --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestEdiblesPackage/TestTomato.java @@ -0,0 +1,49 @@ +package com.zipcodewilmington.froilansfarm.TestEdiblesPackage; + +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.EdiblePackage.EdiblePlant; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Tomato; +import org.junit.Assert; +import org.junit.Test; + +public class TestTomato { + @Test + public void testImplementsEdible(){ + //Arrange + Tomato tomato = new Tomato(); + + //Assertion + Assert.assertTrue(tomato instanceof Edible); + } + @Test + public void testImplementsEdiblePlant(){ + //Arrange + Tomato tomato = new Tomato(); + + //Assertion + Assert.assertTrue(tomato instanceof EdiblePlant); + } + @Test + public void testHasBeenFertilized(){ + //Arrange + Tomato tomato = new Tomato(); + + //Action + boolean test = tomato.hasBeenFertilized(); + + //Assertion + Assert.assertFalse(test); + } + @Test + public void testHasBeenHarvested(){ + //Arrange + Tomato tomato = new Tomato(); + + //Action + boolean test = tomato.hasBeenHarvested(); + + //Assertion + Assert.assertFalse(test); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestAirCraft.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestAirCraft.java new file mode 100644 index 00000000..2b3bcb6f --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestAirCraft.java @@ -0,0 +1,10 @@ +package com.zipcodewilmington.froilansfarm.TestVehicles; + +import com.zipcodewilmington.froilansfarm.Vehicles.Aircraft; +import com.zipcodewilmington.froilansfarm.Vehicles.Vehicle; +import org.junit.Assert; +import org.junit.Test; + +public class TestAirCraft { + +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestCropDuster.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestCropDuster.java new file mode 100644 index 00000000..f698b825 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestCropDuster.java @@ -0,0 +1,58 @@ +package com.zipcodewilmington.froilansfarm.TestVehicles; + +import com.zipcodewilmington.froilansfarm.Crops.CornStalk; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import com.zipcodewilmington.froilansfarm.Vehicles.Aircraft; +import com.zipcodewilmington.froilansfarm.Vehicles.CropDuster; +import com.zipcodewilmington.froilansfarm.Vehicles.Vehicle; +import org.junit.Assert; +import org.junit.Test; + +public class TestCropDuster { + @Test + public void testInheritanceAirCraft(){ + //Arrange + CropDuster duster = new CropDuster(); + + //Assertion + Assert.assertTrue(duster instanceof Aircraft); + } + @Test + public void testImplementsVehicle(){ + //Arrange + CropDuster duster = new CropDuster(); + + //Assertion + Assert.assertTrue(duster instanceof Vehicle); + } + @Test + public void testMakeNoise(){ + //Arrange + CropDuster duster = new CropDuster(); + + //Action + String expected = "NnNnNn"; + String actual = duster.makeNoise(); + + //Assertion + Assert.assertEquals(expected,actual); + } + + @Test + public void fertilizedCrops() { + //Given + CropDuster duster = new CropDuster(); + CornStalk cornStalk = new CornStalk(); + Field field = Field.getInstance(); + CropRow cropRow = new CropRow(1, cornStalk); + field.fieldMap.put(1, cropRow); + + //When + duster.fertilizeField(); + boolean actual = cornStalk.getFertilized(); + + //Then + Assert.assertTrue(actual); + } +} diff --git a/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestTractor.java b/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestTractor.java new file mode 100644 index 00000000..fa772128 --- /dev/null +++ b/src/test/java/com/zipcodewilmington/froilansfarm/TestVehicles/TestTractor.java @@ -0,0 +1,66 @@ +package com.zipcodewilmington.froilansfarm.TestVehicles; + +import com.zipcodewilmington.froilansfarm.Crops.AppleTrees; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Apple; +import com.zipcodewilmington.froilansfarm.EdiblePackage.Edible; +import com.zipcodewilmington.froilansfarm.Farm.CropRow; +import com.zipcodewilmington.froilansfarm.Farm.Field; +import com.zipcodewilmington.froilansfarm.Farm.ProduceStand; +import com.zipcodewilmington.froilansfarm.Persons.Farmer; +import com.zipcodewilmington.froilansfarm.Produce; +import com.zipcodewilmington.froilansfarm.Vehicles.*; +import org.junit.Assert; +import org.junit.Test; + +import java.util.LinkedHashMap; + +public class TestTractor { + @Test + public void testInheritanceFarmVehicle(){ + //Arrange + Tractor tractor = new Tractor(); + + //Assertion + Assert.assertTrue(tractor instanceof FarmVehicle); + } + @Test + public void testImplementsVehicle(){ + //Arrange + Tractor tractor = new Tractor(); + + //Assertion + Assert.assertTrue(tractor instanceof Vehicle); + } + @Test + public void testMakeNoise(){ + //Arrange + Tractor tractor = new Tractor();; + + //Action + String expected = "NnNnNn"; + String actual = tractor.makeNoise(); + + //Assertion + Assert.assertEquals(expected,actual); + } + @Test + public void testHarvestRow() { + //Given + Field field = Field.getInstance(); + CropRow row = new CropRow(); + AppleTrees appleTrees = new AppleTrees(); + field.tillLand(1, row); + row.add(appleTrees, 1); + Tractor tractor = new Tractor(); + int expected = 1; + + //When + ProduceStand produceStand = ProduceStand.getInstance(); + tractor.harvestField(); + int output = produceStand.produceStand.size(); + + + //Then + Assert.assertEquals(expected, output); + } +}