Ich habe eine Klasse namens Handy2 und eine "ausführ" Datei namens UIHandy2. Auf Handy2 habe ich 4 Atrribute und mit get/set Methoden und noch 3 weiteren Methoden. Auf UIHandy2 habe ich nun ein Objekt namens "nokia" erstellt und habe das Attribut bestimmt. Nun möchte ich dieses ausgeben. Aber es passiert nichts. Nur wenn ich den Wert schon um Konstruktor vorbestimme. Was mache ich falsch?
Klasse Handy2:
UIHandy2
Klasse Handy2:
Java:
public class Handy2 {
// Anfang Attribute
private String handyNr;
private String handyBesitzer;
private double handyGuthaben;
private boolean ausreichendGuthaben;
// Ende Attribute
public Handy2(String handyNrNeu) {
this.handyNr = "";
this.handyBesitzer = "";
this.handyGuthaben = 0;
this.ausreichendGuthaben = false;
}
// Anfang Methoden
public String getHandyNr() {
return handyNr;
}
public void setHandyNr(String handyNrNeu) {
handyNr = handyNrNeu;
}
public String getHandyBesitzer() {
return handyBesitzer;
}
public void setHandyBesitzer(String handyBesitzerNeu) {
handyBesitzer = handyBesitzerNeu;
}
public double getHandyGuthaben() {
return handyGuthaben;
}
public void setHandyGuthaben(double handyGuthabenNeu) {
handyGuthaben = handyGuthabenNeu;
}
public boolean getAusreichendGuthaben() {
return ausreichendGuthaben;
}
public void setAusreichendGuthaben(boolean ausreichendGuthabenNeu) {
ausreichendGuthaben = ausreichendGuthabenNeu;
}
public void ausgabe() {
System.out.println(handyNr);
}
public void warnungGuthaben() {
// TODO hier Quelltext einfügen
}
public void erhoehenGuthaben(double pGuthaben) {
// TODO hier Quelltext einfügen
}
// Ende Methoden
} // end of Handy2
UIHandy2
Java:
public class UIHandy2 {
public static void main(String[] args) {
Handy2 nokia = new Handy2("0173-123456");
nokia.ausgabe();
} // end of main
} // end of class UIHandy2