Browse Source

got two tests working

mpierse 6 years ago
parent
commit
4ea82c2708

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

@@ -6,9 +6,9 @@ import com.zipcodewilmington.froilansfarm.Holders.Stable;
6 6
 import com.zipcodewilmington.froilansfarm.Ridable;
7 7
 import com.zipcodewilmington.froilansfarm.Rider;
8 8
 
9
-public class Horse extends Amimal implements Ridable {
9
+public class Horse extends Amimal {
10 10
 
11
-    Stable stable = new Stable(0);
11
+    //Stable stable = new Stable(0);
12 12
     private String result;
13 13
 
14 14
 
@@ -20,7 +20,9 @@ public class Horse extends Amimal implements Ridable {
20 20
         return rider.getIsMounted();
21 21
     }
22 22
 
23
-    public String ride(Person rider) {
23
+
24
+
25
+    public String ride(Person rider, Stable stable) {
24 26
         result = "No riding today";
25 27
         if (getIsRideable(rider)) {
26 28
             result = "";

+ 9
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java View File

@@ -66,7 +66,15 @@ public class Farm  {
66 66
 
67 67
     public void morningRoutine(){
68 68
         froilan.setIsMounted();
69
-        horse.ride(froilan);
69
+        horse.ride(froilan, stable1);
70
+        horse.ride(froilan, stable2);
71
+        horse.ride(froilan, stable3);
72
+        for(int i=0; i<stable1.getHorses(); i++) {
73
+            horse.eat(corn, 3);
74
+        }
75
+        for(int i=0; i<stable2.getHorses(); i++) {
76
+            horse.eat(corn, 3);
77
+        }
70 78
         for(int i=0; i<stable3.getHorses(); i++) {
71 79
             horse.eat(corn, 3);
72 80
         }

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Stable.java View File

@@ -2,7 +2,7 @@ package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3 3
 public class Stable {
4 4
 
5
-    private static int horses = 0;
5
+    private int horses = 0;
6 6
 
7 7
     public Stable(int horses) {
8 8
         this.horses += horses;

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

@@ -5,7 +5,7 @@ import com.zipcodewilmington.froilansfarm.Holders.Field;
5 5
 
6 6
 public class CornEar implements Edible {
7 7
 
8
-    private static int cornCount = 70;
8
+    private int cornCount = 70;
9 9
     Field field = new Field();
10 10
 
11 11
     public boolean isEdible() {

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

@@ -4,7 +4,7 @@ import com.zipcodewilmington.froilansfarm.Edible;
4 4
 import com.zipcodewilmington.froilansfarm.Holders.Field;
5 5
 
6 6
 public class Tomato implements Edible {
7
-    private static int tomatoCount = 20;
7
+    private int tomatoCount = 20;
8 8
     Field field = new Field();
9 9
 
10 10
     public boolean isEdible() {

+ 1
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Ridable.java View File

@@ -1,6 +1,7 @@
1 1
 package com.zipcodewilmington.froilansfarm;
2 2
 
3 3
 import com.zipcodewilmington.froilansfarm.Animals.Person;
4
+import com.zipcodewilmington.froilansfarm.Holders.Stable;
4 5
 
5 6
 public interface Ridable {
6 7
 

+ 27
- 22
src/test/java/com/zipcodewilmington/froilansfarm/SundayTest.java View File

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