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

Username:   Password: 
 RegisterRegister   
 Program is not working properly, any1 care to help?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
w0lv3rin3




PostPosted: Thu Apr 24, 2003 8:10 am   Post subject: Program is not working properly, any1 care to help?

This is a hang man game

when I put in the right answer to program still tells me its rong, WTF is up with that.

example

say the word is hi, then i type in hi, says its rong but its right, it will keep telling me that i have to enter in correct letter


code:
% Hangman Game
var area : array 0 .. 12 of string
var guessedword : string (12)
var letter : array 0 .. 7 of boolean
var letter1 : array 1 .. 7 of string (1)
var number, long : int
var word : array 1 .. 7 of string
var gfxwrong : int := 0
var letterchosen : boolean
var inwrd : array 1 .. 7 of string

put "Max letter's in a word is 10."
put "Use Lower Case. You have 7 Guesses"
delay (6000)
cls

put "Please enter 7 words."
put ""
for I : 1 .. 7
    put "Please enter word ", I, ".", " :>" ..
    get inwrd (I)
end for

cls

for I : 1 .. 7
    put I, ".", inwrd (I)
end for

procedure outputhangman
    put area (1), area (2), area (3), area (4),
        area (5), area (6), area (7)
end outputhangman

procedure noose
    drawline (350, 170, 350, 190, 4)
    drawline (350, 190, 400, 190, 4)
    drawline (400, 190, 400, 20, 4)
    drawline (425, 20, 375, 20, 4)
end noose

procedure graphics
    noose
    % head
    if gfxwrong = 1 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
    end if
    %neck
    if gfxwrong = 2 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
        drawline (350, 130, 350, 110, 3)
    end if
    %arm Right
    if gfxwrong = 3 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
        drawline (350, 130, 350, 110, 3)
        drawline (350, 110, 360, 120, 3)
    end if
    %arm Left
    if gfxwrong = 4 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
        drawline (350, 130, 350, 110, 3)
        drawline (350, 110, 360, 120, 3)
        drawline (350, 110, 340, 120, 3)
    end if
    %chest
    if gfxwrong = 5 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
        drawline (350, 130, 350, 70, 3)
        drawline (350, 110, 360, 120, 3)
        drawline (350, 110, 340, 120, 3)
    end if
    %leg right
    if gfxwrong = 6 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
        drawline (350, 130, 350, 70, 3)
        drawline (350, 110, 360, 120, 3)
        drawline (350, 110, 340, 120, 3)
        drawline (350, 70, 360, 60, 3)
    end if
    %leg left
    if gfxwrong = 7 then
        drawarc (350, 150, 20, 20, 0, 360, 3)
        drawline (350, 130, 350, 70, 3)
        drawline (350, 110, 360, 120, 3)
        drawline (350, 110, 340, 120, 3)
        drawline (350, 70, 360, 60, 3)
        drawline (350, 70, 340, 60, 3)
    end if
end graphics
procedure numbers
    locate (6, 1)
    put "There are ", long, " letters in the word."
end numbers

% initialization
word (1) := inwrd (1)
word (2) := inwrd (2)
word (3) := inwrd (3)
word (4) := inwrd (4)
word (5) := inwrd (5)
word (6) := inwrd (6)
word (7) := inwrd (7)

area (0) := " "
area (1) := " "
area (2) := " "
area (3) := " "
area (4) := " "
area (5) := " "
area (6) := " "
area (7) := " "

letter (0) := true
letter (1) := false
letter (2) := false
letter (3) := false
letter (4) := false
letter (5) := false
letter (6) := false
letterchosen := false

randomize
randint (number, 1, 7)
guessedword := word (number)
long := length (guessedword)
for times : 1 .. 7
    letterchosen := false
    cls
    graphics
    outputhangman
    locate (2, 1)
    for I : 1 .. long
        put "_" ..
    end for
    locate (3, 1)
    put "Enter a letter in lowercase.  Do not press return."
    put ""
    numbers
    locate (7, 1)
    put "You have ", 8 - times, " guesses left."
    getch (letter1 (times))
    cls
    for d : 1 .. long
        if word (number) (d .. d) = letter1 (times) then
            area (d) := letter1 (times)
            letter (d) := true
            letterchosen := true
            cls
            outputhangman
            graphics
            gfxwrong := gfxwrong + 0
        end if
    end for
    if letterchosen = false then
        locate (11, 1)
        put "Sorry, wrong letter."
        delay (500)
        gfxwrong := gfxwrong + 1
        graphics
    end if
    outputhangman
    if letter (1) = true and letter (2) = true and letter (3) = true and
            letter (4) = true and letter (5) = true and
            letter (6) = true and letter (long) = true and letter (long - 1)
            = true and letter (long - 2) = true and
            letter (long - 3) = true and letter (long - 4) = true and
            letter (long - 5) = true and letter (long - 6) = true then
        exit
    end if
    graphics
end for
if letter (1) = true and letter (2) = true and letter (3) = true and
        letter (4) = true and letter (5) = true and
        letter (6) = true and letter (long) = true and letter (long - 1) =
        true and letter (long - 2) = true and
        letter (long - 3) = true and letter (long - 4) = true and
        letter (long - 5) = true and letter (long - 6) = true then
    cls
    outputhangman
    locate (12, 5)
    put "Congratulations.  You have won the game."
else
    cls
    put
        "Sorry, you have run out of guesses.  You lost the game.  The word was, "
    put word (number), "."
    gfxwrong := 7
    graphics
end if
% end of game
Sponsor
Sponsor
Sponsor
sponsor
Delta




PostPosted: Thu Apr 24, 2003 8:31 am   Post subject: (No subject)

Erase the space between the quotes that may work because that all I see wrong without looking at it too much, besides the amount of lines that you used, maybe you'll cut it down later.

code:

area (0) := ""
area (1) := ""
area (2) := ""
area (3) := ""
area (4) := ""
area (5) := ""
area (6) := ""
area (7) := ""
w0lv3rin3




PostPosted: Thu Apr 24, 2003 8:42 am   Post subject: (No subject)

nope, still get same thing
Delta




PostPosted: Thu Apr 24, 2003 8:48 am   Post subject: (No subject)

I will check through it a little more and see what comes up

okay umm I just tested it and it works fine no error except that the whole thing is screwed... my word was pete.

I typed p it said I got it wrong but it should have been right. Confused you have to look through your plan on how things are to be done.
w0lv3rin3




PostPosted: Thu Apr 24, 2003 8:59 am   Post subject: (No subject)

yes thats my problem
Delta




PostPosted: Thu Apr 24, 2003 9:01 am   Post subject: (No subject)

Okay maybe next period I'll be able to help you with it I will look it over and see what happens.
w0lv3rin3




PostPosted: Thu Apr 24, 2003 9:02 am   Post subject: (No subject)

thx man, i'll also get my teacher to help me, see what he can do
Delta




PostPosted: Thu Apr 24, 2003 9:05 am   Post subject: (No subject)

Sounds cool! I pv or email it to you when I get it working or I'll just tell you what was screwing it up. Then you can fix it. If you get it fixed tell me
Smile
Sponsor
Sponsor
Sponsor
sponsor
w0lv3rin3




PostPosted: Thu Apr 24, 2003 9:21 am   Post subject: (No subject)

k thx man, i need this fixed, i want to get it working
Delta




PostPosted: Thu Apr 24, 2003 10:08 am   Post subject: (No subject)

Not enough time to fix it and do my work so I will bring it home.
Wait first try to comment all your lines that are useful and tell me what they do... or are susposed to
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 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: