• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

How do I play again as the same 'player'?  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I currently have a Player class private instances, getters, and setters as well as a game class.

For the game, I ask the player for their name. It is saved in the object class. Every player has a $500 balance.
The game is called 21 of Dice and basically, it is like Blackjack in a sense that if you happen to beat the dealer (or computer) you win $100 and if you lose or tie, you lose $50.

When I play the game each time, it is creating a new player. I want it to be possible that I want to play as the same player with the updated balance. Any help would be greatly appreciated.

Here is my Player class:





Here is my Game class:


 
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of calling your play21method from your playAgainmethod, call your playAgainmethod from your play21Method, make it return a boolean and put your playmethod, except for the playercreation in a do whileloop that calls the playAgainmethod, when the player presses y it reurns true and otherwise false
 
Rancher
Posts: 3353
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you post the code that you are executing?
How do you execute the program?

I don't see where the playGame method is called.
 
Daniel Demesmaecker
Rancher
Posts: 1170
18
Firefox Browser Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to Illustrate:

 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!