• Post Reply Bookmark Topic Watch Topic
  • New Topic

need urgent help, teacher didnt teach  RSS feed

 
akshar shah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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:
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • 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.
 
Norm Radder
Ranch Foreman
Posts: 2240
28
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
Knute Snortum
Sheriff
Posts: 4087
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Liutauras Vilda
Marshal
Posts: 4658
320
BSD
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!