I am getting this error and I do not understand the ways to fix it. Class Tutor could not understand it. It is a poker program that deals with one hand, allows the user to change up to 4 cards, and then analyzes it. It is designed to design that the hand as much as the hands need the user to play, but the scanner whose input is decided whether he can play or not, is not working and I can not understand the reason .
Here is the main code
import java.util. *; Public category poker {public static zero main (string [] args) {string game = "continue"; Runpoker Play = New Run (); System.out.println (Enter 2 to play a hand or 1 to play: "); while (game ==" continue ") {game = (run run score). Pahlhund (); // This line is called the Playhand that it is calling, this is the real core code import Java.util.Scanner; public class run {public string playhand {int r = 1; int range = 0; // create a new, shuffle deck deck de = new deck; hand H = D.Dial () ; H.sort (); Println (h); System.out.println ("Which card do you want to change , Up to 4 "); System.out.println (" Enter 0 when the end "); scanner = new scanner (System.in); R = in.nextInt (); while (R & gt; 0 & amp; Amp; R & lt; 6 & amp; amp; amp; & amp; amp; amp; Limitations & amp; 4; 4) {if (R & gt; 0) h.replace (d, r - 1); range ++; In.nextInt (); H.sort (); Println (h); String result = H. Analysis (); Println (result); String reply; System.out.println ("Do you want to play again? Enter 'Continue' to play again or enter 'Skip' to stop playing); In.close (); Scanner input = new scanner (System.in); Answer = input.nextLine (); // This line is 34 input. Close (); Answer to return; }}
There are other classes but the scanner should not be affected. There is an error here
Exception in thread "main" java.util.NoSuchElementException: On the run, no line was found on java.util.Scanner.nextLine (unknown source). Runhand (Run.java: 34) in poker.mine (poker.java 18)
Numeric carriage return
pressed after system.out.println (enter one to play or one to play 1, 2: "); while ((game = scan.nextInt ( )) == 2) is never consumed and is still on the input when called playHand .
call Before playHand call scan.nextLine ();
No comments:
Post a Comment