Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Needhelp with face cards for a deck.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Psychotogen




PostPosted: Wed Apr 23, 2008 9:06 pm   Post subject: Needhelp with face cards for a deck.

This is what i have and it works perfectly for producing 4 suits and 13 of each number without repeating.
I just need some pointers on how to make it display the name of a face card instead of the number.

code:
proc showCard
    randint (card, 1, 52)   
    if deck (card) not= -1 then
        put deck (card) mod 13, " " ..   
         put deck (card) mod 4
    end if 
    deck (card) := -1
end showCard
Sponsor
Sponsor
Sponsor
sponsor
I Smell Death




PostPosted: Wed Apr 23, 2008 9:27 pm   Post subject: RE:Needhelp with face cards for a deck.

I am assuming that the face cards are going to be the same numbers each time you play. Can't you just use a if statement such as

if deck(card)mod 13=12 then
put "King" % or what ever card it may be
else
put deck (card)mod 4
end if
Psychotogen




PostPosted: Wed Apr 23, 2008 10:12 pm   Post subject: Re: Needhelp with face cards for a deck.

Actually, how could I condense this stupidness?

code:
var deck : array 1 .. 52 of int
var card : int
setscreen ("graphics:700,700")
var suit, cardNo : string

for i : 1 .. 52
    deck (i) := i
end for

proc showCard
    randint (card, 1, 52)
    if deck (card) not= -1 then
   
    if deck (card) mod 13 = 0  then
    cardNo := "Ace"
    elsif deck (card) mod 13 = 1  then
    cardNo := "2"
    elsif deck (card) mod 13 = 2  then
    cardNo := "3"
    elsif deck (card) mod 13 = 3  then
    cardNo := "4"
    elsif deck (card) mod 13 =  4 then
    cardNo := "5"
    elsif deck (card) mod 13 = 5  then
    cardNo := "6"
    elsif deck (card) mod 13 = 6  then
    cardNo := "7"
    elsif deck (card) mod 13 = 7  then
    cardNo := "8"
    elsif deck (card) mod 13 = 8  then
    cardNo := "9"
    elsif deck (card) mod 13 = 9  then
    cardNo := "10"
    elsif deck (card) mod 13 = 10  then
    cardNo := "Jack"
    elsif deck (card) mod 13 =  11 then
    cardNo := "Queen"
    elsif deck (card) mod 13 =  12 then
    cardNo := "King"
   end if
   

        if deck (card) mod 4 = 0 then
            suit := " of Diamonds"
        elsif deck (card) mod 4 = 1 then
            suit := " of Hearts"
        elsif deck (card) mod 4 = 2 then
            suit := " of Spades"
        elsif deck (card) mod 4 = 3 then
            suit := " of Clubs"
        end if

        put cardNo ..
        put suit

    end if
    deck (card) := -1
end showCard
syntax_error




PostPosted: Wed Apr 23, 2008 10:41 pm   Post subject: RE:Needhelp with face cards for a deck.

use a for loop.

hint: make cardNo a string array.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: