diff --git a/cow.java b/cow.java new file mode 100755 index 0000000..7743d25 --- /dev/null +++ b/cow.java @@ -0,0 +1,90 @@ +/** + * Moobreeder is a simple cow breeding game to illustrate the principles of + * selective breeding to KS3 pupils. + * + * (c) Daniel Vedder 2018, + * Amano Christian School + */ + +/* + * This file holds the cow class and associated methods. + */ + +public class Cow +{ + private static int idCounter = 1; + + private int id; + private String name; + private String sex; + private int milk, strength, meat, aggression; + + public Cow(String desiredSex) + { + //Default cow/bull + sex = desiredSex; + id = idCounter; + idCounter++; + name = makeName(sex, id); + milk = 1; + strength = 5; + meat = 1; + aggression = 10; + } + + public Cow(Cow father, Cow mother) + { + //Constructor used for reproduction + //TODO + } + + public String rateCow(Cow c, String use) + { + int rating = 0; + if (use == "dairy") { + rating = rateDairyCow(c); + } + else if (use == "plowing") { + rating = ratePlowCow(c); + } + else if (use == "meat") { + rating = rateMeatCow(c); + } + else { + //error + } + return "This is a "+rating2string(rating)+" cow for "+use+"."; + } + + private int rateDairyCow(Cow c) + { + //TODO + } + + private int rateMeatCow(Cow c) + { + //TODO + } + + private int ratePlowCow(Cow c) + { + //TODO + } + + /* + * Return a string rating for values between 0 and 20. + */ + private String rating2String(int rating) + { + if (rating < 1) return "useless"; + else if (rating < 3) return "terrible"; + else if (rating < 6) return "pretty bad"; + else if (rating < 9) return "moderate"; + else if (rating < 12) return "passable"; + else if (rating < 15) return "fairly good"; + else if (rating < 18) return "pretty good"; + else if (rating < 20) return "very good"; + else return "brilliant"; + } + +}