class Attractor { //PROPERTIES float x;//position float y; float r; //reichweite float s; //stŠrke //--------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- //CONSTRUCTOR Attractor(float r, float s) { x = random(50,550); y = random(50,450); this.r = r; this.s = s; } //--------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- //METHODS float distanceTo (float x, float y) { float dx = x - this.getX(); float dy = y - this.getY(); return sqrt (dx*dx + dy*dy); } //--------------------------------------------------------------------------------------------------------- float xdistanceTo (float x, float y) { return x - this.getX(); } //--------------------------------------------------------------------------------------------------------- float ydistanceTo (float x, float y) { return y - this.getY(); } //--------------------------------------------------------------------------------------------------------- void display() { fill(0,255,0); noStroke(); ellipse(x,y,3,3); } //--------------------------------------------------------------------------------------------------------- //GETTERS AND SETTERS float getX() { return this.x; } //--------------------------------------------------------------------------------------------------------- float getY() { return this.y; } //--------------------------------------------------------------------------------------------------------- float getReichweite() { return this.r; } //--------------------------------------------------------------------------------------------------------- float getStarke() { return this.s; } //--------------------------------------------------------------------------------------------------------- }