You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PflanzengruppenKonfigurator.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package garten.model;
  7. /**
  8. *
  9. * @author Jan
  10. */
  11. class PflanzengruppenKonfigurator
  12. {
  13. private int alter = 1;
  14. private int pflanzenTyp = 1;
  15. private int anzahlPflanzen = 1;
  16. public PflanzengruppenKonfigurator()
  17. {
  18. }
  19. public PflanzengruppenKonfigurator alter(int Alter)
  20. {
  21. this.alter = Alter;
  22. return this;
  23. }
  24. public PflanzengruppenKonfigurator pflanzenTyp(int PflanzenTyp)
  25. {
  26. this.pflanzenTyp = PflanzenTyp;
  27. return this;
  28. }
  29. public PflanzengruppenKonfigurator anzahlPflanzen(int AnzahlPflanzen)
  30. {
  31. this.anzahlPflanzen = AnzahlPflanzen;
  32. return this;
  33. }
  34. public void setanzPflanzen(int tempanz)
  35. {
  36. anzahlPflanzen=tempanz;
  37. }
  38. public Pflanzengruppe erstellen() throws IllegalArgumentException
  39. {
  40. konfigurationPruefen();
  41. Pflanzengruppe pflgruppe = new Pflanzengruppe(alter,pflanzenTyp,anzahlPflanzen);
  42. return pflgruppe;
  43. }
  44. private void konfigurationPruefen() throws IllegalArgumentException
  45. {
  46. if((this.pflanzenTyp ==2 ||this.pflanzenTyp ==3 )&& alter > 4)
  47. {
  48. throw new IllegalArgumentException("Ein geringeres Alter muss gewählt werden");
  49. }
  50. if(this.pflanzenTyp ==1 && alter > 5)
  51. {
  52. throw new IllegalArgumentException("Ein geringeres Alter muss gewählt werden");
  53. }
  54. }
  55. }