Ver código fonte

made fields etc

mpierse 6 anos atrás
pai
commit
fb439ddd7c

+ 19
- 0
src/main/java/com/zipcodewilmington/froilansfarm/Animals/Freelan.java Ver arquivo

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 Ver arquivo

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 Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.Animals;
1
 package com.zipcodewilmington.froilansfarm.Animals;
2
 
2
 
3
-import com.zipcodewilmington.froilansfarm.Animals.Person;
4
 import com.zipcodewilmington.froilansfarm.Vehicle.Flyer;
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 Ver arquivo

15
         return "NEIGH!";
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
     public String ride() {
22
     public String ride() {
23
         String result = "No riding today";
23
         String result = "No riding today";
24
-        if (getIsRideable() && rider.getIsMounted()) {
24
+        if (getIsRideable()) {
25
             result = "";
25
             result = "";
26
             for (int i = 0; i < stable.getHorses(); i++) {
26
             for (int i = 0; i < stable.getHorses(); i++) {
27
                 result += "Horse number " + i + " has been ridden today. \n";
27
                 result += "Horse number " + i + " has been ridden today. \n";

+ 17
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/CropRow.java Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.Holders;
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 Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.Holders;
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 Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.Holders;
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 Ver arquivo

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

+ 9
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/CornStalk.java Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
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 Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
1
 package com.zipcodewilmington.froilansfarm.PlantsAndCrops;
2
 
2
 
3
+import com.zipcodewilmington.froilansfarm.Holders.CropRow;
3
 import com.zipcodewilmington.froilansfarm.PlantsAndCrops.Crop;
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 Ver arquivo

3
 import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle;
3
 import com.zipcodewilmington.froilansfarm.Vehicle.Vehicle;
4
 
4
 
5
 public class Aircraft extends Vehicle {
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 Ver arquivo

14
         addToStore(numToStore);
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 Ver arquivo

1
 package com.zipcodewilmington.froilansfarm.Vehicle;
1
 package com.zipcodewilmington.froilansfarm.Vehicle;
2
 
2
 
3
+import com.zipcodewilmington.froilansfarm.Animals.Person;
3
 import com.zipcodewilmington.froilansfarm.NoiseMaker;
4
 import com.zipcodewilmington.froilansfarm.NoiseMaker;
4
 import com.zipcodewilmington.froilansfarm.Ridable;
5
 import com.zipcodewilmington.froilansfarm.Ridable;
5
 
6
 
6
 public class Vehicle implements Ridable, NoiseMaker {
7
 public class Vehicle implements Ridable, NoiseMaker {
7
 
8
 
9
+    Person person = new Person();
10
+
8
     public String makeNoise(){
11
     public String makeNoise(){
9
         return "VROOM VROOM!";
12
         return "VROOM VROOM!";
10
     }
13
     }
11
 
14
 
15
+
12
     public boolean getIsRideable(){
16
     public boolean getIsRideable(){
13
-        return true;
17
+        return person.getIsMounted();
14
     }
18
     }
15
 
19
 
20
+
16
     public String ride(){
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
 }