Computer Science Canada

second ever program - blackjack

Author:  noobprogrammer123 [ Sat May 01, 2004 4:56 pm ]
Post subject:  second ever program - blackjack

this is the second program i have ever made

Author:  Tony [ Sat May 01, 2004 5:05 pm ]
Post subject: 

ouch, I cry Crying or Very sad

well you're just starting programming... so I suppose you just don't know any better Thinking

but don't worry - soon you'll be able to rewrite blackjack to look better and be under 100 lines of code Wink

Author:  Paul [ Sat May 01, 2004 5:06 pm ]
Post subject: 

Nice program. If its that big, why not bugproof it? like not allowing people to enter an character when betting.

Author:  guruguru [ Sun May 02, 2004 10:52 am ]
Post subject: 

Pretty good for second program. Try using less ifs, then it would be sweet.

Author:  beedub [ Thu May 06, 2004 9:15 pm ]
Post subject: 

maybe using a record so, u can add suits and other values. good try i guess

Author:  the_short1 [ Thu May 06, 2004 10:04 pm ]
Post subject: 

yea... good for second program.... i woulkdn;t think a noob ** beginer programer... would attemp something like that... VDG...!!


btw...
beedub... both ur avatar and sig aint working..
PM me if u want me to host ur pictures at my server ***never fails..

Author:  zomg [ Wed Oct 13, 2004 1:29 pm ]
Post subject: 

nice work for a 2nd program lol better than my 2nd
4 bits for effort

Author:  wtd [ Wed Oct 13, 2004 6:32 pm ]
Post subject: 

You're working too hard. Smile

code:
    if userCardNum1 = 1 then
        userCard1 := "A"
    elsif userCardNum1 = 2 then
        userCard1 := "2"
        userCount1 := 2
    elsif userCardNum1 = 3 then
        userCard1 := "3"
        userCount1 := 3
    elsif userCardNum1 = 4 then
        userCard1 := "4"
        userCount1 := 4
    elsif userCardNum1 = 5 then
        userCard1 := "5"
        userCount1 := 5
    elsif userCardNum1 = 6 then
        userCard1 := "6"
        userCount1 := 6
    elsif userCardNum1 = 7 then
        userCard1 := "7"
        userCount1 := 7
    elsif userCardNum1 = 8 then
        userCard1 := "8"
        userCount1 := 8
    elsif userCardNum1 = 9 then
        userCard1 := "9"
        userCount1 := 9
    elsif userCardNum1 = 10 then
        userCard1 := "10"
        userCount1 := 10
    elsif userCardNum1 = 11 then
        userCard1 := "J"
        userCount1 := 10
    elsif userCardNum1 = 12 then
        userCard1 := "Q"
        userCount1 := 10
    elsif userCardNum1 = 13 then
        userCard1 := "K"
        userCount1 := 10
    end if


Can easily become:

code:
    if userCardNum1 = 1 then
        userCard1  := "A"
    elsif userCardNum1 = 11 then
        userCard1  := "J"
        userCount1 := 10
    elsif userCardNum1 = 12 then
        userCard1  := "G"
        userCount1 := 10
    elsif userCardNum1 = 13 then
        userCard1  := "K"
        userCount1 := 10
    else
        userCard1  := intstr(userCardNum1)
        userCount1 := userCardNum1
    end if


Which would be even easier as a case construct, though I'm not entirely sure of the syntax for it in Turing.

code:
case userCardNum1 of
   label 1:
      userCard1  := "A"
   label 11:
      userCard1  := "J"
      userCount1 := 10
   label 12:
      userCard1  := "G"
      userCount1 := 10
   label 13:
      userCard1  := "K"
      userCount1 := 10
   else
      userCard1  := intstr(userCardNum1)
      userCount1 := userCardNum1
end case


: