Some
Techniques
VARIABLES
PROCEDURES
card(52)
sort(13)
tok$(4,2)
kmcmh
ran
temp
item
dart
comp
inc
seat
aC,dn;
row
Iin$
max
p
n
shuffle
split
sortem
layout
printem
gelline
stores card numbers
used
to
sort each hand
stores tokens
H:,
C:,
D:,
S:
working loop variables
random position for card exchange
used
in
card exchange
card
to
be inserted
in
sort
pointer
to
find position
in
sort
hold card number
in
sort
pixel increment
in
card
rows
current deal' position
cursor position for characters
current
row
for characters
builds up
row
of characters
highest card number
pOints
to
card position
current number of card
shuffles 52 cards
splits cards
into
four hands and calls sortem
to
sort each hand
sorts
13
cards
in
ascending order
provides background colour, border and table
prints each line of card symbols
gets one
row
of cards and converts numbers into the symbols
A, 2
,3,4,5,6,
7.,8,9,T,J,Q,
K
•
•
PROGRAM DESIGN
1.
OUTLINE 2.
3.
4.
5.
6.
7.
102
Declare
arrays,
pick up tokens' and place 52 numbers
in
array card.
Shuffle cards.
Split into 4 hands and sort each.
OPEN screen window
Fix
the screen layout
Print the four hands.
CLOSE the screen window
100
DIM
card(52)
,sart
(13)
,tak$(4,2)
110
FOR
k = 1
TO
4 :
READ
tak$(k)
120
FOR
k =1
TO
52 :
LET
card(k)
=k
130
shuffLe
140
split
150
OPEN
#6,scr
440x220a35x15
160
Layaut
-
17.0
pri
ntem
180
CLOSE
#6
190
DEFine PROCedure
shuffle
200
FOR
c =
52
TO
3
STEP
-1
210
LET
ran
=
RND(1
TO
c-1)
220
LET
temp =
card(c)
230
LET
card(c)
=
card(ran)
240
LET
card(ran)
= temp
250
END
FOR
c
260
END
DEFine
27.0
DEFine PROCedure
split
280
FOR
h =1
TO
4
290
FOR
c =1
TO
13
300
LET
sart(c)
=
card«h-1)*13+c)
310
END
FOR
c
320
sartem
330
FOR
c = 1
TO
13
340
LET
card«h-1)*13+c)
sart(c)
350
END
FOR
c
360
END
FOR
h
37.0
END
DEFine
380
DEFi ne PROCedure
sartem
390
FOR
item
=2
TO
13
400
LET
dart
=
item
12/84
•
•