# Problem with constructor

**URL:** <https://discourse.processing.org/t/problem-with-constructor/36566>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 24, 2022, 2:42am UTC](https://discourse.processing.org/t/problem-with-constructor/36566 "2022-04-24T02:42:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyanLovesPlanes](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@RyanLovesPlanes](https://discourse.processing.org/u/RyanLovesPlanes)\
**Post date:** [April 24, 2022, 2:42am UTC](https://discourse.processing.org/t/problem-with-constructor/36566/1 "2022-04-24T02:42:43Z")

</div>

hey ya’ll! My code is almost complete but I am having a problem with one of my classes not initializing a function I made. Specifically the “kill” function ( atarget.kill(); ). it says that kill() expects parameters like “kill(Ball)” however when I put Ball in it doesn’t work. Same with aBall. anyone know what is wrong? here is the code in question.  
from a separate class  
void kill(Ball aBall){

```
if(bottom>=aBall.c1d+2.5 &&front>=aBall.c1d+2.5){
   isCrashed=true;
   println("hit");

```

}  
}  
from the constructor

for (target atarget : targetList) {

```
atarget.render();
atarget.wallDetect();
atarget.move();
atarget.reset();

```

//where the problem is  
atarget.kill();

```
for (laffey aLaffey : laffeyList) {
  aTarget.crash(aLaffey);
}
//println(aTarget.isCrashed);

```

}  
}

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [April 24, 2022, 4:48am UTC](https://discourse.processing.org/t/problem-with-constructor/36566/2 "2022-04-24T04:48:14Z")

</div>

Those code pieces are hard to put together and I can’t say just based on them what’s wrong. My guess is that your if statement `if(bottom>=aBall.c1d+2.5 &&front>=aBall.c1d+2.5)` isn’t working as you expect.
