I think i got the right output but the last task still seems to be wrong, why?
package de.codegym.task.task16.task1605;
import java.util.Date;
/*
Reden wir über Musik
*/
public class Solution {
public static int delay = 1000;
public static void main(String[] args) {
Thread violin = new Thread(new Violin("Spieler"));
violin.start();
}
public static void sleepNSeconds(int n) {
try {
Thread.sleep(n * delay);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public interface MusicalInstrument extends Runnable {
Date startPlaying();
Date stopPlaying();
}
public static class Violin implements MusicalInstrument{
private String owner;
public void run(){
Date beg = startPlaying();
Solution.sleepNSeconds(1);
Date schl = stopPlaying();
System.out.println((schl.getTime() - beg.getTime())/1000);
}
public Violin(String owner) {
this.owner = owner;
}
public Date startPlaying() {
System.out.println(this.owner + " beginnt zu spielen");
return new Date();
}
public Date stopPlaying() {
System.out.println(this.owner + " hört auf zu spielen");
return new Date();
}
}
}