We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › cannot find a class or type named "Starchaos"
Page Index Toggle Pages: 1
cannot find a class or type named "Starchaos" (Read 852 times)
cannot find a class or type named "Starchaos"
Mar 23rd, 2010, 8:41pm
 
please help me with what is wrong. I've checked things over and over for spelling, what is the issue??? Sad need help asap!!

Code:


Star stara;
Starchaos starb;

void setup() {
 size(500, 500);
 smooth();
 stara = new stara(1);
 starb = new starb(1);

}

void draw() {
 background(64);
 fill(255);
 rect(0, 0, width/2, height);

 fill(255, 0, 0);
 if  (mouseX < 250) {
   stara.display();

 }
 else {
   starb.display();

 }

}


//------------------


//-----------------

class Star {
 float starsz;
 Star(float starSize) {
   starsz = starSize;
 }
 void display() {
   scale(starsz);
   int x = 0;
   int limitX = 250;
   int y = 0;
   int limitY = 500;
   noStroke();
   fill(255, 0, 0);
   while(y <= limitY) {
while(x <= limitX) {

 //star
 pushMatrix( );

 for(int i=0; i < points; i++) {
   rotate( TWO_PI / 5 );
   triangle(-15/2, 0, 0, 100, 15/2, 0);
 }
 popMatrix( );

}
}
   }
 }  
}


//-----

class Starchaos {
 float starcsz;
 Starchaos(float starchaosSize) {
   starcsz = starchaosSize;
 }
 void display() {
   scale(starcsz);
float[] x;
   float[] y;
   x = new float[100];
   y = new float[100];
   for (int i=0; i < x.length; i++) {
x[i] = random(width);
y[i] = random(height);  
   }
   background(0);
   fill(255, 0, 0);
   noStroke();
   ellipse(width/2, height/2, 200, 200);
   fill(255);
   for (int i=0; i < x.length; i++) {
ellipse(x[i], random(height), 50, 50);
//   triangle(x[i], random(height), x[i], random(height), random(width), y[i]);
 }
}
}
Re: cannot find a class or type named "Starchaos"
Reply #1 - Mar 23rd, 2010, 9:40pm
 
Edit: there is one too many right curly's after the Star class.
Also, changing
"stara = new stara(1);
 starb = new starb(1);"

to
"stara = new Star(1); //stara is a Star
 starb = new Starchaos(1); //starb is a Starchaos"

may help. Wink
Re: cannot find a class or type named "Starchaos"
Reply #2 - Mar 23rd, 2010, 9:49pm
 
Quote:
Star stara;
Starchaos starb;

void setup() {
  size(500, 500);
  smooth();
  ///???????????????????????????????
  //stara = new stara(1);
  //starb = new starb(1);
  //????????????????????????????????
  // Did you mean this? :::::::::::::::::
  stara = new Star(1);
  starb = new Starchaos(1);
  ///:::::::::::::::::::::::::::::::
}

void draw() {
  background(64);
  fill(255);
  rect(0, 0, width/2, height);
  fill(255, 0, 0);
  if  (mouseX < 250) {
    stara.display();
  }
  else {
    starb.display();
  }
}


//------------------


//-----------------

class Star {
  float starsz;
  Star(float starSize) {
    starsz = starSize;
  }
  void display() {
    scale(starsz);
    int x = 0;
    int limitX = 250;
    int y = 0;
    int limitY = 500;
    noStroke();
    fill(255, 0, 0);
    while(y <= limitY) {
      while(x <= limitX) {
        //star
        pushMatrix( );
        // Added this::::::::::::::::::::::::::::::
        int points = 5;
        //:::::::::::::::::::::::
        // points undefined??????????????????????????????????
        for(int i=0; i < points; i++) {
          rotate( TWO_PI / 5 );
          triangle(-15/2, 0, 0, 100, 15/2, 0);
        }
        popMatrix( );
      }
    }
  }
}  


///????????????????????????????????
//} // This looks like one too many.
///????????????????????????????????

//-----

class Starchaos {
  float starcsz;
  Starchaos(float starchaosSize) {
    starcsz = starchaosSize;
  }
  void display() {
    scale(starcsz);
    float[] x;
    float[] y;
    x = new float[100];
    y = new float[100];
    for (int i=0; i < x.length; i++) {
      x[i] = random(width);
      y[i] = random(height);  
    }
    background(0);
    fill(255, 0, 0);
    noStroke();
    ellipse(width/2, height/2, 200, 200);
    fill(255);
    for (int i=0; i < x.length; i++) {
      ellipse(x[i], random(height), 50, 50);
      //   triangle(x[i], random(height), x[i], random(height), random(width), y[i]);
    }
  } 
}



Ctrl-t formats messy code. It may complain at you if you have too many { or }'s. Maybe. The best thing to do is to indent properly! "points was not defined, and you were also trying to use a variable name as a type.
Re: cannot find a class or type named "Starchaos"
Reply #3 - Mar 24th, 2010, 6:17am
 
THANK YOU SO MUCH!
I was overly tired and could no notice the extra curly brace! PHEW Cheesy
Page Index Toggle Pages: 1