This commit is contained in:
Jan 2019-06-20 21:15:55 +02:00
parent 60ff8db8ad
commit 91d1bbbec8
9 changed files with 129 additions and 22 deletions

View File

@ -72,18 +72,15 @@ public class Gaertner
meinGarten.hinzufuegenBeet(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1]-randomwertex[i]-20,randomwertey[j+1] - randomwertey[j]-20); meinGarten.hinzufuegenBeet(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1]-randomwertex[i]-20,randomwertey[j+1] - randomwertey[j]-20);
} }
} }
//Beet * Weg zeichen, muss noch in Garten (geht halt so recht schön) //Beet * Weg zeichen, muss noch in Garten (geht halt so recht schön)
flbeet.setBeet(randomwertex,randomwertey); flbeet.setBeet(randomwertex,randomwertey);
flweg.setWeg(randomwertex,randomwertey); flweg.setWeg(randomwertex,randomwertey);
pfl = new Pflanze1(100,100,3); pfl = new Pflanze1(100,100,3);
//pfl2 = new Pflanze1(200,400,2); pfl2 = new Pflanze1(200,400,4);
pflanzen.add(pfl); meinGarten.hinzufuegenPflanze(pfl);
//pflanzen.add(pfl2); meinGarten.hinzufuegenPflanze(pfl2);
flpfl.setPflanzen(pflanzen);
//meinGarten.hinzufuegenPflanze(pfl);
// meinGarten.hinzufuegenPflanze(pfl2);
meinGarten.zeichnePflanzen(); meinGarten.zeichnePflanzen();
} }
/* /*

View File

@ -0,0 +1,19 @@
/*
* 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 Gaertner1
{
public Gaertner1()
{
}
}

View File

@ -17,7 +17,6 @@ public interface Pflanze
void setPosition(); void setPosition();
//Position lieferePosition(); //Position lieferePosition();
//TurtleStack ts = new TurtleStack();
//public void draw(); //public void draw();
public ArrayList<float[]> getPoints(); public ArrayList<float[]> getPoints();

View File

@ -71,7 +71,6 @@ public class PflanzeImpl extends JComponent implements Pflanze
{ {
x_temp, y_temp, turtle.getX(), turtle.getY() x_temp, y_temp, turtle.getX(), turtle.getY()
}; };
System.out.println("Punkte :" +x_temp + " " + y_temp + " " + turtle.getX()+ " " + turtle.getY());
pts.add(temp); pts.add(temp);
break; break;
case '+': case '+':
@ -109,7 +108,6 @@ public class PflanzeImpl extends JComponent implements Pflanze
return pts; return pts;
} }
public int getPositionx() public int getPositionx()
{ {
return positionx; return positionx;
@ -129,11 +127,7 @@ public class PflanzeImpl extends JComponent implements Pflanze
{ {
positiony = y; positiony = y;
} }
public void setflaeche(int flaeche)
{
}
public int getflaeche() public int getflaeche()
{ {
return flaeche; return flaeche;

View File

@ -0,0 +1,37 @@
/*
* 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 Pflanzengruppe
{
private int alter;
private int pflanzentyp;
private int anzahlPflanzen = 1;
//Pflanze[] Pflanzengruppe = new Pflanze[anzahlPflanzen];
Pflanzengruppe(int Alter,int PflanzenTyp,int AnzahlPflanzen)
{
alter = Alter;
pflanzentyp = PflanzenTyp;
anzahlPflanzen = AnzahlPflanzen;
}
public void anzeigen()
{
}
public void beginnebepflanzung()
{
}
}

View File

@ -0,0 +1,67 @@
/*
* 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");
}
}
}

View File

@ -41,7 +41,7 @@ public class start
hauptkiste.add(flbeet); hauptkiste.add(flbeet);
hauptkiste.add(flweg); hauptkiste.add(flweg);
Gaertner ga = new Gaertner(view,flbeet,flweg,flpflanzen); Gaertner ga = new Gaertner(view,flbeet,flweg,flpflanzen);
} }
/** /**

View File

@ -39,9 +39,7 @@ public class FlaecheBeet extends JPanel
g.fillRect(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1] - randomwertex[i] - 20, randomwertey[j + 1] - randomwertey[j] - 20); g.fillRect(randomwertex[i] + 10, randomwertey[j] + 10, randomwertex[i + 1] - randomwertex[i] - 20, randomwertey[j + 1] - randomwertey[j] - 20);
} }
} }
} }
public void setBeet(int[] x, int[] y) public void setBeet(int[] x, int[] y)
{ {
randomwertex = x; randomwertex = x;

View File

@ -41,14 +41,10 @@ public class FlaechePflanzen extends JPanel
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(colorPflanzen); g.setColor(colorPflanzen);
System.out.println(pflanzen);
for(Pflanze p : pflanzen) for(Pflanze p : pflanzen)
{ {
ArrayList<float[]> pts = p.getPoints(); ArrayList<float[]> pts = p.getPoints();
System.out.println("Return points" + pts);
for(float[] pt : pts) for(float[] pt : pts)
{ {
Gerade.setLine(pt[0], pt[1], pt[2], pt[3]); Gerade.setLine(pt[0], pt[1], pt[2], pt[3]);