Suppose your writing a simple game code and you want to have the user select any number of stages and each stage has 10 enemies and you only get 2 shots per stage (that the user can input). Lets look at the if code part...
public void shoot(int enemies){ if (!isOver){ //Method that ends the game. enemiesUp = enemiesUp - enemies; if(shoot == 1 && enemiesUp < 1 && stage != totalStages){ //last stage you can shoot 3 times. stage++; }
When you test it goes good after the first shot, but the 2nd shot screws up on the count, getShoot should come back with the 2nd shot, and comes back on the 1st shot. Should I add shoot++; to that if statement? The enemies are doing great till I get to the 3 shoot() call, enemies should reset back to 10 after the 2nd shot, but my test is going into the negative.
Should be--> Stage: 1 Enemies: 10 Shoot: 1 Stage: 1 Enemies: 10 Shoot: 1 Should be--> Stage: 1 Enemies: 5 Shoot: 1 Stage: 1 Enemies: 5 Shoot: 1 Should be--> Stage: 1 Enemies: 2 Shoot: 2 Stage: 1 Enemies: 2 Shoot: 1 Should be--> Stage: 2 Enemies: 5 Shoot: 1 Stage: 2 Enemies: -3 Shoot: 1 Should be--> Stage: 2 Enemies: 10 Shoot: 2 Stage: 3 Enemies: -8 Shoot: 1
Should I make more nested If statements, or else if?