Posted: Mon Jan 12, 2004 5:31 pm Post subject: (No subject)
well i have most of my program figured out but i was having some trouble with assigning values to the cards
the only error is substring index is greater then the length of the string i think this means cards is greater then deck but how would i fix this
var name, temp, option : string
var bet : int := 100
var card, a, b : int
card := 1
function DECK : array 1 .. 52 of string
var deck : array 1 .. 52 of string
var cardz : array 1 .. 13 of string := init ("2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A")
var suit : array 1 .. 4 of string := init ("C", "D", "S", "H")
for x : 1 .. 4
for y : 1 .. 13
deck (card) := cardz (y) + suit (x)
card := card + 1
end for
end for
for i : 1 .. 52
randint (a, 1, 52)
randint (b, 1, 52)
temp := deck (a)
deck (a) := deck (b)
deck (b) := temp
end for
result deck
end DECK
function Getvalue (deck: string) : int
var value : int:=0
if index (deck(card)(1),"T,J,Q,K,") >0 then
value := 10
end if
result value
end Getvalue
View.Set ("nocursor")
var count : int := 1
var deck : array 1 .. 52 of string
var value : int := 1
var points : int
put " Enter your name "
get name : *
put name, " You have 100$ to start with what is your bet "
get bet
put " Your bet is ", bet, " dollars Good Luck !!!!! "
deck := DECK
loop
put "Would you like to Hit or Stand (you must hit on your first turn) "
get option : *
put "Your card is ", deck (count)
count := count + 1
points := Getvalue (deck (count))
put "ur total", points
exit when option = "stand"
end loop