loops - Or statement help in Java -


im making dog text adventure game java class, , latest assignment add probability , training game.

basically have random number generated, , if number associated skill "shake " instance greater set number, dog perform trick successfully.

that part working 100% me.

now adding training im running problems. have each skill set initial value of 1. each time skill performed value increases 1.

my goal have max value of 3, , if max valued reached, dog performs trick every single time executed!

here have, can explain why not working

    //sit     if(trick.equalsignorecase("sit")){         if(roll >= 4 || sitskill == 3){             system.out.println("\n" + name + " sat down you!");             energy -= 10;             food -= 5;             sitskill ++;             happy ++;         }         else{             system.out.println("\n" + name + " did not perform trick successfuly.");             energy -= 10;             food -= 6;             happy -= 20;         }     } 

i can't tell you're trying with, obvious issue can see in case sitskill == 3, still call sitskill++, , after iteration, equal four, causing else statement triggered if roll low.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -