Kaynağa Gözat

all tests pass 82 percent coverage

mpierse 6 yıl önce
ebeveyn
işleme
83cd6e85b9

+ 4
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Person.java Dosyayı Görüntüle

@@ -12,4 +12,8 @@ public class Person extends Amimal implements Rider {
12 12
     public void setIsMounted(){ isMounted = true;}
13 13
 
14 14
     public void setIsDismounted(){ isMounted = false;}
15
+
16
+    public void collectEggs(Egg egg, int number){
17
+        egg.foodIsAdded(number);
18
+    }
15 19
 }

+ 4
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/ChickenCoop.java Dosyayı Görüntüle

@@ -14,7 +14,10 @@ public class ChickenCoop {
14 14
         this.coopCount = numOfChickens;
15 15
     }
16 16
 
17
-    //public void addToCoop(int numOfChickens){ coopCount += numOfChickens;}
17
+    public int getCoopCount() {
18
+        return coopCount;
19
+    }
20
+//public void addToCoop(int numOfChickens){ coopCount += numOfChickens;}
18 21
 
19 22
     public boolean getIsRooster() {
20 23
         return rooster;

+ 4
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java Dosyayı Görüntüle

@@ -106,6 +106,10 @@ public class Farm  {
106 106
         return cornStalk;
107 107
     }
108 108
 
109
+    public ChickenCoop getCoop1() {
110
+        return coop1;
111
+    }
112
+
109 113
     public void populateFarm(){
110 114
         house.addToFarmHpuse(froilan);
111 115
         house.addToFarmHpuse(froilanda);

+ 29
- 0
src/test/java/com/zipcodewilmington/froilansfarm/SaturdayTest.java Dosyayı Görüntüle

@@ -0,0 +1,29 @@
1
+package com.zipcodewilmington.froilansfarm;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import com.zipcodewilmington.froilansfarm.Holders.Farm;
7
+
8
+public class SaturdayTest {
9
+    Farm farm;
10
+    int eggFirstCount;
11
+
12
+    @Before
13
+    public void setup(){
14
+        farm = new Farm();
15
+        farm.populateFarm();
16
+        farm.morningRoutine();
17
+        eggFirstCount = farm.getEgg().getFoodCount();
18
+    }
19
+
20
+    @Test
21
+    public void collectEggTest(){
22
+        farm.getFroilanda().collectEggs(farm.getEgg(), farm.getCoop1().getCoopCount());
23
+        int secondEggCount = farm.getEgg().getFoodCount();
24
+        int expected = 4;
25
+        int actual = secondEggCount-eggFirstCount;
26
+        Assert.assertEquals(expected,actual);
27
+    }
28
+
29
+}