Card game

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators: Administrator, Global Moderator

Post Reply
Joe
Newbie
Posts: 1
Joined: Sun Jan 19, 2003 2:17 pm

Card game

Post by Joe »

I am doing a card game with 5 cards in my hand.
but when the program should check if i got pair or something i have to write so much.
the five card get numbers between 1 - 52 so it can look like this: card(1) = 3
How do i check if i got pair.......
User avatar
frankiebaby
Global Moderator
Posts: 95
Joined: Tue Apr 30, 2002 1:38 am
Location: Pennsylvania
Contact:

Re: Card game

Post by frankiebaby »

Well, this always works:

PAIR = 0
PAIR_IS = 0

For x = 1 to 5
for y = 1 to 5
 if Card(X) = Card(Y) then
   PAIR = PAIR + 1
   PAIR_IS = CARD(X)
 end if
next
next

if pair then print "YOU HAVE A PAIR OF"; PAIR_IS; "!"

this does not, however, check for two or more pair, but could be easily modified to do so.
Post Reply