瀏覽代碼

made fields etc

mpierse 6 年之前
父節點
當前提交
fb439ddd7c

+ 19
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Freelan.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.zipcodewilmington.froilansfarm.Animals;
2
+
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
4
+import com.zipcodewilmington.froilansfarm.Holders.Field;
5
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Botanist;
6
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.CornStalk;
7
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
8
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.TomatoPlant;
9
+
10
+public class Freelan extends Person implements Farmer, Botanist {
11
+
12
+    Field field = new Field;
13
+
14
+    public void plant(Crop type, int numToPlant){
15
+        CropRow row = new CropRow(type, numToPlant);
16
+        field.addToField(row);
17
+
18
+    }
19
+}

+ 10
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Froilan.java 查看文件

@@ -0,0 +1,10 @@
1
+package com.zipcodewilmington.froilansfarm.Animals;
2
+
3
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Botanist;
4
+
5
+public class Froilan extends Person implements Farmer {
6
+
7
+    public plant(){
8
+
9
+    }
10
+}

src/main/java/com/zipcodewilmington/froilansfarm/Animals/Pilot.java → src/main/java/com/zipcodewilmington/froilansfarm/Animals/Froilanda.java 查看文件

@@ -1,7 +1,6 @@
1 1
 package com.zipcodewilmington.froilansfarm.Animals;
2 2
 
3
-import com.zipcodewilmington.froilansfarm.Animals.Person;
4 3
 import com.zipcodewilmington.froilansfarm.Vehicle.Flyer;
5 4
 
6
-public class Pilot extends Person implements Flyer {
5
+public class Froilanda extends Person implements Flyer {
7 6
 }

+ 3
- 3
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Horse.java 查看文件

@@ -15,13 +15,13 @@ public class Horse extends Amimal implements Ridable {
15 15
         return "NEIGH!";
16 16
     }
17 17
 
18
-    public boolean isRideable(){
19
-        return true;
18
+    public boolean getIsRideable(){
19
+        return rider.getIsMounted();
20 20
     }
21 21
 
22 22
     public String ride() {
23 23
         String result = "No riding today";
24
-        if (getIsRideable() && rider.getIsMounted()) {
24
+        if (getIsRideable()) {
25 25
             result = "";
26 26
             for (int i = 0; i < stable.getHorses(); i++) {
27 27
                 result += "Horse number " + i + " has been ridden today. \n";

+ 17
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/CropRow.java 查看文件

@@ -1,7 +1,23 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
-public class CropRow extends Field {
3
+import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
4 4
 
5
+public class CropRow {
5 6
 
7
+    private int numberPlanted;
8
+    private Crop cropType;
9
+    private boolean isFertilized = false;
6 10
 
11
+    public CropRow(Crop cropType, int numberPlanted) {
12
+        this.cropType=cropType;
13
+        this.numberPlanted=numberPlanted;
14
+    }
15
+
16
+    public boolean getIsFertilized() {
17
+        return isFertilized;
18
+    }
19
+
20
+    public void setFertilized(boolean fertilized) {
21
+        isFertilized = fertilized;
22
+    }
7 23
 }

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java 查看文件

@@ -1,4 +1,4 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
-public class Farm extends Storer {
3
+public class Farm  {
4 4
 }

+ 23
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Field.java 查看文件

@@ -1,4 +1,26 @@
1 1
 package com.zipcodewilmington.froilansfarm.Holders;
2 2
 
3
-public class Field extends Farm {
3
+import java.util.ArrayList;
4
+import java.util.LinkedHashMap;
5
+import java.util.Map;
6
+
7
+public class Field {
8
+
9
+    private Map<Integer, CropRow> fieldMap;
10
+    private int rowNumber=1;
11
+
12
+
13
+    public Field() {
14
+
15
+        fieldMap = new LinkedHashMap<Integer, CropRow>();
16
+
17
+    }
18
+
19
+    public void addToField(CropRow cropRow){
20
+        fieldMap.put(getRowNumber(), cropRow);
21
+    }
22
+
23
+    public int getRowNumber() {
24
+        return rowNumber++;
25
+    }
4 26
 }

+ 3
- 0
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/Botanist.java 查看文件

@@ -1,4 +1,7 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3 3
 public interface Botanist {
4
+
5
+    void plant();
6
+
4 7
 }

+ 9
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/CornStalk.java 查看文件

@@ -1,4 +1,12 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3
-public class CornStalk extends Crop {
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
4
+
5
+import java.util.ArrayList;
6
+import java.util.Map;
7
+
8
+public class CornStalk extends Crop{
9
+
10
+    public CornStalk() {
11
+    }
4 12
 }

+ 5
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/TomatoPlant.java 查看文件

@@ -1,6 +1,10 @@
1 1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
3 4
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
4 5
 
5
-public class TomatoPlant extends Crop {
6
+public class TomatoPlant extends Crop{
7
+
8
+    public TomatoPlant() {
9
+    }
6 10
 }

+ 10
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Aircraft.java 查看文件

@@ -3,4 +3,14 @@ package com.zipcodewilmington.froilansfarm.Vehicle;
3 3
 import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle;
4 4
 
5 5
 public class Aircraft extends Vehicle {
6
+
7
+    @Override
8
+    public String ride(){
9
+        String result = "No transportation today";
10
+        if(getIsRideable()){
11
+            result = "We're flying!";
12
+        }
13
+
14
+        return result;
15
+    }
6 16
 }

+ 9
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Tractor.java 查看文件

@@ -14,4 +14,13 @@ public class Tractor extends Vehicle implements Harvests, FarmVehicle {
14 14
         addToStore(numToStore);
15 15
 
16 16
     }
17
+
18
+    public String ride(){
19
+        String result = "No transportation today";
20
+        if(getIsRideable()){
21
+            result = "Driving in the field today";
22
+        }
23
+
24
+        return result;
25
+    }
17 26
 }

+ 13
- 3
src/main/java/com/zipcodewilmington/froilansfarm/Vehicle/Vehicle.java 查看文件

@@ -1,21 +1,31 @@
1 1
 package com.zipcodewilmington.froilansfarm.Vehicle;
2 2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
3 4
 import com.zipcodewilmington.froilansfarm.NoiseMaker;
4 5
 import com.zipcodewilmington.froilansfarm.Ridable;
5 6
 
6 7
 public class Vehicle implements Ridable, NoiseMaker {
7 8
 
9
+    Person person = new Person();
10
+
8 11
     public String makeNoise(){
9 12
         return "VROOM VROOM!";
10 13
     }
11 14
 
15
+
12 16
     public boolean getIsRideable(){
13
-        return true;
17
+        return person.getIsMounted();
14 18
     }
15 19
 
20
+
16 21
     public String ride(){
17
-     return "Moving around on a vehicle";
18
-    };
22
+     String result = "No transportation today";
23
+     if(getIsRideable()){
24
+         result = "Moving around on a vehicle";
25
+     }
26
+
27
+        return result;
28
+    }
19 29
 
20 30
 
21 31
 }