The Artima Developer Community
Sponsored Link

Design Forum
URGENT, need someone to help check for this design

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Betty Pui

Posts: 2
Nickname: rainbowval
Registered: May, 2004

URGENT, need someone to help check for this design Posted: May 30, 2004 5:23 PM
Reply to this message Reply
Advertisement
Some I don't know wat to do, The Card Game Web Site, [online], [http://www.pagat.com/war/beggar_my_neighbour.html],


Strip Jack Naked

Arrays that will be created:

1. Deck = k
2. NewDeck=g
3. Player
4. Dealer
5. Stack
6. Play = i

Methods that will be called:
1. DealCards
2. CheckCard
3. SwitchTurns
4. Shuffling

Class created:





Module: Main
Import: none
Export: none
Input:

PROMPT user for number of shuffles = x
PROMPT user for number of games to play = y
DEFINE NewDeck

FOR (y=1, y<= number_of_games, y++)
Get Shuffling
Get DealCards
CREATE empty string array Stack[]
CREATE empty string array Play[]

Play[]=Player[]
GET Play

i=0
WHILE (i<Play.length)

PRINT “The card displayed at the top is”+ Play

DEFINE Card
Card=0
GET Checkcard

IF Check=c
GET CheckTrue
ELSE
GET SwitchPlayer
PRINT “The card displayed at the top is”+ Play
IF Check=c
GET CheckTrue
ELSE
GET SwitchPlayer
i++
ENDIF


DISPLAY results for each game
Output: The results table of the game

------------------------------------------------------------------------- -------------------

Module: Deck
Import: none
Export: Array of “Deck”
Input:

CREATE a string array of String Deck[52]

Assign each card accordingly “2”, “2”, “2”, “2”… “A”, “A”, “A”, “A”

RETURN Deck


------------------------------------------------------------------------ --------------------


Module: Shuffling
Import: Deck array
Export: NewDeck array
Input:

OR USE java.util.Collections is for shuffling

CREATE NewDeck[]

FOR (x=1, x<=no_of_shuffles, x++)

Math.random to choose r in array from 0 to k
Swap values in positions r and k

RETURN NewDeck

Output: The Cards are already shuffled and ready to deal.


----------------------------------------------------------------------- ---------------------

Module: DealCards
Import: NewDeck
Export: 2 arrays of cards “Player” and “Dealer”
Input:

CREATE 2 string arrays “player”[52] and “dealer”[52]
FOR (g=0, g<= NewDeck.length, g++)
IF (g%2= = 0)
g goes to player array
ELSE
g goes to dealer array

RETURN Player
RETURN Dealer
------------------------------------------------------------------------ --------------------

INCOMPLETE!!!!!!!!!!!!!!! STUCK!!!!!!!!!!!!!!!!!!!!

Module: Play
Import: Player and Dealer array
Export:
Input:



-------------------------------------------------------------------- ------------------------

Module: CheckCard
Import: Player. Dealer[j]
Export: True/False
Input:

Boolean c,d
c=true
d=false

IF Play equals to A, K, Q, J
Check = c

Switch(Card)
CASE1: Play =A
Card=4
CASE2: Play=K
Card=3
CASE3: Play=Q
Card=2
CASE4: Play=J
Card=1
DEFAULT: Play=2-10
Card=5

ELSE
Check=d

RETURN Check
RETURN Card

------------------------------------------------------------------------- -------------------

Module: SwitchPlayer
Import: Dealer/Player
Export:
Input:

IF Play[]=Player[]
Play[]=Dealer[]

ELSE
Play[]=Player[]

RETURN Play[]
------------------------------------------------------------------------ --------------------

Module: CheckTrue
Import:
Export:
Input:

s=1
WHILE (s<=Card && i<Play.length)
PUT Play in Stack[]
GET SwitchPlayer
PRINT ‘The card displayed at the top is” +Play
GET CheckCard
IF Check=d
GET CheckFalse
ENDIF
-------------------------------------------------------------- ------------------------------
Module: CheckFalse
Import:
Export:
Input:

t=1
WHILE (t<=Card)
GET Checkcard
IF Check=c
GET CheckTrue
ENDIF
t++
ENDWHILE

Topic: UML Design: Whether required? Previous Topic   Next Topic Topic: Best website design company style

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use