Created
January 11, 2012 18:46
-
-
Save wemakeweb/1596135 to your computer and use it in GitHub Desktop.
Oberklasse.setBuchung.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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