ソースを参照

completed farm and started tests

mpierse 6 年 前
コミット
fa51d406be
共有38 個のファイルを変更した356 個の追加151 個の削除を含む
  1. 8
    0
      pom.xml
  2. 0
    3
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Amimal.java
  3. 8
    13
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java
  4. 6
    2
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Egg.java
  5. 0
    14
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Farmer.java
  6. 5
    3
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Freelan.java
  7. 12
    2
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Froilan.java
  8. 0
    7
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Hen.java
  9. 6
    6
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java
  10. 0
    7
      src/main/java/com/zipcodewilmington/froilansfarm/Animals/Rooster.java
  11. 2
    0
      src/main/java/com/zipcodewilmington/froilansfarm/Edible.java
  12. 3
    0
      src/main/java/com/zipcodewilmington/froilansfarm/Fertilizer.java
  13. 2
    2
      src/main/java/com/zipcodewilmington/froilansfarm/Harvests.java
  14. 0
    26
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/Barn.java
  15. 14
    2
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/ChickenCoop.java
  16. 15
    5
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/CropRow.java
  17. 84
    0
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java
  18. 17
    1
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/FarmHouse.java
  19. 8
    0
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/Field.java
  20. 4
    4
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/Stable.java
  21. 0
    14
      src/main/java/com/zipcodewilmington/froilansfarm/Holders/Storer.java
  22. 2
    0
      src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java
  23. 7
    0
      src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/ArbitraryCrop.java
  24. 1
    1
      src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Botanist.java
  25. 21
    0
      src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/CornEar.java
  26. 3
    3
      src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Crop.java
  27. 20
    0
      src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Tomato.java
  28. 0
    7
      src/main/java/com/zipcodewilmington/froilansfarm/Produce.java
  29. 4
    2
      src/main/java/com/zipcodewilmington/froilansfarm/Ridable.java
  30. 0
    8
      src/main/java/com/zipcodewilmington/froilansfarm/Storeable.java
  31. 4
    3
      src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Aircraft.java
  32. 19
    1
      src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/CropDuster.java
  33. 0
    4
      src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Flyable.java
  34. 1
    0
      src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Flyer.java
  35. 23
    7
      src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Tractor.java
  36. 4
    4
      src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Vehicle.java
  37. 2
    0
      src/test/java/com/zipcodewilmington/froilansfarm/MainApplicationTest.java
  38. 51
    0
      src/test/java/com/zipcodewilmington/froilansfarm/SundayTest.java

+ 8
- 0
pom.xml ファイルの表示

@@ -7,6 +7,14 @@
7 7
     <groupId>com.zipcodewilmington</groupId>
8 8
     <artifactId>froilans-farm</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>junit</groupId>
13
+            <artifactId>junit</artifactId>
14
+            <version>RELEASE</version>
15
+            <scope>test</scope>
16
+        </dependency>
17
+    </dependencies>
10 18
 
11 19
 
12 20
 </project>

+ 0
- 3
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Amimal.java ファイルの表示

@@ -3,7 +3,6 @@ package com.zipcodewilmington.froilansfarm.Animals;
3 3
 import com.zipcodewilmington.froilansfarm.Eater;
4 4
 import com.zipcodewilmington.froilansfarm.Edible;
5 5
 import com.zipcodewilmington.froilansfarm.NoiseMaker;
6
-import com.zipcodewilmington.froilansfarm.Storeable;
7 6
 
8 7
 public class Amimal implements NoiseMaker, Eater {
9 8
 
@@ -13,8 +12,6 @@ public class Amimal implements NoiseMaker, Eater {
13 12
     }
14 13
 
15 14
     public void eat(Edible food, int numberEaten) {
16
-        if (food.isEdible()) {
17 15
             food.foodIsEaten(numberEaten);
18
-        }
19 16
     }
20 17
 }

+ 8
- 13
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java ファイルの表示

@@ -1,24 +1,19 @@
1 1
 package com.zipcodewilmington.froilansfarm.Animals;
2 2
 
