Solved

writing a value to a methd from another class using a loop

Posted on 2008-10-23
3
166 Views
Last Modified: 2013-11-23
i have a program that needs to write values to a method from another class, this method writes values to a popup for colours etc..  at first i am just trying to get the values in the for loop to get passed back to the .pix class (which already has the required code for the popup etc..)
so i just want it to loop through the values one by one until ver reaches 256, at the moment the values in the declaration i.e. 33, 0, 55, 2 appear but that it is it, the for loop does not have any effect?  hope this is clear, as you can gather I am new to this!!!  the code below is just a snippet...

int hor = 33;
int ver = 0;
int length = 55;
int shade =2;
            
plotdavey.pix(hor, ver, length, shade);
            
       for (ver=0;ver<256;ver++) {
              hor = hor++;      
                     length = length++;      
             shade = shade++;
}
0
Comment
Question by:ckawebcreation
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
divyeshhdoshi earned 80 total points
ID: 22784286
You should use
 for (ver=0;ver<256 && hor<256 && length<256 && shade < 256;ver++) {
              hor = hor++;      
                     length = length++;      
             shade = shade++;
0
 

Author Comment

by:ckawebcreation
ID: 22784542
hi divyeshhdoshi,

i got it working now thanks, i have another problem, i am being a bit vague because i am creating the program bit by bit and because i am a beginner i have to get the basicas working first..  What i have now is the code below.

it will draw the lines if I use the commented out for loop but if I use the count for loop it gives me an error, the reason for the for loop is to create a line that is set to the awidth (which gets declared early on) and once it reaches the awidth, start reading the next line and so on until it runs out of numbers and all the lines have been drawn revealing an image.

the error is > expected for (count=count+length;<awidth;)  --- and it has an arrow pointing at the semi-colon after the h?  

any pointers would be great!!!!


            int hor = 0;
            int ver = 0;
            int length = 0;
            int shade = 0;
            int count =0;      
                        
             //      for (ver=0;ver<256;ver++) {
                    
                    for (count=count+length;<awidth;) {
                    hor = hor;      
                         length = inputFile.nextInt();      
                         shade = inputFile.nextInt();
                         count = length +shade;
                         plotdarryl.plot(hor, ver, length, shade);
                   
                          }


0
 

Author Comment

by:ckawebcreation
ID: 22786180
cheers divyeshhdoshi:
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question