?
Solved

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

Posted on 2008-10-23
3
Medium Priority
?
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
divyeshhdoshi earned 240 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month11 days, 21 hours left to enroll

752 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