fast fast fertig
This commit is contained in:
parent
b4ee6317db
commit
3909cc0e6e
@ -84,8 +84,7 @@ public class Gaertner implements MouseMotionListener, MouseListener,ActionListen
|
|||||||
if (SwingUtilities.isRightMouseButton(e))//Bei Rechtsklick Popup Menü
|
if (SwingUtilities.isRightMouseButton(e))//Bei Rechtsklick Popup Menü
|
||||||
{
|
{
|
||||||
//Zwischenspeichern der Koordinaten der Maus um Beet zu finden
|
//Zwischenspeichern der Koordinaten der Maus um Beet zu finden
|
||||||
aktuellesBeet[0] = e.getX();
|
koordinbeet = e;
|
||||||
aktuellesBeet[1] = e.getY();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,9 +215,9 @@ public class Gaertner implements MouseMotionListener, MouseListener,ActionListen
|
|||||||
konfig.alter(alter);
|
konfig.alter(alter);
|
||||||
konfig.pflanzenTyp(pflanzentyp);
|
konfig.pflanzenTyp(pflanzentyp);
|
||||||
konfig.startlaenge(laenge);
|
konfig.startlaenge(laenge);
|
||||||
konfig.beet(meinGarten.getBeet(aktuellesBeet));
|
konfig.beet(meinGarten.getBeet(koordinbeet));
|
||||||
konfig.erstellen();
|
konfig.erstellen();
|
||||||
for(Pflanze pf : meinGarten.getBeet(aktuellesBeet).getPflanzenausgruppe())
|
for(Pflanze pf : meinGarten.getBeet(koordinbeet).getPflanzenausgruppe())
|
||||||
{
|
{
|
||||||
meinGarten.hinzufuegenPflanze(pf);
|
meinGarten.hinzufuegenPflanze(pf);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,22 @@ package garten.model;
|
|||||||
*/
|
*/
|
||||||
public class Gaertner1
|
public class Gaertner1
|
||||||
{
|
{
|
||||||
public Gaertner1()
|
private static int tempx,
|
||||||
|
tempy,
|
||||||
|
alter,
|
||||||
|
startlaenge;
|
||||||
|
|
||||||
|
public Gaertner1(int tempx,int tempy,int alter,int startlaenge)
|
||||||
{
|
{
|
||||||
|
this.tempx = tempx;
|
||||||
|
this.tempy = tempy;
|
||||||
|
this.alter = alter;
|
||||||
|
this.startlaenge = startlaenge;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Pflanze pflanzen()
|
||||||
|
{
|
||||||
|
return new Pflanze1(tempx, tempy, alter,startlaenge);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
33
Garten/src/garten/model/Gaertner2.java
Normal file
33
Garten/src/garten/model/Gaertner2.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public class Gaertner2
|
||||||
|
{
|
||||||
|
private static int tempx,
|
||||||
|
tempy,
|
||||||
|
alter,
|
||||||
|
startlaenge;
|
||||||
|
|
||||||
|
public Gaertner2(int tempx,int tempy,int alter,int startlaenge)
|
||||||
|
{
|
||||||
|
this.tempx = tempx;
|
||||||
|
this.tempy = tempy;
|
||||||
|
this.alter = alter;
|
||||||
|
this.startlaenge = startlaenge;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pflanze pflanzen()
|
||||||
|
{
|
||||||
|
return new Pflanze2(tempx, tempy, alter,startlaenge);
|
||||||
|
}
|
||||||
|
}
|
@ -33,6 +33,16 @@ class Pflanzengruppe
|
|||||||
beginnebepflanzung();
|
beginnebepflanzung();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPflanze(Pflanze pfl)
|
||||||
|
{
|
||||||
|
pflanzen.add(pfl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePflanze(Pflanze pfl)
|
||||||
|
{
|
||||||
|
pflanzen.remove(pfl);
|
||||||
|
}
|
||||||
|
|
||||||
public void beginnebepflanzung()
|
public void beginnebepflanzung()
|
||||||
{
|
{
|
||||||
Boolean bepflanzung = true;
|
Boolean bepflanzung = true;
|
||||||
@ -50,17 +60,19 @@ class Pflanzengruppe
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
||||||
if (pflanzentyp == 1)
|
switch (pflanzentyp)
|
||||||
{
|
{
|
||||||
pfl = new Pflanze1(tempx, tempy, alter,startlaenge);
|
case 1:
|
||||||
}
|
pfl = new Gaertner1(tempx, tempy, alter,startlaenge).pflanzen();
|
||||||
else if (pflanzentyp == 2)
|
break;
|
||||||
{
|
case 2:
|
||||||
pfl = new Pflanze2(tempx, tempy, alter,startlaenge);
|
pfl = new Gaertner2(tempx, tempy, alter,startlaenge).pflanzen();
|
||||||
}
|
break;
|
||||||
else if (pflanzentyp == 3)
|
case 3:
|
||||||
{
|
pfl = new Gaertner3(tempx, tempy, alter,startlaenge).pflanzen();
|
||||||
pfl = new Pflanze3(tempx, tempy, alter,startlaenge);
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
pflanzen.add(pfl);
|
pflanzen.add(pfl);
|
||||||
tempx += deltax;
|
tempx += deltax;
|
||||||
@ -99,75 +111,4 @@ class Pflanzengruppe
|
|||||||
return pflanzen;
|
return pflanzen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginnebepflbox()
|
|
||||||
{
|
|
||||||
int[] randKoordinaten = beet.getKoordinaten();//großes Rechteck aufspannen welche Position schon vergeben sind
|
|
||||||
boolean platzimBeet = true;
|
|
||||||
System.out.println("Folgendes Beet bekommen: " + beet);
|
|
||||||
System.out.println("Beet hat folgende Koordinaten " +randKoordinaten[0] + " "+ randKoordinaten[1] + " " +randKoordinaten[2] + " " +randKoordinaten[3]);
|
|
||||||
int tempxstart = randKoordinaten[0]+20;
|
|
||||||
int tempystart = randKoordinaten[1]+20;
|
|
||||||
|
|
||||||
int xmin = randKoordinaten[0];
|
|
||||||
int xmax = randKoordinaten[2]+randKoordinaten[0];
|
|
||||||
int ymax = randKoordinaten[3]+randKoordinaten[1];
|
|
||||||
|
|
||||||
int[] temprechteck = new int[4];
|
|
||||||
temprechteck[0] = randKoordinaten[0];
|
|
||||||
temprechteck[1] = randKoordinaten[1];
|
|
||||||
temprechteck[2] = randKoordinaten[0];
|
|
||||||
temprechteck[3] = randKoordinaten[1];
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
float[] koordvergleich;
|
|
||||||
if (pflanzentyp == 1)
|
|
||||||
{
|
|
||||||
pfl = new Pflanze1(tempxstart, tempystart, alter, startlaenge);
|
|
||||||
}
|
|
||||||
else if (pflanzentyp == 2)
|
|
||||||
{
|
|
||||||
pfl = new Pflanze2(tempxstart, tempystart, alter, startlaenge);
|
|
||||||
}
|
|
||||||
else if (pflanzentyp == 3)
|
|
||||||
{
|
|
||||||
pfl = new Pflanze3(tempxstart, tempystart, alter, startlaenge);
|
|
||||||
}
|
|
||||||
|
|
||||||
koordvergleich = pfl.getBoundingBoxes();
|
|
||||||
// System.out.println("Pflanze hat folgende Koordinaten " + koordvergleich[0] + " "+ koordvergleich[1] + " "+ xmax + " "+ ymax);
|
|
||||||
//System.out.println("Temprechteck 2: " + temprechteck[2] + " Koordvergleich 2: " + koordvergleich[2] + " Xmax : " + xmax);
|
|
||||||
if(temprechteck[2]< koordvergleich[2] && koordvergleich[2]<xmax)
|
|
||||||
{
|
|
||||||
temprechteck[2] = (int) koordvergleich[2];
|
|
||||||
tempxstart =temprechteck[2]+20;
|
|
||||||
if(temprechteck[3]<koordvergleich[3])
|
|
||||||
{
|
|
||||||
temprechteck[3]= (int)koordvergleich[3];
|
|
||||||
}
|
|
||||||
pflanzen.add(pfl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tempxstart +=40;
|
|
||||||
if(koordvergleich[2] > xmax && koordvergleich[3]< ymax)
|
|
||||||
{
|
|
||||||
temprechteck[0] = xmin;
|
|
||||||
temprechteck[2] = xmin;
|
|
||||||
tempxstart = temprechteck[0]+20;
|
|
||||||
tempystart = temprechteck[3]+temprechteck[3]-temprechteck[0]+20;
|
|
||||||
System.out.println("Y-Achse wert erhöhen");
|
|
||||||
|
|
||||||
}
|
|
||||||
if(ymax < koordvergleich[3] && xmax < koordvergleich[2])
|
|
||||||
{
|
|
||||||
platzimBeet = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
while (platzimBeet);
|
|
||||||
System.out.println("Pflanzengruppe erstellt und folgenden Pflanzen hinzugefügt");
|
|
||||||
System.out.println(pflanzen);
|
|
||||||
beet.setPflanzengruppeBeet(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user