import java.util.*; import java.awt.*; public class Oscillator extends PhysicsElement implements Attachable{ private static int id=0; // Oscillator's identification number private double center; // oscillator's center private double amplitude; // oscillation's amplitude private double w; // oscillator's frequency [rad] private double time; private double pos_t; private double pos_tPlusDelta; private Spring spring=null; private Oscillator(){ // nobody can create a block without state this(1.0,0.3,0.5); } public Oscillator(double c, double a, double f){ // f frequency in Hz super(id++); pos_t = pos_tPlusDelta = center = c; amplitude = a; w = 2*Math.PI*f; time=0; } public void attach(Spring s){ // to be coded } public double getPosition() { return pos_t; } public void computeNextState(double delta_t) { time+=delta_t; pos_tPlusDelta = center + amplitude*Math.sin(w*time); } public void updateState(){ // to be coded } public String getDescription() { // to be coded } public String getState() { // to be coded } }