Browse Source

sunday tests complete

mpierse 6 years ago
parent
commit
b8134907f8

+ 4
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Freelan.java View File

@@ -10,12 +10,15 @@ import com.zipcodewilmington.froilansfarm.PlantsAndCrops.TomatoPlant;
10 10
 
11 11
 public class Freelan extends Person implements Botanist {
12 12
 
13
-    public void plant(Crop type, int numToPlant){
13
+    public void plantNewRow(Crop type, int numToPlant){
14 14
         Field field = new Field();
15 15
         CropRow row = new CropRow(type, numToPlant);
16 16
         field.addToField(row);
17 17
     }
18 18
 
19
+    public void plant(CropRow row, int numberPlanted){
20
+        row.setNumberPlanted(numberPlanted);}
21
+
19 22
     public void collectYeild(int numToStore, Edible foodType) {
20 23
         foodType.foodIsAdded(numToStore);
21 24
     }

+ 4
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Froilan.java View File

@@ -8,12 +8,15 @@ import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
8 8
 
9 9
 public class Froilan extends Person implements Botanist {
10 10
 
11
-    public void plant(Crop type, int numToPlant){
11
+    public void plantNewRow(Crop type, int numToPlant){
12 12
         Field field = new Field();
13 13
         CropRow row = new CropRow(type, numToPlant);
14 14
         field.addToField(row);
15 15
     }
16 16
 
17
+    public void plant(CropRow row, int numberPlanted){
18
+        row.setNumberPlanted(numberPlanted);}
19
+
17 20
     public void collectYeild(int numToStore, Edible foodType) {
18 21
         foodType.foodIsAdded(numToStore);
19 22
     }

+ 0
- 5
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java View File

@@ -30,11 +30,6 @@ public class Horse extends Amimal {
30 30
                 result += "Horse number " + i + " has been ridden today. \n";
31 31
             }
32 32
         }
33
-
34
-        return result;
35
-    }
36
-
37
-    public String getRideResult() {
38 33
         return result;
39 34
     }
40 35
 }

+ 55
- 11
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java View File

@@ -14,15 +14,15 @@ public class Farm  {
14 14
     private Field field = new Field();
15 15
     private CornStalk cornStalk = new CornStalk();
16 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);
17
+    private CropRow row1 = new CropRow(cornStalk, 0);
18
+    private CropRow row2 = new CropRow(tomatoPlant, 0);
19
+    private CropRow row3 = new CropRow(cornStalk, 0);
20
+    private CropRow row4 = new CropRow(cornStalk,0);
21
+    private CropRow row5 = new CropRow(0);
22 22
     private FarmHouse house = new FarmHouse();
23
-    private Person froilan = new Froilan();
24
-    private Person freelan = new Freelan();
25
-    private Person froilanda = new Froilanda();
23
+    private Froilan froilan = new Froilan();
24
+    private Freelan freelan = new Freelan();
25
+    private Froilanda froilanda = new Froilanda();
26 26
     private ChickenCoop coop1 = new ChickenCoop(4);
27 27
     private ChickenCoop coop2 = new ChickenCoop(4);
28 28
     private ChickenCoop coop3 = new ChickenCoop(4);
@@ -41,10 +41,18 @@ public class Farm  {
41 41
     public Horse getHorse() {
42 42
         return horse;
43 43
     }
44
-    public Person getFroilan(){
44
+    public Froilan getFroilan(){
45 45
         return froilan;
46 46
     }
47 47
 
48
+    public Freelan getFreelan() {
49
+        return freelan;
50
+    }
51
+
52
+    public Froilanda getFroilanda() {
53
+        return froilanda;
54
+    }
55
+
48 56
     public CornEar getCorn() {
49 57
         return corn;
50 58
     }
@@ -53,6 +61,42 @@ public class Farm  {
53 61
         return tomato;
54 62
     }
55 63
 
64
+    public Stable getStable1() {
65
+        return stable1;
66
+    }
67
+
68
+    public Stable getStable2() {
69
+        return stable2;
70
+    }
71
+
72
+    public Stable getStable3() {
73
+        return stable3;
74
+    }
75
+
76
+    public Egg getEgg() {
77
+        return egg;
78
+    }
79
+
80
+    public CropRow getRow5() {
81
+        return row5;
82
+    }
83
+
84
+    public CropRow getRow4() {
85
+        return row4;
86
+    }
87
+
88
+    public CropRow getRow3() {
89
+        return row3;
90
+    }
91
+
92
+    public CropRow getRow2() {
93
+        return row2;
94
+    }
95
+
96
+    public CropRow getRow1() {
97
+        return row1;
98
+    }
99
+
56 100
     public void populateFarm(){
57 101
         house.addToFarmHpuse(froilan);
58 102
         house.addToFarmHpuse(froilanda);
@@ -60,8 +104,8 @@ public class Farm  {
60 104
         field.addToField(row1);
61 105
         field.addToField(row2);
62 106
         field.addToField(row3);
63
-        field.addToField(row4);
64
-        field.addToField(row5);
107
+      //  field.addToField(row4);
108
+      //  field.addToField(row5);
65 109
     }
66 110
 
67 111
     public void morningRoutine(){

+ 5
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Botanist.java View File

@@ -1,7 +1,11 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
4
+
3 5
 public interface Botanist {
4 6
 
5
-    void plant(Crop type, int numToPlant);
7
+    void plantNewRow(Crop type, int numToPlant);
8
+
9
+    void plant(CropRow row, int numberPlanted);
6 10
 
7 11
 }

+ 40
- 14
src/test/java/com/zipcodewilmington/froilansfarm/SundayTest.java View File

@@ -12,6 +12,7 @@ public class SundayTest {
12 12
     Farm farm = new Farm();;
13 13
   private int cornFirstCount;
14 14
  private int tomatoFirstCount;
15
+ private int eggFirstCount;
15 16
 
16 17
 
17 18
     @Before
@@ -19,6 +20,7 @@ public class SundayTest {
19 20
         farm = new Farm();
20 21
        cornFirstCount = farm.getCorn().getFoodCount();
21 22
       tomatoFirstCount = farm.getTomato().getFoodCount();
23
+      eggFirstCount = farm.getEgg().getFoodCount();
22 24
         farm.populateFarm();
23 25
       farm.morningRoutine();
24 26
 
@@ -27,36 +29,60 @@ public class SundayTest {
27 29
 
28 30
     @Test
29 31
     public void horseRidetest(){
30
-
31
-       // farm.populateFarm();
32
-        //farm.morningRoutine();
33
-        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";
34
-        String actual = farm.getHorse().getRideResult();
32
+        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 1 has been ridden today. \nHorse number 2 has been ridden today. \nHorse number 3 has been ridden today. \nHorse number 1 has been ridden today. \nHorse number 2 has been ridden today. \nHorse number 3 has been ridden today. \n";
33
+        String actual = farm.getHorse().ride(farm.getFroilan(), farm.getStable1())+farm.getHorse().ride(farm.getFroilan(), farm.getStable2()) +farm.getHorse().ride(farm.getFroilan(), farm.getStable3());
35 34
         Assert.assertEquals(expected, actual);
36 35
     }
37
-
38 36
     @Test
39 37
     public void cornEatTest(){
40
-
41
-      //  int cornFirstCount = farm.getCorn().getFoodCount();
42
-       // farm.populateFarm();
43
-       // farm.morningRoutine();
44 38
         int secondCount = farm.getCorn().getFoodCount();
45 39
         int expected = 30;
46 40
         int actual = cornFirstCount-secondCount;
47 41
         Assert.assertEquals(expected, actual);
48 42
     }
43
+
49 44
     @Test
50
-    public void tomatoEatTest(){
45
+    public void isHorseHappy(){
46
+        String actual = farm.getHorse().makeNoise();
47
+        String expected = "NEIGH!";
48
+        Assert.assertEquals(expected, actual);
51 49
 
52
-      //  int tomatoFirstCount = farm.getTomato().getFoodCount();
53
-      // farm.populateFarm();
54
-      //  farm.morningRoutine();
50
+    }
51
+    @Test
52
+    public void tomatoEatTest(){
55 53
         int secondCount = farm.getTomato().getFoodCount();
56 54
         int expected = 6;
57 55
         int actual = tomatoFirstCount-secondCount;
58 56
         Assert.assertEquals(expected, actual);
59 57
     }
58
+    @Test
59
+    public void eggEatTest(){
60
+        int secondCount = farm.getEgg().getFoodCount();
61
+        int expected = 9;
62
+        int actual = eggFirstCount-secondCount;
63
+        Assert.assertEquals(expected, actual);
64
+    }
60 65
 
66
+    @Test
67
+    public void plantRow1Test(){
68
+        farm.getFroilan().plant(farm.getRow1(),40);
69
+        int actual = farm.getRow1().getNumberPlanted();
70
+        int expected = 40;
71
+        Assert.assertEquals(expected, actual);
72
+    }
61 73
 
74
+    @Test
75
+    public void plantRow2Test(){
76
+        farm.getFreelan().plant(farm.getRow2(),40);
77
+        int actual = farm.getRow2().getNumberPlanted();
78
+        int expected = 40;
79
+        Assert.assertEquals(expected, actual);
80
+    }
81
+    @Test
82
+    public void plantRow3Test(){
83
+        farm.getFreelan().plant(farm.getRow3(),40);
84
+        int actual = farm.getRow3().getNumberPlanted();
85
+        int expected = 40;
86
+        Assert.assertEquals(expected, actual);
87
+    }
62 88
 }