 Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki Blog Search Turing Chat Room Members
using randint, Help asap, isp due tomoro!!       Author Message
johnbobbit Posted: Sat Jan 17, 2004 8:08 pm   Post subject: using randint, Help asap, isp due tomoro!!

I am doing an isp which requires the usage of arrays, which i dont understand well.
i have to make 5 different sized blocks each a different color appear on the screen in random order.
I am able to make one square come out and each time it changes size and colour.
now i need to get all of it's 5 forms to come out in random order. Thats the part i am stuck on and i've tried everything for about 6 hours now.
if any body can help plz correct and guide me.
here is the userInput part of my program code:

var num : array 1 .. 5 of int
var coord : array 1 .. 5 of int
randomize
var box : array 1 .. 5 of int := init (60, 80, 100, 120, 140)
var boxEndx : array 1 .. 5 of int := init (0, 0, 0, 0, 0)
var boxEndy : array 1 .. 5 of int := init (60, 80, 100, 120, 140)
var c : int := 0
var x : int := 0
var f : string (1)

procedure userInput
randomize
for y : 1 .. 5
randomize
x := x + 1
randint (num (x), 1, 5)

put (num (x))

exit when x > 5
randint (num (x), 1, 5)

if num (x) = 1 then
c := 7
elsif num (x) = 2 then
c := 9
elsif num (x) = 3 then
c := 12
elsif num (x) = 4 then
c := 14
else
c := 5
end if
end for
for a : 1 .. 5
for s : 1 .. 5
for y : 1 .. 5
x := x + 1
drawfillbox (100, 100, box (num (y)) + boxEndy (num (y)), box (num (y)) + box (num (y)), c)
end for
end for
end for
end userInput      Posted: Sat Jan 17, 2004 9:49 pm   Post subject: (No subject)

k...first of all, you dont need to post the same post twice, just leave one, and wait for it to be answered. Secondly, dont name posts like "I NEED HELP ON THIS F*CKEN BITCH!!" of whatever it was. (This post title is good though.) With seeing two p osts with the same thing, I decided not to read your post, and just explain arrays to you, fair enough.
 code: %Declares an array with the name "numbers" with ten integers in it var numbers:array 1..10 of int %In a for statement, each integer in the "numbers" array is assigned a %number, which is equal to "i" for i:1..10 numbers(i):=i end for %In a for statement, it displays the values of all the integers in the %"numbers" array for i:1..10 put "Numbers(",i,")= ",numbers(i) end for %Makes the fifth integer in the "numbers" array equal to 8 numbers(5):=8

Thats how an array works...if you need more information, ask specifically, and nicely. This can be manipulated like so:
 code: var x,y:array 1..3 of int x(1):=100 y(1):=100 x(2):=300 y(2):=200 x(3):=500 y(3):=300 for i:1..3 Draw.Box(x(i)-10,y(i)-10,x(i)+10,y(i)+10,255) end for johnbobbit Posted: Sun Jan 18, 2004 3:19 pm   Post subject: It is still the same

I need to randomize in the order which each block comes out recneps  Posted: Sun Jan 18, 2004 4:20 pm   Post subject: (No subject)

so have a randint make a random number, and have it call up the boxsize of that nuber in the array, like

randint(rand,1,5)

and whatever it gives, tell it to call up that siz box..

drawbox(x(rand),y(rand),(x(rand)+50),(y(rand)+50),7)

thatd make a box that is at the position that you randomized, and make it 50 by 50 pixels. understand? johnbobbit Posted: Sun Jan 18, 2004 4:46 pm   Post subject: Thanks for the reply

Yes i understand that and i have wrote the new userInput procedure.
The problem is that i need the 5 boxes which are differently sized, to come out in different order each time. so onece the largest may come first or second, or third or fourth or last. This goes for all the boxes.

Heres the userInput procedre:

%user input
procedure userInput
var x : array 1 .. 5 of int := init (60, 80, 100, 120, 140)
var y : array 1 .. 5 of int := init (60, 80, 100, 120, 140)
var space : array 1 .. 5 of int := init (-50, 20, 110, 220, 350)
for i : 1 .. 5
drawfillbox (space (i) + x (i), 200, space (i) + x (i) + x (i), y (i) + 200, i)
end for
end userInput
userInput Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First        Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: