Procházet zdrojové kódy

wrote chicken class

mpierse před 6 roky
rodič
revize
44133bdfa0

+ 12
- 4
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Chicken.java Zobrazit soubor

@@ -2,15 +2,23 @@ package com.zipcodewilmington.froilansfarm.Animals;
2 2
 
3 3
 import com.zipcodewilmington.froilansfarm.Animals.Amimal;
4 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 13
     public String makeNoise(){
9 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 Zobrazit soubor

@@ -5,11 +5,17 @@ import com.zipcodewilmington.froilansfarm.Fertilizable;
5 5
 
6 6
 public class Egg implements Edible, Fertilizable {
7 7
 
8
+
8 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 17
         //if no roosters in chicken coop that yeilds egg
12
-        return false;
18
+        return rooster;
13 19
     }
14 20
 
15 21
     public boolean isEdible(){

+ 7
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java Zobrazit soubor

@@ -1,6 +1,7 @@
1 1
 package com.zipcodewilmington.froilansfarm.Animals;
2 2
 
3 3
 import com.zipcodewilmington.froilansfarm.Animals.Amimal;
4
+import com.zipcodewilmington.froilansfarm.Edible;
4 5
 import com.zipcodewilmington.froilansfarm.Holders.Stable;
5 6
 import com.zipcodewilmington.froilansfarm.Ridable;
6 7
 import com.zipcodewilmington.froilansfarm.Rider;
@@ -19,10 +20,15 @@ public class Horse extends Amimal implements Ridable {
19 20
     }
20 21
 
21 22
     public String ride(){
23
+        String result = "";
22 24
         if (isRideable() && rider.getIsMounted())
23 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 Zobrazit soubor

@@ -1,4 +1,7 @@
1 1
 package com.zipcodewilmington.froilansfarm;
2 2
 
3 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 Zobrazit soubor

@@ -4,6 +4,6 @@ public interface Ridable {
4 4
 
5 5
     boolean isRideable();
6 6
 
7
-    
7
+
8 8
 
9 9
 }