mpierse 6 лет назад
Родитель
Сommit
4ea82c2708

+ 5
- 3
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java Просмотреть файл

6
 import com.zipcodewilmington.froilansfarm.Ridable;
6
 import com.zipcodewilmington.froilansfarm.Ridable;
7
 import com.zipcodewilmington.froilansfarm.Rider;
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
     private String result;
12
     private String result;
13
 
13
 
14
 
14
 
20
         return rider.getIsMounted();
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
         result = "No riding today";
26
         result = "No riding today";
25
         if (getIsRideable(rider)) {
27
         if (getIsRideable(rider)) {
26
             result = "";
28
             result = "";

+ 9
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java Просмотреть файл

66
 
66
 
67
     public void morningRoutine(){
67
     public void morningRoutine(){
68
         froilan.setIsMounted();
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
         for(int i=0; i<stable3.getHorses(); i++) {
78
         for(int i=0; i<stable3.getHorses(); i++) {
71
             horse.eat(corn, 3);
79
             horse.eat(corn, 3);
72
         }
80
         }

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Stable.java Просмотреть файл

2
 
2
 
3
 public class Stable {
3
 public class Stable {
4
 
4
 
5
-    private static int horses = 0;
5
+    private int horses = 0;
6
 
6
 
7
     public Stable(int horses) {
7
     public Stable(int horses) {
8
         this.horses += horses;
8
         this.horses += horses;

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/CornEar.java Просмотреть файл

5
 
5
 
6
 public class CornEar implements Edible {
6
 public class CornEar implements Edible {
7
 
7
 
8
-    private static int cornCount = 70;
8
+    private int cornCount = 70;
9
     Field field = new Field();
9
     Field field = new Field();
10
 
10
 
11
     public boolean isEdible() {
11
     public boolean isEdible() {

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Tomato.java Просмотреть файл

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

+ 1
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Ridable.java Просмотреть файл

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

+ 27
- 22
src/test/java/com/zipcodewilmington/froilansfarm/SundayTest.java Просмотреть файл

9
 
9
 
10
 public class SundayTest {
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
     @Before
17
     @Before
18
     public void setup(){
18
     public void setup(){
19
         farm = new Farm();
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
     @Test
28
     @Test
29
     public void horseRidetest(){
29
     public void horseRidetest(){
30
-        farm.populateFarm();
31
-        farm.morningRoutine();
30
+
31
+       // farm.populateFarm();
32
+        //farm.morningRoutine();
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";
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
         String actual = farm.getHorse().getRideResult();
34
         String actual = farm.getHorse().getRideResult();
34
         Assert.assertEquals(expected, actual);
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
     @Test
38
     @Test
47
     public void cornEatTest(){
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
         int secondCount = farm.getCorn().getFoodCount();
44
         int secondCount = farm.getCorn().getFoodCount();
52
         int expected = 30;
45
         int expected = 30;
53
         int actual = cornFirstCount-secondCount;
46
         int actual = cornFirstCount-secondCount;
54
         Assert.assertEquals(expected, actual);
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
 }