import java.awt.*; public class Spring extends PhysicsElement { private static int id=0; // Spring identification protected final double restLength; private final double stiffness; protected Attachable a_end, b_end; protected SpringView view; private Spring(){ // nobody can create a spring without state this(0,0); } public Spring(double restLength, double stiffness){ super(id++); this.restLength = restLength; this.stiffness = stiffness; a_end = b_end = null; view = new SpringView(this); } public void attachEnd (Attachable sa) { // note: we attach a spring to a ball, if(a_end==null) // not the other way around. a_end = sa; // to be completed by you } private Vector2D getStrech() { // if you feel that this method in useful } public Vector2D getForce(Ball ball) { // to be completed by you } public Vector2D getAendPosition() { return a_end.getPosition(); } public Vector2D getBendPosition() { return b_end.getPosition(); } public double getRestLength() { return restLength; } public void paintView (Graphics2D g) { // NEW view.paint(g); // update this spring's view in Model-View-Controller design pattern } }