Bladeren bron

wrote chicken class

mpierse 6 jaren geleden
bovenliggende
commit
44133bdfa0

+ 12
- 4
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java Bestand weergeven

2
 
2
 
3
 import com.zipcodewilmington.froilansfarm.Animals.Amimal;
3
 import com.zipcodewilmington.froilansfarm.Animals.Amimal;
4
 import com.zipcodewilmington.froilansfarm.Edible;
4
 import com.zipcodewilmington.froilansfarm.Edible;
5
+import com.zipcodewilmington.froilansfarm.Holders.ChickenCoop;
6
+import com.zipcodewilmington.froilansfarm.Produce;
5
 
7
 
6
-public class Chicken extends Amimal {
8
+public class Chicken extends Amimal implements Produce {
9
+
10
+    ChickenCoop coop = new ChickenCoop();
11
+    Egg egg = new Egg;
7
 
12
 
8
     public String makeNoise(){
13
     public String makeNoise(){
9
         return "CLUCK CLUCK!!";
14
         return "CLUCK CLUCK!!";
10
     }
15
     }
11
 
16
 
12
-    @Override
13
-    public void eat(Edible food, int numberEaten){
14
-        super.eat(food, numberEaten);
17
+    //producing eggs
18
+    public void yeild(){
19
+        if (coop.getIsRooster()== true){ egg.setIsFertilized(true); } else {
20
+            egg.foodIsAdded(1);
21
+        }
15
     }
22
     }
23
+
16
 }
24
 }

+ 8
- 2
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Egg.java Bestand weergeven

5
 
5
 
6
 public class Egg implements Edible, Fertilizable {
6
 public class Egg implements Edible, Fertilizable {
7
 
7
 
8
+
8
     private int eggCount = 0;
9
     private int eggCount = 0;
10
+    private boolean isFertilized = false;
11
+
9
 
12
 
10
-    public boolean isFertilized() {
13
+    public boolean getisFertilized() {
14
+        return isFertilized;
15
+    }
16
+    public boolean setIsFertilized(boolean rooster) {
11
         //if no roosters in chicken coop that yeilds egg
17
         //if no roosters in chicken coop that yeilds egg
12
-        return false;
18
+        return rooster;
13
     }
19
     }
14
 
20
 
15
     public boolean isEdible(){
21
     public boolean isEdible(){

+ 7
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java Bestand weergeven

1
 package com.zipcodewilmington.froilansfarm.Animals;
1
 package com.zipcodewilmington.froilansfarm.Animals;
2
 
2
 
3
 import com.zipcodewilmington.froilansfarm.Animals.Amimal;
3
 import com.zipcodewilmington.froilansfarm.Animals.Amimal;
4
+import com.zipcodewilmington.froilansfarm.Edible;
4
 import com.zipcodewilmington.froilansfarm.Holders.Stable;
5
 import com.zipcodewilmington.froilansfarm.Holders.Stable;
5
 import com.zipcodewilmington.froilansfarm.Ridable;
6
 import com.zipcodewilmington.froilansfarm.Ridable;
6
 import com.zipcodewilmington.froilansfarm.Rider;
7
 import com.zipcodewilmington.froilansfarm.Rider;
19
     }
20
     }
20
 
21
 
21
     public String ride(){
22
     public String ride(){
23
+        String result = "";
22
         if (isRideable() && rider.getIsMounted())
24
         if (isRideable() && rider.getIsMounted())
23
             for (int i=0; i<stable.getHorses(); i++) {
25
             for (int i=0; i<stable.getHorses(); i++) {
24
-            return "Horse number " + i + " has been ridden today.";
26
+            result += "Horse number " + i + " has been ridden today. \n";
25
         }
27
         }
28
+        return result;
26
     }
29
     }
27
 
30
 
31
+
32
+
33
+
28
 }
34
 }

+ 3
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Produce.java Bestand weergeven

1
 package com.zipcodewilmington.froilansfarm;
1
 package com.zipcodewilmington.froilansfarm;
2
 
2
 
3
 public interface Produce {
3
 public interface Produce {
4
+
5
+    //adds or subtracts from field yield in classes
6
+    void yeild();
4
 }
7
 }

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Ridable.java Bestand weergeven

4
 
4
 
5
     boolean isRideable();
5
     boolean isRideable();
6
 
6
 
7
-    
7
+
8
 
8
 
9
 }
9
 }