Computer Science Canada

Help me..

Author:  not_l33t [ Sat Apr 03, 2004 11:27 am ]
Post subject:  Help me..

Hey, it is my first time on this baord. I hope I make something good out of this. Well I am studying Turing in grade 10, in my high school (Toronto YAAH!).

Well it goes like this, my teacher has given us the book and just sits there on his ass, he hardly says or teach anything. Just wants us to do the stuff in the book , and the book ain't NOT so helpful.

Well you guys seem to be the gurus of Turing, so I have a question. I can't wrap my head around it. I hope you guys can.

" Ask the user for the upper left row and column and the bottom right row and column to represent the top left and bottom right corners of a rectangle. Ask the user for the number of the color they wish to use. Ask the user for the character indicated by the user going from the top-left to the top bottom-right co-ordinates."

I still don't get what I just typed down. Please help.

Author:  guruguru [ Sat Apr 03, 2004 1:09 pm ]
Post subject: 

By the way, "ain't NOT so helpful" is a double negative: it is not not so helpful, meaning that it is helpful Laughing !

Anyways... it asks you to get the x and y coordinates and color of a rectangle... i dont get the last part either Rolling Eyes .

code:
var x1, x2, y1, y2, color : int
put "What is x1? " ..
get x1
put "What is x2? " ..
get x2
put "What is y1? " ..
get y1
put "What is y2? " ..
get y2
put "What color? " ..
get color
Draw.FillBox (x1, y1, x2, y2, color)

There ya go...

Author:  Tony [ Sat Apr 03, 2004 1:42 pm ]
Post subject: 

eh... I think the question asked to draw a line using ASCII Confused
code:

 var x1, x2, y1, y2, c : int
 var letter:string(1)
put "What is x1? " ..
get x1
put "What is x2? " ..
get x2
put "What is y1? " ..
get y1
put "What is y2? " ..
get y2
put "What color? " ..
get c
put "what character to use?"
getch(letter)

colorback(black) %black background
color(c) %sets text colour to that of user's choice
cls

var len:int := round(Math.Distance(x1,y1,x2,y2)) %length of the line
var angle:int := round(arctand((y2-y1)/(x2-x1)))
for i:1..len %for each segment of the line
locate(round((cosd(angle)*i)+x1),round((sind(angle)*i))+y1) %locates the character on the screen
put letter %places character
end for

Author:  not_l33t [ Sat Apr 03, 2004 1:54 pm ]
Post subject: 

guruguru wrote:
By the way, "ain't NOT so helpful" is a double negative: it is not not so helpful, meaning that it is helpful Laughing !




Thank you, I know, its a purposeful fragment. It can be forgiven, depending on the situation. Very Happy

To Tony:

Thank you Tony. I will test this right now. It is very rare to see someone master Turing. Most of the time when I ask someone, they don't even have the least idea of this language. Exclamation

Well there is an error in one of the line.

code:
var len : int := round %(Math.distance (x1, y1, x2, y2)) %length of the line

Author:  Tony [ Sat Apr 03, 2004 2:00 pm ]
Post subject: 

not_l33t wrote:
It is very rare to see someone master Turing.

Laughing
you should check out our [Best of Submissions] post for some interesting programs writen in turing Wink

as for the error - Math.Distance is a part of turing v4.0.5 - there's a link for upgrade on the main page

Author:  Jodo Yodo [ Sat Apr 03, 2004 10:51 pm ]
Post subject: 

Tony, I think your program is a bit too complicated. I remember that question, and I think you're only supposed to use stuff such as repeat (ch, x1) and stuff, not advanced things.

Author:  apomb [ Sun Apr 04, 2004 12:23 pm ]
Post subject: 

Here is a simplified version of tony's , it fills a box with a specific character ...
code:
var x1, x2, y1, y2, c : int
var chara : string (1)
put "What is x1? " ..
get x1
put "What is x2? " ..
get x2
put "What is y1? " ..
get y1
put "What is y2? " ..
get y2
put "What color? " ..
get c
put "what character?"
getch (chara)
for i : x1 .. x2
    for ii : y1 .. y2
        locatexy (i, ii)
        color (c)
        put chara ..
    end for
end for

hope this helps!

Author:  not_l33t [ Sun Apr 04, 2004 3:04 pm ]
Post subject: 

Tony dude:

It doesn't work. Sad When the script was executed the only output was the an alphabet I put in, in some color.


