[Solved] APCSP create task issue – Method ends program after being called [closed]


It looks like you stopped following the pattern that you applied in the beginning. As you’ll see, prior to line 310, you have used

play = scan.nextLine();
if (play.charAt(0) == 'x' )

Where you call the scanner to read a new line before checking the character. After line 310, you have stopped using the play = scan.nextLine(); which means the program won’t halt to wait for user input and will continue because player.charAt(0) will always equal x (or whatever the previous input was).

Find all the instances where you are checking for the character input and make sure you have called the nextLine()

Edit:

Just a word of advice as someone who’s had to mark first-year university projects.

  • Consider storing your dialogue in something like an array (especially in this case where the dialogue is very linear) and then using a while loop to iterate over it. Look up line separators for Java.
  • Consider what happens when the user doesn’t press “x” and how you would handle that correctly.
  • Add some developer comments on why you did something a certain way.
  • Look up the concept of DRY (don’t repeat yourself) and look at ways to improve your code in this fashion.

0

solved APCSP create task issue – Method ends program after being called [closed]