package simulation;

import jgame.JGColor;

public class Spring extends Muscle implements Force {
	
    private final static JGColor SPRING_COMPRESSED_COLOR = new JGColor(96, 96, 96);
    private final static JGColor SPRING_STRETCHED_COLOR = new JGColor(208, 208, 208);
    private final static double SPRING_WIDTH = 5.0;
    protected float myRotation;

	public Spring(Mass a, Mass b, double restLength, double constant){
		super("spring", a, b, restLength, constant, 0);
	}
	public Spring(double x, double y, Mass b, double restLength, double constant){
		super("spring", null, b, restLength, constant, 0);
	}

	@Override
	public void paint(){
		if(a != null){
			if (a.distance(b) > restLength)
				myEngine.drawLine(a.x, a.y, b.x, b.y, SPRING_WIDTH, SPRING_STRETCHED_COLOR);
			else
				myEngine.drawLine(a.x, a.y, b.x, b.y, SPRING_WIDTH, SPRING_COMPRESSED_COLOR);
		}
		else{
			if (a.distance(b) > restLength)
				myEngine.drawLine(a.x, a.y, b.x, b.y, SPRING_WIDTH, SPRING_STRETCHED_COLOR);
			else
				myEngine.drawLine(a.x, a.y, b.x, b.y, SPRING_WIDTH, SPRING_COMPRESSED_COLOR);
		}
	}
	
	@Override
	public String getForceName(){
		return "Spring";
	}
}

@@ -95,14 +95,10 @@
 e %7B%0A
+%0A
 %09
-%0A    
 priv
@@ -173,20 +173,17 @@
 6, 96);%0A
-    
+%09
 private 
@@ -256,20 +256,17 @@
 , 208);%0A
-    
+%09
 private 
@@ -309,12 +309,9 @@
 .0;%0A
-    
+%09
 prot
@@ -630,26 +630,8 @@
 ()%7B%0A
-%09%09if(a != null)%7B%0A%09
 %09%09if
@@ -652,33 +652,32 @@
 ) %3E restLength)%0A
-%09
 %09%09%09myEngine.draw
@@ -732,33 +732,32 @@
 RETCHED_COLOR);%0A
-%09
 %09%09else%0A%09%09%09%09myEng
@@ -742,33 +742,32 @@
 LOR);%0A%09%09else%0A%09%09%09
-%09
 myEngine.drawLin
@@ -832,234 +832,11 @@
 R);%0A
-%09%09%7D%0A%09%09else%7B%0A%09%09%09if (a.distance(b) %3E restLength)%0A%09%09%09%09myEngine.drawLine(a.x, a.y, b.x, b.y, SPRING_WIDTH, SPRING_STRETCHED_COLOR);%0A%09%09%09else%0A%09%09%09%09myEngine.drawLine(a.x, a.y, b.x, b.y, SPRING_WIDTH, SPRING_COMPRESSED_COLOR);%0A%09%09%7D%0A
 %09%7D%0A
-%09
 %0A%09@O

Remove unnecessary if/else block