Hello, i have a little problem with this peace of code which should calculate if there is or there isnt colinear points in array called "ostring", which is object of class "point",with x and y coordinates
"ocounter" is a varibale that represent number of elements in array.
I must mention that on every mouse click , coordinates of the mouse are stored in the array
The problem i have is that when "ocounter" reaches 4, it throws me a NullPointerException and AritmeticException divide by zero, heres the code
if(ocounter>2)
{
for(i=0;i<ocounter-2;i++)
{
int y1=ostring[i].getY();
int x1=ostring[i].getX();
for(j=i+1;j<ocounter-1;j++)
{
int y2=ostring[j].getY();
int x2=ostring[j].getX();
for(z=j+1;z<ocounter;z++)
{
int y3=ostring[z].getY();
int x3=ostring[z].getX();
if((y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2))
{
Greenfoot.stop();
}
}
}
}
}
