This problem arose from the question next I have the following polymorphism code in java and the problem I have is that children classes are not executed
Parent Class "Player"
public class reproductor implements Runnable {
protected static sboolean pausado = false;
protected static String temaactual ;
protected static Integer posiciondepausa;
protected static boolean ordendereproducir =true;
volatile boolean muerto = false;
volatile boolean reproduciendo = false;
public void reproducir(){
if (!reproduciendo ){
String proximotema = com.proximotema();
empezar(proximotema);
}
}
reproductor getInstance() {
System.out.println("bfhsoftware.sonidoambiental.reproductor.getInstance()");
if (main.isandroid()) {
return new reproducirAndroid();
} else {
//System.out.println("bfhsoftware.sonidoambiental.reproductor.getInstance()");
return new ReproducirJava();
}
}
public void empezar (String proximotema){
//reproduciendo = true;
}
public void parar(){
reproduciendo = false;
}
public void pausa(){
reproduciendo = false;
pausado = true;
}
@Override
public void run (){
if (verificador ==null) {
verificador = new Timer();
}
verificador.scheduleAtFixedRate(controlado, 0, 1000);
//el error esta a continuacion, un bucle que vuelve loca a la memoria
while (!muerto && ordendereproducir) {
reproducir();
//System.out.println( "reproducir");
}
}
}
Child class "playAndroid"
class reproducirAndroid extends reproductor {
public reproducirAndroid() {
/* Llamamos al constructor padre */
super();
}
@Override
public void empezar() {
/* Llamamos a la implementación común de comienzo */
super.empezar();
/* Implementamos aquí el método en java se */
}
@Override
public void parar() {
/* Llamamos a la implementación común de parada */
super.parar();
/* Implementamos aquí el método en java se */
}
@Override
public void pausa() {
/* Llamamos a la implementación común de pausa */
super.pausa();
/* Implementamos aquí el método en java se */
}
/* No es necesario implementar getNumCancion ni getPosicion */
}
Child class "reproducejava"
class ReproducirJava extends reproductor {
public reproducirJava() {
/* Llamamos al constructor padre */
super();
}
@Override
public void empezar() {
/* Llamamos a la implementación común de comienzo */
super.empezar();
/* Implementamos aquí el método en java se */
}
@Override
public void parar() {
/* Llamamos a la implementación común de parada */
super.parar();
/* Implementamos aquí el método en java se */
}
@Override
public void pausa() {
/* Llamamos a la implementación común de pausa */
super.pausa();
/* Implementamos aquí el método en java se */
}
/* No es necesario implementar getNumCancion ni getPosicion */
}
As you can see it has three classes, the reproductive class, is the father, and reprodutorjava and reproirandroid are the daughters, The problem I have is that children classes are not executed
The idea is to run a child depending on the type of operating system I am using, but I can not make it work, no child class is executed, where is the problem? I have placed Getinstance can be seen in the code of the parent class. P.S: Maybe it works, to call the parent class I do it as if it were a thread. as follows
reproductor sistemaprincipal = new reproductor();
Thread t = new Thread(sistemaprincipal);
t.start();