123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package garten.model;
-
- /**
- *
- * @author Jan
- */
- class PflanzengruppenKonfigurator
- {
- private int alter = 1;
- private int pflanzenTyp =1;
- private int startlaenge =1;
- private Beet beet;
-
- public PflanzengruppenKonfigurator()
- {
-
- }
- public Pflanzengruppe erstellen() throws IllegalArgumentException
- {
- konfigurationPruefen();
- Pflanzengruppe pflgruppe = new Pflanzengruppe(pflanzenTyp,alter,startlaenge,beet);
- return pflgruppe;
- }
-
- public PflanzengruppenKonfigurator alter(int alter)
- {
- this.alter = alter;
- return this;
- }
-
- public PflanzengruppenKonfigurator pflanzenTyp(int pflanzenTyp)
- {
- this.pflanzenTyp = pflanzenTyp;
- return this;
- }
-
- public PflanzengruppenKonfigurator startlaenge(int startlaenge)
- {
- this.startlaenge = startlaenge;
- return this;
- }
- public PflanzengruppenKonfigurator beet(Beet beet)
- {
- this.beet = beet;
- return this;
- }
-
- private void konfigurationPruefen() throws IllegalArgumentException
- {
- if((pflanzenTyp ==1 || pflanzenTyp ==2) && alter > 3|| pflanzenTyp ==3 && alter > 4)
- {
- throw new IllegalArgumentException("Ein geringeres Alter muss gewählt werden");
- }
- if(pflanzenTyp ==1 && (startlaenge < 30 || startlaenge >50))
- {
- throw new IllegalArgumentException("Größe muss zwischen 30-50 liegen");
- }
- if((pflanzenTyp ==2 || pflanzenTyp ==3) && (startlaenge <10 || startlaenge >20))
- {
- throw new IllegalArgumentException("Größe muss zwischen 10-20 liegen");
-
- }
-
- }
-
- }
|