Compwiz

Dude that script doesn't go after the question of character. It just ends there.

PS. Simple non 4.0.5 commands would be good. Very Happy

Thank you again for your help guys.

Author:  Jodo Yodo [ Sun Apr 04, 2004 9:47 pm ]
Post subject: 

Quote:

"Ask the user for the character indicated by the user going from the top-left to the top bottom-right co-ordinates."


What the ninny does this mean?

Author:  we64 [ Mon Apr 05, 2004 6:55 am ]
Post subject: 

People who wrote this question did not pass Grade 9 English Very Happy
I think CompWiz333's code looks like correct to me, I still don't get the last part.... it makes me remember the question on the Canadian Computer Competion....

Author:  Cervantes [ Mon Apr 05, 2004 7:59 am ]
Post subject: 

not_l33t wrote:

Compwiz

Dude that script doesn't go after the question of character. It just ends there.


it works for me.. that thing about getch just makes it so that as soon as one character (letter / number key) is pressed the program uses that as the string variable and continues execution.

Author:  Tony [ Mon Apr 05, 2004 8:03 am ]
Post subject: 

you might have picked a character color to be very similar to one of background so it's hard to see the output Confused

btw - my program works perfectly, though it might not be what the question is asking Laughing as we64 points out - this does remind me of this year's CCC, in sence that it doesn't make much sence and is open to interprepation. My program draws an ASCII line using input character between x1/y2 and x2/y2 row/columns.

Author:  not_l33t [ Mon Apr 05, 2004 12:00 pm ]
Post subject: 

Let me put the question again: (Oh man I hate this book.)

Quote:
Ask the user for the upper left row and column and the bottom right row and column to represent the top left and bottom right corners of a rectangle. Ask the user for the number of the color they wish to use. Ask the user for the character they wish to use. Create a filled in rectangle in the color and character indicated by the user going from top-left to the bottom-right co-ordinates.

Author:  we64 [ Mon Apr 05, 2004 8:38 pm ]
Post subject: 

are you sure you typed the question right? Very Happy Very Happy Very Happy

Author:  apomb [ Tue Apr 06, 2004 11:48 am ]
Post subject: 

oh, sorry for the "complicated" code, but it does draw a square and fills it with a letter inputted by the user, as well as inputted colors for both ascii character and background... since
Quote:
Create a filled[ in rectangle in the color and character indicated by the user going from top-left to the bottom-right co-ordinates.

uumm there is no 4.0.5 code anyway...! Smile

Author:  zylum [ Tue Apr 06, 2004 7:19 pm ]
Post subject: 

maybe this is what you're looking for?

code:
var x1, x2, y1, y2, c : int
var chara : string (1)
put "What is x1? " ..
get x1
put "What is x2? " ..
get x2
put "What is y1? " ..
get y1
put "What is y2? " ..
get y2
put "What color? " ..
get c
put "what character?"
getch (chara)
cls
color(c)
for i : y1 .. y2
    locate (maxrow - i, x1)
    put repeat (chara, x2 - x1 + 1)
end for


-zylum

Author:  the_short1 [ Tue Apr 06, 2004 8:03 pm ]
Post subject: 

zylums got it...... yea i had tmake a similiar program... except once it was just drawing in a verticle... then another program to make a horizontal...
(in both cases we used astericksts...)...


leave it to tony to always use Math.Distance... <<<he is adicted to it... almost as much as Dodge and his whatdotcolour...... Laughing Razz Very Happy

Author:  Tony [ Tue Apr 06, 2004 8:18 pm ]
Post subject: 

I think that zylum's output loop should be replaced with
code:

for i : y1 .. y2
    locate (round(Math.Distance(0,maxrow,0,i)), x1)
    put repeat (chara, round(Math.Distance(x2,0,x1,0)) + 1)
end for

Laughing

Author:  Paul [ Tue Apr 06, 2004 8:28 pm ]
Post subject: 

um... I see nothing for all of those?

Author:  apomb [ Wed Apr 07, 2004 5:51 pm ]
Post subject: 

well, how about that is exactly the same as mine, only it errors out EVERY time, so, if we can all agree that we helped this guy as much as we can before someone starts spamming in this thread!

Author:  the_short1 [ Thu Apr 08, 2004 11:05 am ]
Post subject: 

... again... tony are u a dicted to Math.Distance???? anyways... i agree with u compwizz... this is degenerating kinda quickly........


: