Skip to content

Instantly share code, notes, and snippets.

@wemakeweb
Created January 11, 2012 18:46
Show Gist options
  • Save wemakeweb/1596135 to your computer and use it in GitHub Desktop.
Save wemakeweb/1596135 to your computer and use it in GitHub Desktop.
Oberklasse.setBuchung.java
public void setBuchung(Datum buchungsdatum, int naechte, Datum heute,String name,int preis) throws BuchungÜberschneidetSich{
Buchung wunsch = new Buchung(buchungsdatum, naechte);
wunsch.setpreis(preis);
wunsch.setname(name);
if (buchungsListe.size() != 0) {
for (int i = 0; i < buchungsListe.size(); i++) {
Buchung alteBuchung = buchungsListe.get(i);
if (wunsch.überschneidung(alteBuchung)) {
throw new BuchungÜberschneidetSich();
}
}
// wenn es keine überschneidung gab dann adden
this.buchungsListe.addElement(wunsch);
} else {
this.buchungsListe.addElement(wunsch);
}
}
public boolean überschneidung(Buchung alteBuchung) {
if (this.getlongdatestart() < alteBuchung.getlongdateend()&& this.getlongdateend() > alteBuchung.getlongdatestart()) {
return true;
} else
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment