import java.awt.*;

// An instance of this class models the current speed of the car. The
// current speed is changed by calling method changeSpeed. An instance
// of this class has a window (a Frame) that displays the current speed.
// An instance has its own thread of execution --method run is in
// superclass ClockedFrame.
public class CurrentSpeed extends ClockedFrame {

// Components that go in this Frame
	Label label= new Label("Current speed:   ");
	Label tempLabel= new Label("72");

private double speed;	// Current speed of the car
  
// Constructor: current-speed control; the clock is c
// and the initial desired speed is s
public CurrentSpeed(SystemClock c, int s) {
    super(c, "Current speed");
	speed = s;
	tempLabel.setText("" + speed);
	add("North", label);
	add("Center", tempLabel);
	resize(600, 200);
	pack();
    move(580, 100);
	show();
  	}

// Return the current speed.
public synchronized double readValue() {
    notifyAll();
    return(speed);
  	}

// Set the current speed to s
public synchronized void setValue(double s) {
    speed = s;
    notifyAll();
    tempLabel.setText("" + speed);
  	}

}

