Hi,
also mal ne Frage, ich hab nen Scenetyp1, Scenetyp2 und Scenetyp3
2 und 3 erben von 1
Jetzt bin ich in 1 und will herrausfinden ob der aktuelle Scenetyp vom typ2 oder 3 ist. Momentan hab ich das so geloest:
D.h. ich guck obs vom Typ 2 oder vom typ 3 ist. Kann man direkt schauen ob es sich um eine abgeleitete Klasse vom Typ 1 handelt?
Weil !(this instanceof Scenetyp1) kann ich ja net schreiben, alle sind ja vom Typ 1.
also mal ne Frage, ich hab nen Scenetyp1, Scenetyp2 und Scenetyp3
2 und 3 erben von 1
Jetzt bin ich in 1 und will herrausfinden ob der aktuelle Scenetyp vom typ2 oder 3 ist. Momentan hab ich das so geloest:
Java:
private String getLeftButton () {
String valueButton = null;
boolean instanceOfScene2 = this instanceof Scenetype2;
boolean instanceOfScene3 = this instanceof Scenetype3;
//if next != null write next
// && if this is not the main menu
if (main.getValue("next", getTitle()) != null && !getTitle().equalsIgnoreCase("menu")) {
valueButton = main.getValue("next", "menu");
// if this is not the main menu
// && if this is an instance of Scenetyp2 or Scenetyp3
} else if (!getTitle().equalsIgnoreCase("menu") && (instanceOfScene2 || instanceOfScene3) ) {
valueButton = main.getValue("send", "menu");
}
return valueButton;
}
Weil !(this instanceof Scenetyp1) kann ich ja net schreiben, alle sind ja vom Typ 1.