import java.awt.event.*;
import java.util.Calendar;
import javax.swing.Timer;

public class ClockTranslator implements ActionListener {
    
    private ClockApplication app;
    private ClockPresentation pres;
    
    public ClockTranslator(ClockApplication clockapp,
                           ClockPresentation clockpres) {
        app = clockapp;
        pres = clockpres;
        app.addActionListener(this);
        pres.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e) {
        String what = e.getActionCommand();
        if (what != null){  // button events from pres must be passed to app
            if (what.equals("h"))
                app.incrementHour();
            else if (what.equals("m"))
                app.incrementMinute();
            else if (what.equals("s"))
                app.incrementSecond();
        }                   // in any case, the presentation must be updated
        pres.setHour(app.getHour());
        pres.setMinute(app.getMinute());
        pres.setSecond(app.getSecond());
    }


}
