Browse Source

added three tests, one working

mpierse 6 years ago
parent
commit
cdef37dc14

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

9
 public class Horse extends Amimal implements Ridable {
9
 public class Horse extends Amimal implements Ridable {
10
 
10
 
11
     Stable stable = new Stable(0);
11
     Stable stable = new Stable(0);
12
+    private String result;
12
 
13
 
13
 
14
 
14
     public String makeNoise() {
15
     public String makeNoise() {
20
     }
21
     }
21
 
22
 
22
     public String ride(Person rider) {
23
     public String ride(Person rider) {
23
-        String result = "No riding today";
24
+        result = "No riding today";
24
         if (getIsRideable(rider)) {
25
         if (getIsRideable(rider)) {
25
             result = "";
26
             result = "";
26
             for (int i = 1; i <= stable.getHorses(); i++) {
27
             for (int i = 1; i <= stable.getHorses(); i++) {
31
         return result;
32
         return result;
32
     }
33
     }
33
 
34
 
35
+    public String getRideResult() {
36
+        return result;
37
+    }
34
 }
38
 }

+ 3
- 6
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java View File

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);
29
     private ChickenCoop coop4 = 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);
30
+    private Stable stable1 = new Stable(3);
31
+    private Stable stable2 = new Stable(3);
32
+    private Stable stable3 = new Stable(3);
33
     private Tractor tractor1 = new Tractor();
33
     private Tractor tractor1 = new Tractor();
34
     private Tractor tractor2 = new Tractor();
34
     private Tractor tractor2 = new Tractor();
35
     private CropDuster cropDuster = new CropDuster();
35
     private CropDuster cropDuster = new CropDuster();
62
         field.addToField(row3);
62
         field.addToField(row3);
63
         field.addToField(row4);
63
         field.addToField(row4);
64
         field.addToField(row5);
64
         field.addToField(row5);
65
-        stable1.setHorses(3);
66
-        stable2.setHorses(3);
67
-        stable3.setHorses(3);
68
     }
65
     }
69
 
66
 
70
     public void morningRoutine(){
67
     public void morningRoutine(){

+ 24
- 18
src/test/java/com/zipcodewilmington/froilansfarm/SundayTest.java View File

10
 public class SundayTest {
10
 public class SundayTest {
11
 
11
 
12
     Farm farm;
12
     Farm farm;
13
+  //  int cornFirstCount;
14
+  //  int tomatoFirstCount;
15
+
13
 
16
 
14
     @Before
17
     @Before
15
     public void setup(){
18
     public void setup(){
16
         farm = new Farm();
19
         farm = new Farm();
20
+      //  cornFirstCount = farm.getCorn().getFoodCount();
21
+      //  tomatoFirstCount = farm.getTomato().getFoodCount();
22
+        //farm.populateFarm();
23
+      //  farm.morningRoutine();
17
 
24
 
18
     }
25
     }
19
 
26
 
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
 
27
 
31
     @Test
28
     @Test
32
     public void horseRidetest(){
29
     public void horseRidetest(){
33
-       // farm.populateFarm();
34
-       // farm.morningRoutine();
30
+        farm.populateFarm();
31
+        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";
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 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());
33
+        String actual = farm.getHorse().getRideResult();
38
         Assert.assertEquals(expected, actual);
34
         Assert.assertEquals(expected, actual);
39
     }
35
     }
40
     @Test
36
     @Test
41
     public void tomatoEatTest(){
37
     public void tomatoEatTest(){
42
-        int firstCount = farm.getTomato().getFoodCount();
43
-       // farm.populateFarm();
44
-        //farm.morningRoutine();
38
+       int tomatoFirstCount = farm.getTomato().getFoodCount();
39
+       farm.populateFarm();
40
+        farm.morningRoutine();
45
         int secondCount = farm.getTomato().getFoodCount();
41
         int secondCount = farm.getTomato().getFoodCount();
46
         int expected = 6;
42
         int expected = 6;
47
-        int actual = firstCount-secondCount;
43
+        int actual = tomatoFirstCount-secondCount;
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+    @Test
47
+    public void cornEatTest(){
48
+       int cornFirstCount = farm.getCorn().getFoodCount();
49
+        farm.populateFarm();
50
+         farm.morningRoutine();
51
+        int secondCount = farm.getCorn().getFoodCount();
52
+        int expected = 30;
53
+        int actual = cornFirstCount-secondCount;
48
         Assert.assertEquals(expected, actual);
54
         Assert.assertEquals(expected, actual);
49
     }
55
     }
50
 
56