# Constructor Argument for COLOR ~ Dan Shiffman book ~ exercise 8-6

**URL:** https://discourse.processing.org/t/constructor-argument-for-color-dan-shiffman-book-exercise-8-6/10415
**Category:** Coding Questions
**Created:** [April 17, 2019, 11:01pm UTC](https://discourse.processing.org/t/constructor-argument-for-color-dan-shiffman-book-exercise-8-6/10415 "2019-04-17T23:01:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [April 17, 2019, 11:01pm UTC](https://discourse.processing.org/t/constructor-argument-for-color-dan-shiffman-book-exercise-8-6/10415/1 "2019-04-17T23:01:53Z")

</div>

I want the eyes to appear in **RED** in one iteration of the Zoog object, and to appear **GREEN** in the second iteration of the Zoog object.  
However the eyes are currently appearing **BLACK** in both iterations.  
What have I done incorrectly in the code below:

```auto
Zoog zoog1;
Zoog zoog2;

void setup() {
  size (200, 200);
  zoog1 = new Zoog (color(255,0,0), 100, 125, 60, 60, 16);
  zoog2 = new Zoog (color(0,255,0), 50, 60, 30, 30, 8);
}

void draw(){
  background(255);
  float factor = constrain (mouseX/10, 0, 5);
  
  zoog1.jiggle(factor);
  zoog1.display();
  
  zoog2.jiggle(factor);
  zoog2.display();
}

class Zoog {

  float c, x, y, w, h, eyeSize;
  Zoog (color tempC, float tempX, float tempY, float tempW, float tempH, float tempEyeSize) {
    c = tempC;
    x = tempX;
    y = tempY;
    w = tempW;
    h = tempH;
    eyeSize = tempEyeSize;
    
  }

  void jiggle (float speed) {
    x = x + random(-1, 1)*speed;
    y = y + random(-1, 1)*speed;

    x = constrain(x, 0, width);
    y = constrain(y, 0, height);
  }
  void display() {
    rectMode(CENTER);
    ellipseMode(CENTER);

    //draw Zoog's arms with a for loop
    for (float i = y - h/3; i < y + h/2; i += 10) {
      stroke(0);
      line(x - w/4, i, x + w/4, i);
    }
    //Zoog's body
    stroke(0);
    fill(175);
    rect(x, y, w/6, h);

    //Zoog's head
    stroke(0);
    fill(255);
    ellipse(x, y-h, w, h);

    //Zoog's eyes
    noStroke();
    fill(c);
    ellipse(x-w/3, y-h, eyeSize, eyeSize*2);
    ellipse(x+w/3, y-h, eyeSize, eyeSize*2);

    //Zoog's legs
    stroke(0);
    line(x-w/12, y+h/2, x-w/4, y+h/2 +10);
    line(x+w/12, y+h/2, x+w/4, y+h/2 +10);
  }
}

```

---

<div class="post-metadata">

### Author: ![zenemig](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zenemig/32/4418_2.png) [@zenemig](https://discourse.processing.org/u/zenemig)
#### Post date: [April 18, 2019, 1:24am UTC](https://discourse.processing.org/t/constructor-argument-for-color-dan-shiffman-book-exercise-8-6/10415/2 "2019-04-18T01:24:19Z")

</div>

Hi @debxyz,  
Your variable c, which is the one who store the color of the eyes is declared as a float, and you are passing a color variable as the parameter.

The code work as you expected when you declare the variable c as a color type variable:

```auto
class Zoog {

color c;
float x, y, w, h, eyeSize;
...

```

---

<div class="post-metadata">

### Author: ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)
#### Post date: [April 18, 2019, 2:51pm UTC](https://discourse.processing.org/t/constructor-argument-for-color-dan-shiffman-book-exercise-8-6/10415/3 "2019-04-18T14:51:04Z")

</div>

Thank you @zenemig! It now works. 🙂
