Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Help with a simple Java Uno game

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to build a simple game of "Uno" in java. I just want to be able to display each step of the game without any user input. The computer is playing itself in a way. I have made the shuffle and deal class for the game, but I am not sure how to display the rest of the game.

I would like the game to display the two players' hands, and then each step the players make until the game is over.

Any advice? Thanks!

Here is the code I have so far:



I would like the game to flow some what like this:

Uno Game flow:

Shuffle cards
Deal cards
Display top card
Players take turn placing cards until they are out of cards
If players cannot play, they must draw one card
The player with one card left must say “uno”

Thank you! please let me know if I can make anything more clear.
 
Bartender
Posts: 2414
106
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Austin, I am think that the company has probably patented the game. I suggest against making or using the name of the company or it's characteristics in your code or posting it in forums. Maybe you can attempt a similar game using regular card deck ?

I think your code for shuffling can be improved a lot using Collections.shuffle() method and the code can be improved using enums.
 
Marshal
Posts: 14530
242
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm no lawyer but since the OP's intent is to learn Java and probably not for private commercial gain, I think this falls under "fair use" rules.

@OP: what have you done to try to implement the rules of the game? All I see here are creating the deck and shuffling it. And having all your code in MainIsAPain (←click that, it's a link)
 
Bartender
Posts: 3673
151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If coding a game that is copy-righted is not allowed, I would probably be doing a life sentence  

I woud certainly have a player playing his last-but-one card having a 20% change of forgetting to say "uno". Sounds like fun.
 
salvin francis
Bartender
Posts: 2414
106
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:I'm no lawyer but since the OP's intent is to learn Java and probably not for private commercial gain, I think this falls under "fair use" rules...


Noted. In that case, let's continue with the discussion here.

OP, adding to all comments above, your entire code is written in a "Deal" class. However, the code does not deal any thing, it just shuffles the deck.
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!