Solved

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

Posted on 2008-10-23
3
164 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 77
Exception after setting jdbc session management 2 52
firstswap challenge 20 68
sites similar to codingbat to improve coding hanson skills 3 41
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now