Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-18-2008, 09:15 PM
Member
 
Join Date: Jan 2008
Posts: 2
GodiaN is on a distinguished road
Wanna make 5 quick bucks?
Sure you do!

Make me a java applet with three java files that including:

Gameof21 -> Main Program

PlayingCard Class -> sections of
Playing Card -> Object create
Point value -> returns value of playing card
getname -> returns the card name
tostring -> returns a string that represents the card

Player Class -> sections of
Player -> player object created. Play initially has no cards.
drawCard -> add a card to a players hand
totalhand -> returns players hand value. Ace counted as || if gets player closer to 2!
endhand -> ends the game for the player, throwing in the cards.


5 Dollars paypal for this

Thanks you.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-19-2008, 02:47 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
public class GameOf21 { public static void main(String[] args) { PlayingCard[] cards = new PlayingCard[13]; String suit = "spades"; String[] faces = { "jack", "queen", "king", "ace" }; for(int j = 0; j < 13; j++) { int value = Math.min(j+2, 10); if(j == 12) value += 1; String name = (j < 9) ? String.valueOf(value) : faces[j-9]; cards[j] = new PlayingCard(value, name + " of " + suit); } showCards(cards); Player player = new Player(); for(int j = 0; j < 5; j++) player.drawCard(cards[j]); showCards(player.hand); int handValue = player.totalHand(); System.out.println("handValue = " + handValue); } private static void showCards(PlayingCard[] cards) { for(int j = 0; j < cards.length; j++) { System.out.print(cards[j]); if(j < cards.length-1) System.out.print(", "); else System.out.println(); } System.out.println("--------------"); } } class PlayingCard { int value; String name; public PlayingCard(int value, String name) { this.value = value; this.name = name; } public int getValue() { return value; } public String getName() { return name; } public String toString() { return name; } } class Player { PlayingCard[] hand = new PlayingCard[0]; public Player() { // nothing to do here... } public void drawCard(PlayingCard card) { int size = hand.length; PlayingCard[] newHand = new PlayingCard[size+1]; System.arraycopy(hand, 0, newHand, 0, size); newHand[size] = card; hand = newHand; } public int totalHand() { int total = 0; for(int j = 0; j < hand.length; j++) { PlayingCard card = hand[j]; int value = card.getValue(); if(total + value > 21 && value == 11) value = 1; total += value; } return total; } public void endHand() { hand = new PlayingCard[0]; } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-19-2008, 04:32 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 840
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Pay up! And next time, take your advertising to the Advertising section or find a freelancing site. As you can see, a lot of the folks here program for the joy of it. Thank you.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-21-2008, 03:59 PM
Member
 
Join Date: Jan 2008
Posts: 2
GodiaN is on a distinguished road
Whats your email hardwire (paypal)
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-21-2008, 07:47 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Nevermind; I'm glad to help.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-21-2008, 08:15 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Free for all
Hello GodiaN

This site is not for freelancing programmers. Java Forms is devoted to help people learn Java.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick sort with median-of-three partitioning Java Tip Algorithms 0 04-15-2008 08:40 PM
Quick Help Please! Can't Run Code!! VinceGuad Eclipse 4 01-16-2008 04:54 AM
Quick Stupid Question bluekswing New To Java 7 01-08-2008 07:35 PM
Quick Job required in Java taxman Jobs Offered 0 01-02-2008 12:46 PM
Quick Question (Functions) ibanez270dx New To Java 2 11-16-2007 02:42 AM


All times are GMT +3. The time now is 08:54 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org