3
-import com.zipcodewilmington.froilansfarm.Animals.Amimal;
4
-import com.zipcodewilmington.froilansfarm.Edible;
5
-import com.zipcodewilmington.froilansfarm.Holders.ChickenCoop;
6
-import com.zipcodewilmington.froilansfarm.Produce;
3
+public class Chicken extends Amimal {
7 4
 
8
-public class Chicken extends Amimal implements Produce {
9
-
10
-    ChickenCoop coop = new ChickenCoop();
11
-    Egg egg = new Egg();
5
+    //ChickenCoop coop = new ChickenCoop();
6
+   // Egg egg = new Egg();
12 7
 
13 8
     public String makeNoise(){
14 9
         return "CLUCK CLUCK!!";
15 10
     }
16 11
 
17 12
     //producing eggs
18
-    public void yeild(){
19
-        if (coop.getIsRooster()== true){ egg.setIsFertilized(true); } else {
20
-            egg.foodIsAdded(1);
21
-        }
22
-    }
13
+//    public void yeild(){
14
+//        if (!coop.getIsRooster()) {
15
+//            egg.foodIsAdded(1);
16
+//        }
17
+//    }
23 18
 
24 19
 }

+ 6
- 2
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Egg.java ファイルの表示

@@ -6,7 +6,7 @@ import com.zipcodewilmington.froilansfarm.Fertilizable;
6 6
 public class Egg implements Edible, Fertilizable {
7 7
 
8 8
 
9
-    private int eggCount = 0;
9
+    private static int eggCount = 30;
10 10
     private boolean isFertilized = false;
11 11
 
12 12
 
@@ -27,6 +27,10 @@ public class Egg implements Edible, Fertilizable {
27 27
     };
28 28
 
29 29
     public void foodIsAdded(int foodAdded){
30
-        eggCount += foodAdded;
30
+        if(isEdible()){eggCount += foodAdded;}
31
+    }
32
+
33
+    public int getFoodCount() {
34
+        return eggCount;
31 35
     }
32 36
 }

+ 0
- 14
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Farmer.java ファイルの表示

@@ -1,14 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm.Animals;
2
-
3
-import com.zipcodewilmington.froilansfarm.Animals.Person;
4
-import com.zipcodewilmington.froilansfarm.Harvests;
5
-import com.zipcodewilmington.froilansfarm.Holders.Storer;
6
-import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Botanist;
7
-import com.zipcodewilmington.froilansfarm.Storeable;
8
-
9
-interface Farmer extends Harvests, Botanist {
10
-
11
-    public void collectYeild(int numToStore, Storer storeBuilding);
12
-
13
-
14
-}

+ 5
- 3
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Freelan.java ファイルの表示

@@ -1,5 +1,6 @@
1 1
 package com.zipcodewilmington.froilansfarm.Animals;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Edible;
3 4
 import com.zipcodewilmington.froilansfarm.Holders.CropRow;
4 5
 import com.zipcodewilmington.froilansfarm.Holders.Field;
5 6
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Botanist;
@@ -7,14 +8,15 @@ import com.zipcodewilmington.froilansfarm.PlantsAndCrops.CornStalk;
7 8
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
8 9
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.TomatoPlant;
9 10
 
10
-public class Freelan extends Person implements Farmer, Botanist {
11
-
12
-
11
+public class Freelan extends Person implements Botanist {
13 12
 
14 13
     public void plant(Crop type, int numToPlant){
15 14
         Field field = new Field();
16 15
         CropRow row = new CropRow(type, numToPlant);
17 16
         field.addToField(row);
17
+    }
18 18
 
19
+    public void collectYeild(int numToStore, Edible foodType) {
20
+        foodType.foodIsAdded(numToStore);
19 21
     }
20 22
 }

+ 12
- 2
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Froilan.java ファイルの表示

@@ -1,10 +1,20 @@
1 1
 package com.zipcodewilmington.froilansfarm.Animals;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Edible;
4
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
5
+import com.zipcodewilmington.froilansfarm.Holders.Field;
3 6
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Botanist;
7
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
4 8
 
5
-public class Froilan extends Person implements Farmer {
9
+public class Froilan extends Person implements Botanist {
6 10
 
7
-    public plant(){
11
+    public void plant(Crop type, int numToPlant){
12
+        Field field = new Field();
13
+        CropRow row = new CropRow(type, numToPlant);
14
+        field.addToField(row);
15
+    }
8 16
 
17
+    public void collectYeild(int numToStore, Edible foodType) {
18
+        foodType.foodIsAdded(numToStore);
9 19
     }
10 20
 }

+ 0
- 7
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Hen.java ファイルの表示

@@ -1,7 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm.Animals;
2
-
3
-import com.zipcodewilmington.froilansfarm.Animals.Chicken;
4
-import com.zipcodewilmington.froilansfarm.Produce;
5
-
6
-public class Hen extends Chicken implements Produce {
7
-}

+ 6
- 6
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java ファイルの表示

@@ -8,22 +8,22 @@ import com.zipcodewilmington.froilansfarm.Rider;
8 8
 
9 9
 public class Horse extends Amimal implements Ridable {
10 10
 
11
-    Stable stable = new Stable(9);
12
-    Rider rider = new Person();
11
+    Stable stable = new Stable(0);
12
+
13 13
 
14 14
     public String makeNoise() {
15 15
         return "NEIGH!";
16 16
     }
17 17
 
18
-    public boolean getIsRideable(){
18
+    public boolean getIsRideable(Person rider){
19 19
         return rider.getIsMounted();
20 20
     }
21 21
 
22
-    public String ride() {
22
+    public String ride(Person rider) {
23 23
         String result = "No riding today";
24
-        if (getIsRideable()) {
24
+        if (getIsRideable(rider)) {
25 25
             result = "";
26
-            for (int i = 0; i < stable.getHorses(); i++) {
26
+            for (int i = 1; i <= stable.getHorses(); i++) {
27 27
                 result += "Horse number " + i + " has been ridden today. \n";
28 28
             }
29 29
         }

+ 0
- 7
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Rooster.java ファイルの表示

@@ -1,7 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm.Animals;
2
-
3
-import com.zipcodewilmington.froilansfarm.Animals.Chicken;
4
-import com.zipcodewilmington.froilansfarm.Fertilizer;
5
-
6
-public class Rooster extends Chicken implements Fertilizer {
7
-}

+ 2
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Edible.java ファイルの表示

@@ -6,4 +6,6 @@ public interface Edible {
6 6
     public void foodIsEaten(int numberEaten);
7 7
 
8 8
     public void foodIsAdded(int foodAdded);
9
+
10
+    public int getFoodCount();
9 11
 }

+ 3
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Fertilizer.java ファイルの表示

@@ -1,4 +1,7 @@
1 1
 package com.zipcodewilmington.froilansfarm;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
4
+
3 5
 public interface Fertilizer {
6
+    void fertilize(Person person);
4 7
 }

+ 2
- 2
src/main/java/com/zipcodewilmington/froilansfarm/Harvests.java ファイルの表示

@@ -1,9 +1,9 @@
1 1
 package com.zipcodewilmington.froilansfarm;
2 2
 
3
-import com.zipcodewilmington.froilansfarm.Holders.Storer;
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
4 4
 
5 5
 public interface Harvests {
6 6
 
7
-    void collectYeild(int numToStore, Storer storeBuilding);
7
+    void collectYeild(int numToStore, Edible foodType, CropRow rowNum);
8 8
 
9 9
 }

+ 0
- 26
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Barn.java ファイルの表示

@@ -1,26 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm.Holders;
2
-
3
-import com.zipcodewilmington.froilansfarm.Edible;
4
-import com.zipcodewilmington.froilansfarm.PlantsAndCrops.CornEar;
5
-import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
6
-import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Tomato;
7
-
8
-public class Barn extends Storer {
9
-
10
-    private int corn = 0;
11
-    private int tomato = 0;
12
-
13
-    public void addToStore(int numToStore) {
14
-        setFarmInventory(numToStore);
15
-    }
16
-
17
-    public void addToStore(int numToStore, Edible cropType) {
18
-        if (cropType instanceof CornEar) {
19
-            corn += numToStore;
20
-        } else if (cropType instanceof Tomato) {
21
-                tomato += numToStore;
22
-            } else {addToStore(numToStore);}
23
-        }
24
-
25
-    }
26
-

+ 14
- 2
src/main/java/com/zipcodewilmington/froilansfarm/Holders/ChickenCoop.java ファイルの表示

@@ -1,8 +1,20 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
-public class ChickenCoop extends Farm {
3
+import com.zipcodewilmington.froilansfarm.Animals.Chicken;
4 4
 
5
-    public boolean rooster = false;
5
+import java.util.ArrayList;
6
+
7
+public class ChickenCoop {
8
+
9
+    private boolean rooster = false;
10
+    private int coopCount = 0;
11
+
12
+    public ChickenCoop(int numOfChickens) {
13
+        this.rooster = getIsRooster();
14
+        this.coopCount = numOfChickens;
15
+    }
16
+
17
+    //public void addToCoop(int numOfChickens){ coopCount += numOfChickens;}
6 18
 
7 19
     public boolean getIsRooster() {
8 20
         return rooster;

+ 15
- 5
src/main/java/com/zipcodewilmington/froilansfarm/Holders/CropRow.java ファイルの表示

@@ -1,23 +1,33 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.ArbitraryCrop;
3 4
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
4 5
 
5 6
 public class CropRow {
6 7
 
7 8
     private int numberPlanted;
8 9
     private Crop cropType;
9
-    private boolean isFertilized = false;
10
+    private Crop arbitrary = new ArbitraryCrop();
10 11
 
11 12
     public CropRow(Crop cropType, int numberPlanted) {
12 13
         this.cropType=cropType;
13 14
         this.numberPlanted=numberPlanted;
14 15
     }
15 16
 
16
-    public boolean getIsFertilized() {
17
-        return isFertilized;
17
+    public CropRow( int numberPlanted) {
18
+        this.cropType= arbitrary;
19
+        this.numberPlanted=numberPlanted;
20
+    }
21
+
22
+    public Crop getCropType() {
23
+        return cropType;
24
+    }
25
+
26
+    public int getNumberPlanted() {
27
+        return numberPlanted;
18 28
     }
19 29
 
20
-    public void setFertilized(boolean fertilized) {
21
-        isFertilized = fertilized;
30
+    public void setNumberPlanted(int numberPlanted) {
31
+        this.numberPlanted = numberPlanted;
22 32
     }
23 33
 }

+ 84
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java ファイルの表示

@@ -1,4 +1,88 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.*;
4
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.CornEar;
5
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.CornStalk;
6
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Tomato;
7
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.TomatoPlant;
8
+import com.zipcodewilmington.froilansfarm.Vehicle.CropDuster;
9
+import com.zipcodewilmington.froilansfarm.Vehicle.Tractor;
10
+
11
+
3 12
 public class Farm  {
13
+
14
+    private Field field = new Field();
15
+    private CornStalk cornStalk = new CornStalk();
16
+    private TomatoPlant tomatoPlant = new TomatoPlant();
17
+    private CropRow row1 = new CropRow(cornStalk, 35);
18
+    private CropRow row2 = new CropRow(tomatoPlant, 35);
19
+    private CropRow row3 = new CropRow(cornStalk, 35);
20
+    private CropRow row4 = new CropRow(cornStalk,35);
21
+    private CropRow row5 = new CropRow(35);
22
+    private FarmHouse house = new FarmHouse();
23
+    private Person froilan = new Froilan();
24
+    private Person freelan = new Freelan();
25
+    private Person froilanda = new Froilanda();
26
+    private ChickenCoop coop1 = new ChickenCoop(4);
27
+    private ChickenCoop coop2 = new ChickenCoop(4);
28
+    private ChickenCoop coop3 = new ChickenCoop(4);
29
+    private ChickenCoop coop4 = new ChickenCoop(4);
30
+    private Stable stable1 = new Stable(0);
31
+    private Stable stable2 = new Stable(0);
32
+    private Stable stable3 = new Stable(0);
33
+    private Tractor tractor1 = new Tractor();
34
+    private Tractor tractor2 = new Tractor();
35
+    private CropDuster cropDuster = new CropDuster();
36
+    private Horse horse = new Horse();
37
+    private CornEar corn = new CornEar();
38
+    private Tomato tomato = new Tomato();
39
+    private Egg egg = new Egg();
40
+
41
+    public Horse getHorse() {
42
+        return horse;
43
+    }
44
+    public Person getFroilan(){
45
+        return froilan;
46
+    }
47
+
48
+    public CornEar getCorn() {
49
+        return corn;
50
+    }
51
+
52
+    public Tomato getTomato() {
53
+        return tomato;
54
+    }
55
+
56
+    public void populateFarm(){
57
+        house.addToFarmHpuse(froilan);
58
+        house.addToFarmHpuse(froilanda);
59
+        house.addToFarmHpuse(freelan);
60
+        field.addToField(row1);
61
+        field.addToField(row2);
62
+        field.addToField(row3);
63
+        field.addToField(row4);
64
+        field.addToField(row5);
65
+        stable1.setHorses(3);
66
+        stable2.setHorses(3);
67
+        stable3.setHorses(3);
68
+    }
69
+
70
+    public void morningRoutine(){
71
+        froilan.setIsMounted();
72
+        horse.ride(froilan);
73
+        for(int i=0; i<stable3.getHorses(); i++) {
74
+            horse.eat(corn, 3);
75
+        }
76
+        froilan.eat(corn, 1);
77
+        froilan.eat(tomato, 2);
78
+        froilan.eat(egg, 5);
79
+        froilanda.eat(corn, 2);
80
+        froilanda.eat(tomato, 1);
81
+        froilanda.eat(egg, 2);
82
+        froilan.eat(tomato, 3);
83
+        froilan.eat(egg, 2);
84
+
85
+    }
86
+
87
+
4 88
 }

+ 17
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/FarmHouse.java ファイルの表示

@@ -1,4 +1,20 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
-public class FarmHouse extends Farm {
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
4
+
5
+import java.util.ArrayList;
6
+
7
+public class FarmHouse {
8
+
9
+    static private ArrayList farmHouse;
10
+
11
+    public FarmHouse() {
12
+
13
+        farmHouse = new ArrayList();
14
+
15
+    }
16
+
17
+    public void addToFarmHpuse(Person person){
18
+        farmHouse.add(person);
19
+    }
4 20
 }

+ 8
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Field.java ファイルの表示

@@ -8,7 +8,15 @@ public class Field {
8 8
 
9 9
     static private Map<Integer, CropRow> fieldMap;
10 10
     private int rowNumber=1;
11
+    private static boolean isFertilized = false;
11 12
 
13
+    public void setFertilized(boolean fertilized) {
14
+        isFertilized = fertilized;
15
+    }
16
+
17
+    public boolean getIsFertilized() {
18
+        return isFertilized;
19
+    }
12 20
 
13 21
     public Field() {
14 22
 

+ 4
- 4
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Stable.java ファイルの表示

@@ -1,11 +1,11 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
-public class Stable extends Farm {
3
+public class Stable {
4 4
 
5
-    private int horses = 0;
5
+    private static int horses = 0;
6 6
 
7 7
     public Stable(int horses) {
8
-        this.horses = horses;
8
+        this.horses += horses;
9 9
     }
10 10
 
11 11
     public int getHorses() {
@@ -13,6 +13,6 @@ public class Stable extends Farm {
13 13
     }
14 14
 
15 15
     public void setHorses(int horses) {
16
-        this.horses = horses;
16
+        this.horses += horses;
17 17
     }
18 18
 }

+ 0
- 14
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Storer.java ファイルの表示

@@ -1,14 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm.Holders;
2
-
3
-import com.zipcodewilmington.froilansfarm.Storeable;
4
-
5
-abstract public class Storer {
6
-
7
-    private int unstoredItemsonFarm=0;
8
-
9
-    public void setFarmInventory(int numberToAdd){
10
-        unstoredItemsonFarm += numberToAdd;
11
-    }
12
-
13
-    abstract void addToStore(int numToStore);
14
-}

+ 2
- 0
src/main/java/com/zipcodewilmington/froilansfarm/MainApplication.java ファイルの表示

@@ -5,4 +5,6 @@ package com.zipcodewilmington.froilansfarm;
5 5
  */
6 6
 public class MainApplication {
7 7
 
8
+
9
+
8 10
 }

+ 7
- 0
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/ArbitraryCrop.java ファイルの表示

@@ -0,0 +1,7 @@
1
+package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2
+
3
+public class ArbitraryCrop extends Crop {
4
+
5
+    public ArbitraryCrop() {
6
+    }
7
+}

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Botanist.java ファイルの表示

@@ -2,6 +2,6 @@ package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3 3
 public interface Botanist {
4 4
 
5
-    void plant();
5
+    void plant(Crop type, int numToPlant);
6 6
 
7 7
 }

+ 21
- 0
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/CornEar.java ファイルの表示

@@ -1,6 +1,27 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3 3
 import com.zipcodewilmington.froilansfarm.Edible;
4
+import com.zipcodewilmington.froilansfarm.Holders.Field;
4 5
 
5 6
 public class CornEar implements Edible {
7
+
8
+    private static int cornCount = 70;
9
+    Field field = new Field();
10
+
11
+    public boolean isEdible() {
12
+        if (field.getIsFertilized()){return true;}
13
+        else {return false;}
14
+    }
15
+
16
+    public void foodIsAdded(int foodAdded) {
17
+        if(isEdible()){cornCount+=foodAdded;}
18
+    }
19
+
20
+    public void foodIsEaten(int numberEaten) {
21
+        cornCount -= numberEaten;
22
+    }
23
+
24
+    public int getFoodCount() {
25
+        return cornCount;
26
+    }
6 27
 }

+ 3
- 3
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Crop.java ファイルの表示

@@ -1,8 +1,8 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3 3
 import com.zipcodewilmington.froilansfarm.Fertilizable;
4
-import com.zipcodewilmington.froilansfarm.Holders.CropRow;
5
-import com.zipcodewilmington.froilansfarm.Produce;
6 4
 
7
-public class Crop extends CropRow implements Produce, Fertilizable {
5
+public class Crop{
6
+
7
+
8 8
 }

+ 20
- 0
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Tomato.java ファイルの表示

@@ -1,6 +1,26 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3 3
 import com.zipcodewilmington.froilansfarm.Edible;
4
+import com.zipcodewilmington.froilansfarm.Holders.Field;
4 5
 
5 6
 public class Tomato implements Edible {
7
+    private static int tomatoCount = 20;
8
+    Field field = new Field();
9
+
10
+    public boolean isEdible() {
11
+        if (field.getIsFertilized()){return true;}
12
+        else {return false;}
13
+    }
14
+
15
+    public void foodIsAdded(int foodAdded) {
16
+        if(isEdible()){tomatoCount+=foodAdded;}
17
+    }
18
+
19
+    public void foodIsEaten(int numberEaten) {
20
+        tomatoCount -= numberEaten;
21
+    }
22
+
23
+    public int getFoodCount() {
24
+        return tomatoCount;
25
+    }
6 26
 }

+ 0
- 7
src/main/java/com/zipcodewilmington/froilansfarm/Produce.java ファイルの表示

@@ -1,7 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm;
2
-
3
-public interface Produce {
4
-
5
-    //adds or subtracts from field yield in classes
6
-    void yeild();
7
-}

+ 4
- 2
src/main/java/com/zipcodewilmington/froilansfarm/Ridable.java ファイルの表示

@@ -1,10 +1,12 @@
1 1
 package com.zipcodewilmington.froilansfarm;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
4
+
3 5
 public interface Ridable {
4 6
 
5
-    boolean getIsRideable();
7
+    boolean getIsRideable(Person person);
6 8
 
7
-    String ride();
9
+    String ride(Person rider);
8 10
 
9 11
 
10 12
 

+ 0
- 8
src/main/java/com/zipcodewilmington/froilansfarm/Storeable.java ファイルの表示

@@ -1,8 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm;
2
-
3
-import com.zipcodewilmington.froilansfarm.Holders.Storer;
4
-
5
-public interface Storeable {
6
-
7
-    void addToStore(Storeable storeType, Storer storeBuilding);
8
-}

+ 4
- 3
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Aircraft.java ファイルの表示

@@ -1,13 +1,14 @@
1 1
 package com.zipcodewilmington.froilansfarm.Vehicle;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
3 4
 import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle;
4 5
 
5 6
 public class Aircraft extends Vehicle {
6 7
 
7
-    @Override
8
-    public String ride(){
8
+
9
+    public String ride(Person person){
9 10
         String result = "No transportation today";
10
-        if(getIsRideable()){
11
+        if(getIsRideable(person)){
11 12
             result = "We're flying!";
12 13
         }
13 14
 

+ 19
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/CropDuster.java ファイルの表示

@@ -1,7 +1,25 @@
1 1
 package com.zipcodewilmington.froilansfarm.Vehicle;
2 2
 
3 3
 
4
+import com.zipcodewilmington.froilansfarm.Animals.Person;
4 5
 import com.zipcodewilmington.froilansfarm.Fertilizer;
6
+import com.zipcodewilmington.froilansfarm.Holders.Field;
5 7
 
6
-public class CropDuster extends Aircraft implements FarmVehicle, Fertilizer, Flyable {
8
+public class CropDuster extends Aircraft implements FarmVehicle, Fertilizer {
9
+
10
+    Field field = new Field();
11
+    public boolean isOnAFarm() {
12
+        return true;
13
+    }
14
+
15
+    @Override
16
+    public boolean getIsRideable(Person person){
17
+        return person.getIsMounted() && person instanceof Flyer;
18
+    }
19
+
20
+
21
+    public void fertilize(Person person){
22
+        if(getIsRideable(person)){
23
+        field.setFertilized(true);}
24
+    }
7 25
 }

+ 0
- 4
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Flyable.java ファイルの表示

@@ -1,4 +0,0 @@
1
-package com.zipcodewilmington.froilansfarm.Vehicle;
2
-
3
-public interface Flyable {
4
-}

+ 1
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Flyer.java ファイルの表示

@@ -1,4 +1,5 @@
1 1
 package com.zipcodewilmington.froilansfarm.Vehicle;
2 2
 
3 3
 public interface Flyer {
4
+
4 5
 }

+ 23
- 7
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Tractor.java ファイルの表示

@@ -1,26 +1,42 @@
1 1
 package com.zipcodewilmington.froilansfarm.Vehicle;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
4
+import com.zipcodewilmington.froilansfarm.Edible;
3 5
 import com.zipcodewilmington.froilansfarm.Harvests;
4
-import com.zipcodewilmington.froilansfarm.Holders.Storer;
6
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
7
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Botanist;
5 8
 
6 9
 public class Tractor extends Vehicle implements Harvests, FarmVehicle {
7 10
 
8
-    public boolean isOnAFarm(){
11
+    private boolean isRiding = false;
12
+
13
+
14
+    public boolean isOnAFarm() {
9 15
         return true;
10 16
     }
11 17
 
12
-    public void collectYeild(int numToStore, Storer storeBuilding) {
13
-
14
-        addToStore(numToStore);
18
+    @Override
19
+    public boolean getIsRideable(Person person){
20
+        return person.getIsMounted() && person instanceof Botanist;
21
+    }
15 22
 
23
+    public void setRiding(boolean riding) {
24
+        isRiding = riding;
16 25
     }
17 26
 
18
-    public String ride(){
27
+    public String ride(Person person){
19 28
         String result = "No transportation today";
20
-        if(getIsRideable()){
29
+        if(getIsRideable(person) && isOnAFarm()){
21 30
             result = "Driving in the field today";
31
+            setRiding(true);
22 32
         }
23 33
 
24 34
         return result;
25 35
     }
36
+
37
+    public void collectYeild(int numToStore, Edible foodType, CropRow rowNum) {
38
+        if(isRiding){
39
+            foodType.foodIsAdded(numToStore);
40
+            rowNum.setNumberPlanted(0);}
41
+    }
26 42
 }

+ 4
- 4
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Vehicle.java ファイルの表示

@@ -6,21 +6,21 @@ import com.zipcodewilmington.froilansfarm.Ridable;
6 6
 
7 7
 public class Vehicle implements Ridable, NoiseMaker {
8 8
 
9
-    Person person = new Person();
9
+
10 10
 
11 11
     public String makeNoise(){
12 12
         return "VROOM VROOM!";
13 13
     }
14 14
 
15 15
 
16
-    public boolean getIsRideable(){
16
+    public boolean getIsRideable(Person person){
17 17
         return person.getIsMounted();
18 18
     }
19 19
 
20 20
 
21
-    public String ride(){
21
+    public String ride(Person person){
22 22
      String result = "No transportation today";
23
-     if(getIsRideable()){
23
+     if(getIsRideable(person)){
24 24
          result = "Moving around on a vehicle";
25 25
      }
26 26
 

+ 2
- 0
src/test/java/com/zipcodewilmington/froilansfarm/MainApplicationTest.java ファイルの表示

@@ -4,4 +4,6 @@ package com.zipcodewilmington.froilansfarm;
4 4
  * Created by leon on 2/26/18.
5 5
  */
6 6
 public class MainApplicationTest {
7
+
8
+
7 9
 }

+ 51
- 0
src/test/java/com/zipcodewilmington/froilansfarm/SundayTest.java ファイルの表示

@@ -0,0 +1,51 @@
1
+package com.zipcodewilmington.froilansfarm;
2
+
3
+import com.zipcodewilmington.froilansfarm.Animals.Horse;
4
+import com.zipcodewilmington.froilansfarm.Holders.Farm;
5
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.CornEar;
6
+import org.junit.Assert;
7
+import org.junit.Before;
8
+import org.junit.Test;
9
+
10
+public class SundayTest {
11
+
12
+    Farm farm;
13
+
14
+    @Before
15
+    public void setup(){
16
+        farm = new Farm();
17
+
18
+    }
19
+
20
+    @Test
21
+    public void cornEatTest(){
22
+    int firstCount = farm.getCorn().getFoodCount();
23
+    farm.populateFarm();
24
+    farm.morningRoutine();
25
+    int secondCount = farm.getCorn().getFoodCount();
26
+    int expected = 30;
27
+    int actual = firstCount-secondCount;
28
+    Assert.assertEquals(expected, actual);
29
+    }
30
+
31
+    @Test
32
+    public void horseRidetest(){
33
+       // farm.populateFarm();
34
+       // farm.morningRoutine();
35
+        String expected = "Horse number 1 has been ridden today. \nHorse number 2 has been ridden today. \nHorse number 3 has been ridden today. \nHorse number 4 has been ridden today. \nHorse number 5 has been ridden today. \nHorse number 6 has been ridden today. \nHorse number 7 has been ridden today. \nHorse number 8 has been ridden today. \nHorse number 9 has been ridden today. \n";
36
+        farm.getFroilan().setIsMounted();
37
+        String actual = farm.getHorse().ride(farm.getFroilan());
38
+        Assert.assertEquals(expected, actual);
39
+    }
40
+    @Test
41
+    public void tomatoEatTest(){
42
+        int firstCount = farm.getTomato().getFoodCount();
43
+       // farm.populateFarm();
44
+        //farm.morningRoutine();
45
+        int secondCount = farm.getTomato().getFoodCount();
46
+        int expected = 6;
47
+        int actual = firstCount-secondCount;
48
+        Assert.assertEquals(expected, actual);
49
+    }
50
+
51
+}