• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need urgent help, teacher didnt teach

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simpler the code the better but you have to use his outline:

HIS OUTLINE:

Create a new java project for the card game.
Create the appropriately named package for the java project.
Create two object classes: Card, Deck and a driver class, Main.

Add the shuffle method to the deck class.

Initialize a new integer named nextToDeal at the top of the class and set equal to 0.
Add this method to the Deck class:

Create a new class:

Copy and paste this code under the getPoints() method. Make sure you understand it!

Edit the main method to include the following:


Also given this code earlier and instruction earlier:

Part II: CARD GAME

Using the Card constructor below, implement a Deck Object as described below. Test that the program works as described. When finished, add the following features:

A. Add a method shuffle to the Deck Class. Call the method from the Main class to verify that the deck is indeed shuffled.

B. Add a Hand Class that contains an array of 5 Card references. Have the program Deal the Hand two cards and display them for the user. Tell the user how many points they have and ask them if they would like another card or not. Continue to allow the player to add cards until they reach 5 cards or the total is greater than 21.

C. Adjust the Card class to allow Aces to count as 11 to start. If the Hand Class has a value greater than 21, have the Hand Class check for Aces and reduce their point value to 1.

D. Have the program create a dealer Hand that the user can play against. The user should try to get as close to 21 without going over in an effort to beat the Dealer. If the Dealer has 16 or more the Dealer should stop taking cards.

Here is the code to get you started:

 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Akshar, welcome to CodeRanch!

I removed some of your background story, because it's not that relevant to the issue. I also fixed the formatting of the code and the outline. Next time, please use the "Preview" button to make sure your post is clear before you submit it.

So, you've been given this outline. Show us what you've done by yourself so far, and what you're stuck on.
 
Rancher
Posts: 5008
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also posted at: http://www.java-forums.org/new-java/95992-pay-10-need-help.html#post412159
 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
akshar,

So what is your question? I see a lot of code from your teacher, but I don't see anything except a call for help from you. Please be specific in what you need so we can help you.

Les
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@akshar shah: it's okay if you cross-post on CodeRanch, but please be upfront about it. Also, other forums do not allow cross-posting and may not answer your questions if you do.
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
akshar shah, who wrote that code in quotes?
I see few major issues there, until those gets fixed probably not a good idea to build anything else on top of that.
reply
    Bookmark Topic Watch Topic
  • New Topic