# Why Always report errors

**URL:** https://discourse.processing.org/t/why-always-report-errors/36342
**Category:** Coding Questions
**Tags:** homework
**Created:** [April 15, 2022, 6:16am UTC](https://discourse.processing.org/t/why-always-report-errors/36342 "2022-04-15T06:16:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jiajia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jiajia/32/16099_2.png) [@jiajia](https://discourse.processing.org/u/jiajia)
#### Post date: [April 15, 2022, 6:16am UTC](https://discourse.processing.org/t/why-always-report-errors/36342/1 "2022-04-15T06:16:06Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

\</\>Mover movers = new Mover[100];  
液体;  
void setup（）{  
size（640，320）;  
smooth（）;  
for（int i =0;i\<movers.length;i++）{  
movers[i] = new Mover（random（0.1，5），0，0）;  
}  
液体 = 新液体（0，高度，2，高度/2，0.1）;  
}

void draw（）{  
background（255）;  
liquid.display（）;  
PVector wind=new PVector（0.01，0）;  
PVector gravity=new PVector（0，0.1）;  
for（int i =0;i\<movers.length;i++）{  
if（movers[i].isInside（liquid））{  
movers[i].drag（liquid）;  
}  
浮点数 m =0.1\*移动器[i].质量;  
PVector gravity = new PVector（0，m）;  
浮点数 c =0.1;  
PVector friction = movers[i].velocity.get（）;  
friction.mult（-1）;  
friction.normalize（）;  
friction.mult（c）;

movers[i].applyForce（friction）;  
movers[i].applyForce（wind）;  
移动器[i].applyForce（gravity）;  
movers[i].update（）;  
movers[i].display（）;  
movers[i].checkEdges（）;  
}  
}

类移动器{  
PVector 位置;  
PVector 速度;  
PVector 加速度;  
浮子质量;  
Mover（float m，float x，float y）{  
mass= m;  
location = new PVector（x，y）;  
velocity = new PVector（0，0）;  
acceleration = new PVector（0，0）;  
}  
void applyForce（PVector force）{  
PVector f = PVector.div（force，mass）;  
acceleration.add（f）;  
}  
void update（）{  
velocity.add（acceleration）;  
location.add（velocity）;  
acceleration.mult（0）;  
}  
void display（）{  
stroke（0）;  
fill（174）;  
ellipse（location.x，location.y， _mass16，mass16_ ）;  
}  
void checkEdges（）{  
if（location.x\>width）{  
location.x = width;  
velocity.x\*=-1;  
}else if（location.x \< 0）{  
velocity.x\*=-1;  
location.x = 0;  
}  
if（location.y\>height）{  
velocity.y\*=-1;  
location.y = height;  
}  
}  
}

类 液体{  
浮子 x，y，w，h;  
浮子 c;  
PVector 加速度;  
浮子质量;  
PVector 位置;  
PVector 速度;  
Liquid（float x\_，float y\_，float w\_，float h\_，float c\_）{  
x=x\_;  
y=y\_;  
w=w\_;  
h=h\_;  
c=c\_;  
}  
void display（）{  
noStroke（）;  
fill（174）;  
rect（x，y，w，h）;  
}  
void applyForce（PVector force）{  
PVector f = PVector.div（force，mass）;  
acceleration.add（f）;  
}

boolean isInside（Liquid l）{  
if（location.x\>l.x && location.x\<l.x+l.w && location.y\>l.y && location.y\<l.y+l.h）{  
return true;  
}else{  
返回 false;  
}  
}

void drag（Liquid l）{  
float speed = velocity.mag（）;  
float dragMagnitude = l.c speedspeedspeed;  
PVector drag = velocity.get（）;  
drag.mult（-1）;  
drag.normalize（）;  
drag.mult（dragMagnitude）;  
applyForce（drag）;  
}  
}  
\</\>

 ![屏幕截图 2022-04-14 165906](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/0/f0ca7ccacbeb6d3fa000b91552de9a6eb6af42b0.jpeg)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 15, 2022, 6:53am UTC](https://discourse.processing.org/t/why-always-report-errors/36342/2 "2022-04-15T06:53:09Z")

</div>

As has been said you need to program the  
functions inside the class: isInside and drag()

See [The Nature of Code solutions to exercises?](https://discourse.processing.org/t/the-nature-of-code-solutions-to-exercises/36085)

---

<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 15, 2022, 11:05am UTC](https://discourse.processing.org/t/why-always-report-errors/36342/3 "2022-04-15T11:05:01Z")

</div>

Hello @jiajia,

This was answered here:

> [@This is the third chapter of the book "The Nature of Code" about friction and resistance, I don't know what the problem is, as a beginner this is my first problem I can't solve, so I ask you for help.THANKS！](https://discourse.processing.org/t/this-is-the-third-chapter-of-the-book-the-nature-of-code-about-friction-and-resistance-i-dont-know-what-the-problem-is-as-a-beginner-this-is-my-first-problem-i-cant-solve-so-i-ask-you-for-help-thanks/36331/2):
>
> Hello, The answer is here: [https://natureofcode.com/book/chapter-2-forces/](https://natureofcode.com/book/chapter-2-forces/) The chapter tells you which class to put the functions in. slight_smile
