12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /*
- * 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 anzahlPflanzen = 1;
-
- public PflanzengruppenKonfigurator()
- {
-
- }
-
- public PflanzengruppenKonfigurator alter(int Alter)
- {
- this.alter = Alter;
- return this;
- }
-
- public PflanzengruppenKonfigurator pflanzenTyp(int PflanzenTyp)
- {
- this.pflanzenTyp = PflanzenTyp;
- return this;
- }
-
- public PflanzengruppenKonfigurator anzahlPflanzen(int AnzahlPflanzen)
- {
- this.anzahlPflanzen = AnzahlPflanzen;
- return this;
- }
-
-
- public void setanzPflanzen(int tempanz)
- {
- anzahlPflanzen=tempanz;
- }
-
- public Pflanzengruppe erstellen() throws IllegalArgumentException
- {
- konfigurationPruefen();
- Pflanzengruppe pflgruppe = new Pflanzengruppe(alter,pflanzenTyp,anzahlPflanzen);
- return pflgruppe;
- }
- private void konfigurationPruefen() throws IllegalArgumentException
- {
- if((this.pflanzenTyp ==2 ||this.pflanzenTyp ==3 )&& alter > 4)
- {
- throw new IllegalArgumentException("Ein geringeres Alter muss gewählt werden");
- }
- if(this.pflanzenTyp ==1 && alter > 5)
- {
- throw new IllegalArgumentException("Ein geringeres Alter muss gewählt werden");
- }
-
- }
-
- }
|