diff --git a/MooBreeder.java b/MooBreeder.java index 5c23685..cfff0e1 100755 --- a/MooBreeder.java +++ b/MooBreeder.java @@ -311,6 +311,7 @@ if (possible == "OK") { Herd.getInstance().breed(); updateGUI(); + testWin(); } else { JOptionPane.showMessageDialog(null, possible, "Breeding failed", @@ -318,6 +319,16 @@ } } + private void testWin() + { + Cow[] calves = Herd.getInstance().getCalves(); + if ((calves[0] != null && calves[0].rateCow(goal).indexOf("excellent") != -1) || + (calves[1] != null && calves[1].rateCow(goal).indexOf("excellent") != -1)) + JOptionPane.showMessageDialog(null, "You have bred an excellent cow for "+ + goal+" in "+Cow.getMaxGen()+" generations.", + "Congratulations!", JOptionPane.INFORMATION_MESSAGE); + } + private void chooseGoal() { String[] possible = {"dairy", "beef", "plowing"};