• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reinitialization program freeze  RSS feed

 
joseph Anderson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay again I am having issues. So the program works without the initialize subroutine. But if i put it in, it locks up immediately after i put in a number at the line "guard =...". The subroutine is supposed to reset all holder variables for another run through the program.

main program




subroutine


Console output
Welcome to DrJava. Working directory is C:\Users\David1\Desktop\fun\Programming
> run FiveCardPokerRemake
Hello Welcome to Five Card Draw
Your initial draw is:
10OfSpades, 8OfDiamonds,8OfHearts, 5OfDiamonds, 7OfClubs

Enter the number of a card you would like to hold or hit 0 if there are no more cards you would like to hold
[DrJava Input Box]
Your new hand is: 5OfHearts, JackkOfHearts,2OfDiamonds, QueenOfClubs, 9OfDiamonds
Your new hand is: 100100010110

you got a high card of Queen
Play again?(0 for yes, anything else for no)
[DrJava Input Box]
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is StdIn?

AS for your initialize method, you could use Arrays.fill() instead of those loops.

Also, I believe you should have a Game class and work of an instance of it instead of passing everything arount static methods.
 
joseph Anderson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay thanks the advice about fill array worked it is now running smoothly. As for StdIn it is used to request values to be put into the console to accept variables. In this case it is putting the next int typed into the variable guard.

edit: and StdIn is part of the Standard library.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StdIn is not in the standard Java® library downloaded from Oracle. Maybe it is standard to DrJava?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:StdIn is not in the standard Java® library downloaded from Oracle. Maybe it is standard to DrJava?

Found this which suggests it's just a very thin wrapper to Scanner(System.in).

How disappointing. I'd have though at the very least that when you call readInt() it would require the input to actually be an integer, but no...

Very unimpressed. It just seems like a "noise" class to me...And it uses Locale.US...ALWAYS.

Winston
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!