diff --git a/Cow.java b/Cow.java index 7743d25..5652a60 100755 --- a/Cow.java +++ b/Cow.java @@ -10,11 +10,14 @@ * This file holds the cow class and associated methods. */ +//import java.Exception.*; + public class Cow { private static int idCounter = 1; private int id; + private int generation; private String name; private String sex; private int milk, strength, meat, aggression; @@ -26,6 +29,7 @@ id = idCounter; idCounter++; name = makeName(sex, id); + generation = 0; milk = 1; strength = 5; meat = 1; @@ -51,7 +55,7 @@ rating = rateMeatCow(c); } else { - //error + //throw Exception("No such use: "+use); } return "This is a "+rating2string(rating)+" cow for "+use+"."; } @@ -59,22 +63,25 @@ private int rateDairyCow(Cow c) { //TODO + return 0; } private int rateMeatCow(Cow c) { //TODO + return 0; } private int ratePlowCow(Cow c) { //TODO + return 0; } /* * Return a string rating for values between 0 and 20. */ - private String rating2String(int rating) + private String rating2string(int rating) { if (rating < 1) return "useless"; else if (rating < 3) return "terrible"; @@ -86,5 +93,13 @@ else if (rating < 20) return "very good"; else return "brilliant"; } + + private String makeName(String sex, int id) + { + 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); + } }