Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

746 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

9 Experts available now in Live!

Get 1:1 Help Now