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

Username:   Password: 
 RegisterRegister   
 using arrays for blackjack???
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Poland13




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
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 2 of 2  [ 16 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: