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ü
|
||||
{
|
||||
//Zwischenspeichern der Koordinaten der Maus um Beet zu finden
|
||||
aktuellesBeet[0] = e.getX();
|
||||
aktuellesBeet[1] = e.getY();
|
||||
koordinbeet = e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,9 +215,9 @@ public class Gaertner implements MouseMotionListener, MouseListener,ActionListen
|
||||
konfig.alter(alter);
|
||||
konfig.pflanzenTyp(pflanzentyp);
|
||||
konfig.startlaenge(laenge);
|
||||
konfig.beet(meinGarten.getBeet(aktuellesBeet));
|
||||
konfig.beet(meinGarten.getBeet(koordinbeet));
|
||||
konfig.erstellen();
|
||||
for(Pflanze pf : meinGarten.getBeet(aktuellesBeet).getPflanzenausgruppe())
|
||||
for(Pflanze pf : meinGarten.getBeet(koordinbeet).getPflanzenausgruppe())
|
||||
{
|
||||
meinGarten.hinzufuegenPflanze(pf);
|
||||
}
|
||||
|
@ -12,8 +12,22 @@ package garten.model;
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
@ -32,6 +32,16 @@ class Pflanzengruppe
|
||||
this.beet = beet;
|
||||
beginnebepflanzung();
|
||||
}
|
||||
|
||||
public void addPflanze(Pflanze pfl)
|
||||
{
|
||||
pflanzen.add(pfl);
|
||||
}
|
||||
|
||||
public void removePflanze(Pflanze pfl)
|
||||
{
|
||||
pflanzen.remove(pfl);
|
||||
}
|
||||
|
||||
public void beginnebepflanzung()
|
||||
{
|
||||
@ -49,18 +59,20 @@ class Pflanzengruppe
|
||||
int deltay = (temp[3] - 40) / ((temp[3] - 40) / 50);
|
||||
do
|
||||
{
|
||||
|
||||
if (pflanzentyp == 1)
|
||||
|
||||
switch (pflanzentyp)
|
||||
{
|
||||
pfl = new Pflanze1(tempx, tempy, alter,startlaenge);
|
||||
}
|
||||
else if (pflanzentyp == 2)
|
||||
{
|
||||
pfl = new Pflanze2(tempx, tempy, alter,startlaenge);
|
||||
}
|
||||
else if (pflanzentyp == 3)
|
||||
{
|
||||
pfl = new Pflanze3(tempx, tempy, alter,startlaenge);
|
||||
case 1:
|
||||
pfl = new Gaertner1(tempx, tempy, alter,startlaenge).pflanzen();
|
||||
break;
|
||||
case 2:
|
||||
pfl = new Gaertner2(tempx, tempy, alter,startlaenge).pflanzen();
|
||||
break;
|
||||
case 3:
|
||||
pfl = new Gaertner3(tempx, tempy, alter,startlaenge).pflanzen();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pflanzen.add(pfl);
|
||||
tempx += deltax;
|
||||
@ -99,75 +111,4 @@ class Pflanzengruppe
|
||||
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