I am creating an adventure game for text games for my Java class, and my last assignment was to add credibility and training to the game.
Basically, a random number is generated for me, and if the number associated with the Shake skill, for example, is greater than the given number, then the dog will successfully complete the trick.
This part works for me 100%.
Now adding training is where I run into problems. Each skill has an initial value of 1. Each time the skill succeeds, the value increases by 1.
My goal is to have a maximum value of 3, and if the maximum value is reached, then the dog performs the trick every time it is performed!
Here is what I have, hope someone can explain why its not working
// Sit if (Trick.equalsIgnoreCase("Sit")) { if (roll >= 4 || sitSkill == 3) { System.out.println("\n" + name + " sat down for you!"); energy -= 10; food -= 5; sitSkill ++; happy ++; } else { System.out.println("\n" + name + " did not perform the trick successfuly."); energy -= 10; food -= 6; happy -= 20; } }
source share