Sfoglia il codice sorgente

sunday tests complete

mpierse 6 anni fa
parent
commit
b8134907f8

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

10
 
10
 
11
 public class Freelan extends Person implements Botanist {
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
         Field field = new Field();
14
         Field field = new Field();
15
         CropRow row = new CropRow(type, numToPlant);
15
         CropRow row = new CropRow(type, numToPlant);
16
         field.addToField(row);
16
         field.addToField(row);
17
     }
17
     }
18
 
18
 
19
+    public void plant(CropRow row, int numberPlanted){
20
+        row.setNumberPlanted(numberPlanted);}
21
+
19
     public void collectYeild(int numToStore, Edible foodType) {
22
     public void collectYeild(int numToStore, Edible foodType) {
20
         foodType.foodIsAdded(numToStore);
23
         foodType.foodIsAdded(numToStore);
21
     }
24
     }

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

8
 
8
 
9
 public class Froilan extends Person implements Botanist {
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
         Field field = new Field();
12
         Field field = new Field();
13
         CropRow row = new CropRow(type, numToPlant);
13
         CropRow row = new CropRow(type, numToPlant);
14
         field.addToField(row);
14
         field.addToField(row);
15
     }
15
     }
16
 
16
 
17
+    public void plant(CropRow row, int numberPlanted){
18
+        row.setNumberPlanted(numberPlanted);}
19
+
17
     public void collectYeild(int numToStore, Edible foodType) {
20
     public void collectYeild(int numToStore, Edible foodType) {
18
         foodType.foodIsAdded(numToStore);
21
         foodType.foodIsAdded(numToStore);
19
     }
22
     }

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

30
                 result += "Horse number " + i + " has been ridden today. \n";
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
         return result;
33
         return result;
39
     }
34
     }
40
 }
35
 }

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

14
     private Field field = new Field();
14
     private Field field = new Field();
15
     private CornStalk cornStalk = new CornStalk();
15
     private CornStalk cornStalk = new CornStalk();
16
     private TomatoPlant tomatoPlant = new TomatoPlant();
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
     private FarmHouse house = new FarmHouse();
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
     private ChickenCoop coop1 = new ChickenCoop(4);
26
     private ChickenCoop coop1 = new ChickenCoop(4);
27
     private ChickenCoop coop2 = new ChickenCoop(4);
27
     private ChickenCoop coop2 = new ChickenCoop(4);
28
     private ChickenCoop coop3 = new ChickenCoop(4);
28
     private ChickenCoop coop3 = new ChickenCoop(4);
41
     public Horse getHorse() {
41
     public Horse getHorse() {
42
         return horse;
42
         return horse;
43
     }
43
     }
44
-    public Person getFroilan(){
44
+    public Froilan getFroilan(){
45
         return froilan;
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
     public CornEar getCorn() {
56
     public CornEar getCorn() {
49
         return corn;
57
         return corn;
50
     }
58
     }
53
         return tomato;
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
     public void populateFarm(){
100
     public void populateFarm(){
57
         house.addToFarmHpuse(froilan);
101
         house.addToFarmHpuse(froilan);
58
         house.addToFarmHpuse(froilanda);
102
         house.addToFarmHpuse(froilanda);
60
         field.addToField(row1);
104
         field.addToField(row1);
61
         field.addToField(row2);
105
         field.addToField(row2);
62
         field.addToField(row3);
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
     public void morningRoutine(){
111
     public void morningRoutine(){

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

1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2
 
2
 
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
4
+
3
 public interface Botanist {
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 Vedi File

12
     Farm farm = new Farm();;
12
     Farm farm = new Farm();;
13
   private int cornFirstCount;
13
   private int cornFirstCount;
14
  private int tomatoFirstCount;
14
  private int tomatoFirstCount;
15
+ private int eggFirstCount;
15
 
16
 
16
 
17
 
17
     @Before
18
     @Before
19
         farm = new Farm();
20
         farm = new Farm();
20
        cornFirstCount = farm.getCorn().getFoodCount();
21
        cornFirstCount = farm.getCorn().getFoodCount();
21
       tomatoFirstCount = farm.getTomato().getFoodCount();
22
       tomatoFirstCount = farm.getTomato().getFoodCount();
23
+      eggFirstCount = farm.getEgg().getFoodCount();
22
         farm.populateFarm();
24
         farm.populateFarm();
23
       farm.morningRoutine();
25
       farm.morningRoutine();
24
 
26
 
27
 
29
 
28
     @Test
30
     @Test
29
     public void horseRidetest(){
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
         Assert.assertEquals(expected, actual);
34
         Assert.assertEquals(expected, actual);
36
     }
35
     }
37
-
38
     @Test
36
     @Test
39
     public void cornEatTest(){
37
     public void cornEatTest(){
40
-
41
-      //  int cornFirstCount = farm.getCorn().getFoodCount();
42
-       // farm.populateFarm();
43
-       // farm.morningRoutine();
44
         int secondCount = farm.getCorn().getFoodCount();
38
         int secondCount = farm.getCorn().getFoodCount();
45
         int expected = 30;
39
         int expected = 30;
46
         int actual = cornFirstCount-secondCount;
40
         int actual = cornFirstCount-secondCount;
47
         Assert.assertEquals(expected, actual);
41
         Assert.assertEquals(expected, actual);
48
     }
42
     }
43
+
49
     @Test
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
         int secondCount = farm.getTomato().getFoodCount();
53
         int secondCount = farm.getTomato().getFoodCount();
56
         int expected = 6;
54
         int expected = 6;
57
         int actual = tomatoFirstCount-secondCount;
55
         int actual = tomatoFirstCount-secondCount;
58
         Assert.assertEquals(expected, actual);
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
 }