• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Reinitialization program freeze

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]

 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 76825
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
StdIn is not in the standard Java® library downloaded from Oracle. Maybe it is standard to DrJava?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Hold that thought. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic