Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chris branch #44

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<groupId>com.zipcodewilmington</groupId>
<artifactId>froilans-farm</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
*/
public class MainApplication {

public static void main(String[] args){

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.zipcodewilmington.froilansfarm.animal;

import com.zipcodewilmington.froilansfarm.edible.Corn;
import com.zipcodewilmington.froilansfarm.interfaces.Eater;
import com.zipcodewilmington.froilansfarm.interfaces.Noisemaker;
import com.zipcodewilmington.froilansfarm.shelter.FoodInventory;

public abstract class Animal implements Eater<Corn>, Noisemaker {
String name;

public Animal(String name){
this.name = name;
}

public void eat(Corn food, FoodInventory silo){
//Will remove an instance of a Corn edible object from the given foodInventory -> DONE
//Maybe if object doesn't exist, give a message that the animal is hungry -> DONE
//For debugging purposes at least, print out given foodInventory ->
if(food != null){
System.out.println(this.toString()+" ate "+food.toString());
silo.remove(food);
System.out.println("Current food in food inventory: "+silo.size());
}
else{
System.out.println(this.toString()+" was not fed and is still hungry!");
}

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.zipcodewilmington.froilansfarm.animal;

import com.zipcodewilmington.froilansfarm.edible.Corn;
import com.zipcodewilmington.froilansfarm.edible.Egg;
import com.zipcodewilmington.froilansfarm.interfaces.Produce;

public class Chicken extends Animal implements Produce {
boolean isFertilized = false;

public Chicken(String name){
super(name);
}

//whatever calls yield here has to put the egg in the FoodInventory
public Egg yield(){
if(!isFertilized){
return new Egg();
}
return null;
}

public void fertilizeEgg(){
isFertilized = true;
}

public boolean isFertilized(){
return isFertilized;
}

public void makeNoise() {
System.out.println("Cock-a-doodle-doo");
}

@Override
public String toString(){
return "Chicken";
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/zipcodewilmington/froilansfarm/animal/Horse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.zipcodewilmington.froilansfarm.animal;

import com.zipcodewilmington.froilansfarm.interfaces.Ridable;

public class Horse extends Animal implements Ridable {

public Horse(String name){
super(name);
}


public void makeNoise() {
System.out.println("Nayyy");
}

@Override
public String toString(){
return "Horse";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.zipcodewilmington.froilansfarm.crops;

import com.zipcodewilmington.froilansfarm.edible.Corn;
import com.zipcodewilmington.froilansfarm.edible.Tomato;
import com.zipcodewilmington.froilansfarm.interfaces.Edible;

public class CornStalk extends Crop{

public CornStalk(){

}

//IF isFertilized is true and isHarvested is false -> DONE
//Then return a Corn, and set isHarvested to true -> DONE
//caller will need to store returned food object some place
public Edible yield() {
if(isFertilized() && !isHarvested()){
harvestCrop();
return new Corn();
}
else{
return null;
}
}

@Override
public String toString(){
return "Corn Stalk";
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/zipcodewilmington/froilansfarm/crops/Crop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.zipcodewilmington.froilansfarm.crops;

import com.zipcodewilmington.froilansfarm.interfaces.Edible;
import com.zipcodewilmington.froilansfarm.interfaces.Produce;

public abstract class Crop implements Produce {
private boolean isFertilized = false;
private boolean isHarvested = false;


public Crop(){
}




public void fertilizeCrop() {
isFertilized = true;
}

public void harvestCrop() {
isHarvested = true;
}

public boolean isFertilized() {
return isFertilized;
}


public boolean isHarvested() {
return isHarvested;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.zipcodewilmington.froilansfarm.crops;

import com.zipcodewilmington.froilansfarm.edible.Corn;
import com.zipcodewilmington.froilansfarm.edible.Tomato;
import com.zipcodewilmington.froilansfarm.interfaces.Edible;

public class TomatoPlant extends Crop{

public TomatoPlant(){

}

//IF isFertilized is true and isHarvested is false -> DONE
//Then return a Tomato, and set isHarvested to true -> DONE
//caller will need to store returned food object some place
public Edible yield() {
if(isFertilized() && !isHarvested()){
harvestCrop();
return new Tomato();
}
else{
return null;
}
}

@Override
public String toString(){
return "Tomato Plant";
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/zipcodewilmington/froilansfarm/edible/Corn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.zipcodewilmington.froilansfarm.edible;

import com.zipcodewilmington.froilansfarm.interfaces.Edible;

public class Corn implements Edible {

@Override
public String toString(){
return "Corn";
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/zipcodewilmington/froilansfarm/edible/Egg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.zipcodewilmington.froilansfarm.edible;

import com.zipcodewilmington.froilansfarm.interfaces.Edible;

public class Egg implements Edible {


@Override
public String toString(){
return "Egg";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.zipcodewilmington.froilansfarm.edible;

import com.zipcodewilmington.froilansfarm.interfaces.Edible;

public class Tomato implements Edible {

@Override
public String toString(){
return "Tomato";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.zipcodewilmington.froilansfarm.interfaces;

import com.zipcodewilmington.froilansfarm.shelter.FoodInventory;

public interface Eater<T extends Edible> {

public void eat(T food, FoodInventory whatever);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.zipcodewilmington.froilansfarm.interfaces;

public interface Edible {


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.zipcodewilmington.froilansfarm.interfaces;

import com.zipcodewilmington.froilansfarm.shelter.CropRow;
import com.zipcodewilmington.froilansfarm.shelter.FoodInventory;

public interface FarmVehicle {

//Prints a string letting user know farm vehicle is operating
public void operate();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.zipcodewilmington.froilansfarm.interfaces;

public interface Noisemaker {

//Anything that can make noise just prints a string of whatever
//Dumb noise it makes
public void makeNoise();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.zipcodewilmington.froilansfarm.interfaces;

public interface Produce {

public Edible yield();
public boolean isFertilized();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.zipcodewilmington.froilansfarm.interfaces;

public interface Ridable {
//Only purpose is to determine what objects can be ridden
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.zipcodewilmington.froilansfarm.interfaces;

public interface Rider <T extends Ridable>{

//Either more string fluff, or boolean checks to ensure
// vehicles can only operate if they're being ridden.
//In either case, get name of ridable to use in the string.
public void mount(T mountable);
public void dismount(T mountable);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.zipcodewilmington.froilansfarm.person;

import com.zipcodewilmington.froilansfarm.crops.Crop;
import com.zipcodewilmington.froilansfarm.interfaces.Ridable;
import com.zipcodewilmington.froilansfarm.shelter.CropRow;

public class Botanist extends Person{

public Botanist(String name){
super(name);
}

//Passes Crop objects into croprows -> DONE
public void plantCrops(Crop crop, CropRow cropRow){
cropRow.add(crop);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.zipcodewilmington.froilansfarm.person;

import com.zipcodewilmington.froilansfarm.animal.Animal;
import com.zipcodewilmington.froilansfarm.crops.Crop;
import com.zipcodewilmington.froilansfarm.edible.Corn;
import com.zipcodewilmington.froilansfarm.interfaces.Ridable;
import com.zipcodewilmington.froilansfarm.shelter.ChickenCoop;
import com.zipcodewilmington.froilansfarm.shelter.CropRow;
import com.zipcodewilmington.froilansfarm.shelter.FoodInventory;
import com.zipcodewilmington.froilansfarm.vehicle.Tractor;

public class Farmer extends Botanist{

public Farmer(String name){
super(name);
}

public void operate(Tractor tractor, CropRow cropRow){

}

//Farmer goes into a chickencoop, calls yield on each chicken -> DONE
//Currently there is no means of fertilizing chickens, so each chicken in the coop -> YIELD METHOD ALREADY CHECKS IF NOT FERTILIZED
//should yield an egg to the FoodInventory -> DONE
public void getEggs(ChickenCoop coop, FoodInventory silo){
for(int i=0;i<coop.size();i++){
silo.add(coop.get(i).yield());
}
}

//Going to need to call the animal's eat method here. -> DONE
//if not enough food, return a sad message. Something about being hungry and dolio's fault. -> ANIMALS EAT METHOD CHECKS FOR NULL FOOD
public void feed(Animal animal, Corn food, FoodInventory silo){
System.out.println(animal.toString()+" was fed");
animal.eat(food,silo);
}
}
Loading