diff --git a/Cow.java b/Cow.java index 7f879f3..ecad563 100755 --- a/Cow.java +++ b/Cow.java @@ -11,7 +11,6 @@ * This file holds the cow class and associated methods. */ -//import java.Exception.*; import java.util.HashMap; import java.util.Iterator; @@ -26,7 +25,6 @@ private String name; private String sex; private HashMap traits; - private int milk, strength, meat, aggression; //TODO convert to dict /* * This constructor provides a default cow or bull to start the game with. @@ -118,7 +116,8 @@ rating = rateMeatCow(c); } else { - //throw Exception("No such use: "+use); + rating = 0; + System.out.println("ERROR No such use: "+use); } return "This is a "+rating2string(rating)+" cow for "+use+"."; } @@ -162,13 +161,14 @@ if (sex == "male") return "Bull #"+id; else if (sex == "female") return "Cow #"+id; else return "ERROR No such sex: "+sex; - //else throw Exception("No such sex: "+sex); } - private int combineTrait(int fatherTrait, int motherTrait) + private int combineTrait(int fathertrait, int mothertrait) { - //TODO - return 0; + int newtrait = (int) Math.round((fathertrait+mothertrait)/2); + int quartertrait = (int) Math.round(newtrait*0.25); + int randomfactor = Herd.random.nextInt(quartertrait*2) - quartertrait; + return newtrait+randomfactor; } }