Quote:
if(height<0)
{
System.out.println("Invalid heigth. Setting to 1");
height=1;
}
if(width<0)
{
System.out.println("Invalid width. Setting to 1");
width=1;
}
I guess you should use better constraints (e.g at least 20).
Your should design a
Particle
class with current position
(x,y)
and current direction (the suggested enum) as state variables.
Then you have to move particles, handle collisions between particles (simple, just make sure the particles have the same current position) and collisions between particles and the walls of the box (the requirements says nothing about, I think you may safely assuming usual elastic behaviour, e.g. reflection of x direction on particle hit against a vertical wall).