var deck : array 1 .. 52 of int
var Totals : array 1 .. 2 of int
var card : int
var Ptotal, Dtotal, Dtota : int
var ace : boolean
var yesno : string
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"
Ptotal := Ptotal + 11
Dtotal := Dtotal + 11
ace := true
elsif deck (card) mod 13 = 1 then
cardNo := "2"
Ptotal := Ptotal + 2
Dtotal := Dtotal + 2
elsif deck (card) mod 13 = 2 then
cardNo := "3"
Ptotal := Ptotal + 3
Ptotal := Ptotal + 3
elsif deck (card) mod 13 = 3 then
cardNo := "4"
Ptotal := Ptotal + 4
Dtotal := Dtotal + 4
elsif deck (card) mod 13 = 4 then
cardNo := "5"
Ptotal := Ptotal + 5
Dtotal := Dtotal + 5
elsif deck (card) mod 13 = 5 then
cardNo := "6"
Ptotal := Ptotal + 6
Dtotal := Dtotal + 6
elsif deck (card) mod 13 = 6 then
cardNo := "7"
Ptotal := Ptotal + 7
Dtotal := Dtotal + 7
elsif deck (card) mod 13 = 7 then
cardNo := "8"
Ptotal := Ptotal + 8
Dtotal := Dtotal + 8
elsif deck (card) mod 13 = 8 then
cardNo := "9"
Ptotal := Ptotal + 9
Dtotal := Dtotal + 9
elsif deck (card) mod 13 = 9 then
cardNo := "10"
Ptotal := Ptotal + 10
Dtotal := Dtotal + 10
elsif deck (card) mod 13 = 10 then
cardNo := "Jack"
Ptotal := Ptotal + 10
Dtotal := Dtotal + 10
elsif deck (card) mod 13 = 11 then
cardNo := "Queen"
Ptotal := Ptotal + 10
Dtotal := Dtotal + 10
elsif deck (card) mod 13 = 12 then
cardNo := "King"
Ptotal := Ptotal + 10
Dtotal := Dtotal + 10
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
loop
ace := false
Dtotal := 0
Ptotal := 0
put "%%%%%%%%%%%%"
put "Dealer card"
showCard
put "%%%%%%%%%%%%"
put " "
Totals (1) := Dtotal
Ptotal := 0
%%%%%%%%%%%%%%
showCard
showCard
put " "
Dtotal := 0
put "Your total is ", Ptotal %%
%%%%%%%%
if Ptotal = 21 then
put "Blackjack!, you win!"
elsif Ptotal < 22 then
put "Hit (s) or Stand (s)"
get yesno
end if
if yesno = "s" then
exit
elsif yesno = "h" then
showCard
end if
Dtotal := 0
%%%%%%%%
if Ptotal = 21 then
put "Blackjack!, you win!"
elsif Ptotal < 22 then
put "Hit (s) or Stand (s)"
get yesno
end if
end loop |