# Help with my Lab

**URL:** <https://discourse.processing.org/t/help-with-my-lab/20111>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 24, 2020, 10:55pm UTC](https://discourse.processing.org/t/help-with-my-lab/20111 "2020-04-24T22:55:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan25711](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@Jonathan25711](https://discourse.processing.org/u/Jonathan25711)\
**Post date:** [April 24, 2020, 10:55pm UTC](https://discourse.processing.org/t/help-with-my-lab/20111/1 "2020-04-24T22:55:28Z")

</div>

So I have this code that I’m doing for a lab, thankfully my Comp-Sci teacher gave me some extra time. However, I’m confused about how the code won’t seem to work. It all makes sense to me, so maybe an eye from someone who could code better could help. The lab requires 12 buildings, all 50 in length, and they need randomized heights. With a click of a mouse, the buildings should change in heights, and the lights should change. I have the lights and the 200 random stars on lockdown, so it’s all good there. Here’s my code:

```auto

int [] buildingY = new int [12];
int [] starX = new int [200];
int [] starY = new int [200];
int i = 0;
int x = i*50;
int y = height-buildingY[i]*50;

void setup()
{
  size(600,450);
  rectMode(CORNER);
  ellipseMode(CORNER);
  drawAll();
  randomize();
}

void draw()
{
}

void drawAll()
{
  drawSky();
  drawBuildings();
}
// this is used to randomize the 200 stars and the size of the building.
void randomize()
{
   for(i=0; i<12; i++);
  {
    buildingY[i] = (int)random(1,8);
  }
  
  for(i=0; i<200; i++)
  {
    starX[i] = (int) random(0,width);
    starY[i] = (int) random(0,height);
  }
}
// this draws the sky and the randomized stars
void drawSky()
{
  background(0);
  stroke(255);
  strokeWeight(1);
  for(i=0; i<200; i++)
  {
    starX[i] = (int) random(0,width);
    starY[i] = (int) random(0,height);
    point(starX[i],starY[i]);
  }
  fill(255);
  ellipse(500,-50,150,150);
}
  // this calls upon the building parameters method, to draw the buildings 12 times. 
void drawBuildings()
{
  for(i=0; i<12; i++)
  {
    drawBuildingParams();
  }
}
// used to draw the buildings and the windows.
void drawBuildingParams()
{
  fill(100);
  stroke(0);
  rect(x,y,50,height-y);
  for(int col = x+5; col<x+45; col+=9)
  {
    for(int row = y+10; row<height; row+=25)
    {
      if((int)random(2)==0)
      
        fill(200,200,0);
        else
        fill(0);
        rect(col,row,5,12);
      }
    }
  }
// this randomizes the stars, height of the buildings, and the windows being yellow or black with a click.
void mousePressed()
{
  randomize();
  drawAll();
}

```

Thanks,  
-Jonathan

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 25, 2020, 12:51am UTC](https://discourse.processing.org/t/help-with-my-lab/20111/2 "2020-04-25T00:51:42Z")

</div>

Take a look at this:

```auto
for(i=0; i<12; i++);

```

`:)`

---

<div class="post-metadata">

**Author:** ![Jonathan25711](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@Jonathan25711](https://discourse.processing.org/u/Jonathan25711)\
**Post date:** [April 25, 2020, 12:53am UTC](https://discourse.processing.org/t/help-with-my-lab/20111/3 "2020-04-25T00:53:53Z")

</div>

Even when I change it to 11, it doesn’t draw the buildings, only one will be drawn. And the height isn’t randomized. Am I calling the different methods wrong?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 25, 2020, 1:27am UTC](https://discourse.processing.org/t/help-with-my-lab/20111/4 "2020-04-25T01:27:27Z")

</div>

> <https://stackoverflow.com/questions/14112515/semicolon-at-end-of-if-statement>

`:)`

---

<div class="post-metadata">

**Author:** ![Jonathan25711](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@Jonathan25711](https://discourse.processing.org/u/Jonathan25711)\
**Post date:** [April 25, 2020, 1:28am UTC](https://discourse.processing.org/t/help-with-my-lab/20111/5 "2020-04-25T01:28:43Z")

</div>

…I feel kinda dumb lol. When I applied the fix, the other buildings wouldn’t draw still. I don’t know if I’m doing the loops wrong, or if I’m calling the methods wrong.
