public class Fahrkartenautomat {
private int preisstufe = 1;
private int anzahl = 1;
private double preisProKarte = 1.20;
private double eingeworfen = 0;
private double insgesamtEingeworfen = 0;
private String passwort
= "xyz";
public Fahrkartenautomat {
System.
out.
println("Geladen!!!");
}
public void geldeingeworfen(double pBetrag){
insgesamtEingeworfen += pBetrag;
eingeworfen += pBetrag;
}
public double rueckgabe(){
double g = eingeworfen;
insgesamtEingeworfen -= g;
eingeworfen = 0;
return g;
}
public double geldAusgabe
(String pPasswort
){
if(passwort == pPasswort){
double r = insgesamtEingeworfen;
insgesamtEingeworfen = 0;
return r;
}
}
public void preisstufeWaehlen(int pPreisstufe){
preisstufe = pPreisstufe;
}
public void anzahlWaehlen(int pAnzahl){
anzahl = pAnzahl;
}
public void ducken(){
if (preisstufe*preisProKarte*anzahl > eingeworfen){
druckKarte();
eingeworfen -= preisstufe*preisProKarte*anzahl;
rueckgabe();
else if(preisstufe*preisProKarte*anzahl == eingeworfen){
druckKarte();
eingeworfen -= preisstufe*preisProKarte*anzahl;
}else{
System.
out.
println("Zu wenig geld!");
}
}
private void druckKarte(){
System.
out.
println("|---------------------|");
System.
out.
println("| Fahrkarte |");
System.
out.
println("|---------------------|");
}
public void main
(String[] args
) {
Fahrkartenautomat f = new Fahrkartenautomat();
f.preisstufeWaehlen(2);
f.anzahlWaehlen(4);
f.drucken();
f.geldAusgabe("xyz");
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}