Update notwendig prüfen vor Merge
parent
09a63d8d9c
commit
6668b0be64
|
@ -6,13 +6,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/game_framework.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -20,15 +13,25 @@
|
|||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/game_framework.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/jcommon-1.0.23.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jfreechart-1.0.19.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package pr2.auffrischung.suchemax;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ArraySpielerei {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[] arr;
|
||||
|
||||
// arr[0] = 1; geht nicht, weil Array noch nicht
|
||||
// initialisiert ist.
|
||||
|
||||
arr = new int[5];
|
||||
|
||||
// dies funktioniert jetzt, da mit new das Array initialisiert wurde
|
||||
arr[0] = 1;
|
||||
|
||||
System.out.println(arr); // liefert NUR die Referenz auf das im
|
||||
// Heap liegende Array
|
||||
|
||||
System.out.println(arr[0]); // hier wird ein konkreter Wert aus dem
|
||||
// Array ausgegeben
|
||||
|
||||
// Array Liste und ein Array anlegen, kopieren und casten
|
||||
|
||||
int[] einArray = {1, 2, 3, 4, 5};
|
||||
int[] nochEinArray = new int[5];
|
||||
|
||||
for (int i = 0; i < nochEinArray.length; i++) {
|
||||
nochEinArray[i] = i + 5;
|
||||
}
|
||||
for (int einmal : einArray) {
|
||||
System.out.print(einmal + " ");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
for (int einmal : nochEinArray) {
|
||||
System.out.print(einmal + " ");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
ArrayList<Integer> arr2 = new ArrayList<Integer>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
arr2.add(i);
|
||||
}
|
||||
|
||||
System.out.println(arr2.get(2));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -5,10 +5,10 @@ package pr2.strukturierung.information_hiding;
|
|||
*/
|
||||
public class Rechner {
|
||||
/** Ergebnis des Taschenrechners. */
|
||||
public double wert;
|
||||
private double wert;
|
||||
|
||||
/** Speicher des Taschenrechners. */
|
||||
public double speicher;
|
||||
private double speicher;
|
||||
|
||||
/**
|
||||
* Addiert zwei Werte und gibt das Ergebnis zurück.
|
||||
|
@ -17,8 +17,9 @@ public class Rechner {
|
|||
* @param b zweiter Operand.
|
||||
* @return das Ergebnis.
|
||||
*/
|
||||
public void addiere(double a, double b) {
|
||||
wert = a + b;
|
||||
public double addiere(double a, double b) {
|
||||
wert = a + b;
|
||||
return setWert(wert);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,8 +29,9 @@ public class Rechner {
|
|||
* @param b zweiter Operand.
|
||||
* @return das Ergebnis.
|
||||
*/
|
||||
public void subtrahiere(double a, double b) {
|
||||
wert = a - b;
|
||||
public double subtrahiere(double a, double b) {
|
||||
wert = a - b;
|
||||
return setWert(wert);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,13 +41,25 @@ public class Rechner {
|
|||
* @param b zweiter Operand.
|
||||
* @return das Ergebnis.
|
||||
*/
|
||||
public void multipliziere(double a, double b) {
|
||||
wert = a * b;
|
||||
public double multipliziere(double a, double b) {
|
||||
wert = a * b;
|
||||
return setWert(wert);
|
||||
}
|
||||
/**
|
||||
* Speichert den aktuellen Wert in der Variable {@speicher}.
|
||||
*/
|
||||
public void speichern() {
|
||||
speicher = wert;
|
||||
this.speicher = wert;
|
||||
}
|
||||
|
||||
public double getWert() {
|
||||
return this.wert;
|
||||
}
|
||||
public double setWert(double ergebnis) {
|
||||
wert = ergebnis;
|
||||
return wert;
|
||||
}
|
||||
public double getSpeicher() {
|
||||
return this.speicher;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,20 +19,20 @@ public class RechnerTest {
|
|||
|
||||
// 2 + 2 = 4
|
||||
r.addiere(2.0, 2.0);
|
||||
assertEquals(4.0, r.wert, 0.0001);
|
||||
assertEquals(4.0, r.getWert(), 0.0001);
|
||||
|
||||
// 3 - 1 = 2
|
||||
r.subtrahiere(3, 1);
|
||||
assertEquals(2.0, r.wert, 0.0001);
|
||||
assertEquals(2.0, r.getWert(), 0.0001);
|
||||
|
||||
// 3 * 3 = 9
|
||||
r.multipliziere(3, 3);
|
||||
assertEquals(9.0, r.wert, 0.0001);
|
||||
assertEquals(9.0, r.getWert(), 0.0001);
|
||||
|
||||
// 2 + 2 * 2 = 6
|
||||
r.multipliziere(2, 2);
|
||||
r.speichern();
|
||||
r.addiere(2, r.speicher);
|
||||
assertEquals(6.0, r.wert, 0.0001);
|
||||
r.addiere(2, r.getSpeicher());
|
||||
assertEquals(6.0, r.getWert(), 0.0001);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package pr2.strukturierung.jars_einbinden;
|
|||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
// TODO: Einkommentieren
|
||||
//import org.jfree.chart.ChartFactory;
|
||||
//import org.jfree.chart.ChartPanel;
|
||||
//import org.jfree.chart.JFreeChart;
|
||||
//import org.jfree.chart.plot.PiePlot3D;
|
||||
//import org.jfree.data.general.DefaultPieDataset;
|
||||
|
||||
import org.jfree.chart.ChartFactory;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.plot.PiePlot3D;
|
||||
import org.jfree.data.general.DefaultPieDataset;
|
||||
|
||||
/**
|
||||
* Fenster mit der Torten-Grafik.
|
||||
|
@ -28,32 +28,32 @@ public final class PieChart {
|
|||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
// TODO: Einkommentieren
|
||||
// final String title = "Welches ist Euer Lieblingsspiel?";
|
||||
//
|
||||
// JFrame jframe = new JFrame(title);
|
||||
// jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
//
|
||||
// DefaultPieDataset dataset = new DefaultPieDataset();
|
||||
// dataset.setValue("GTA V", 20);
|
||||
// dataset.setValue("Fortnite", 30);
|
||||
// dataset.setValue("Elden Ring", 15);
|
||||
// dataset.setValue("Horizon Forbidden West", 35);
|
||||
//
|
||||
// JFreeChart chart = ChartFactory.createPieChart3D(
|
||||
// title,
|
||||
// dataset,
|
||||
// true,
|
||||
// true,
|
||||
// false);
|
||||
//
|
||||
// PiePlot3D plot = (PiePlot3D) chart.getPlot();
|
||||
// plot.setForegroundAlpha(0.6f);
|
||||
//
|
||||
// ChartPanel chartPanel = new ChartPanel(chart);
|
||||
// chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
|
||||
// jframe.setContentPane(chartPanel);
|
||||
// jframe.pack();
|
||||
// jframe.setVisible(true);
|
||||
|
||||
final String title = "Welches ist Euer Lieblingsspiel?";
|
||||
|
||||
JFrame jframe = new JFrame(title);
|
||||
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
DefaultPieDataset<String> dataset = new DefaultPieDataset<String>();
|
||||
dataset.setValue("GTA V", 20);
|
||||
dataset.setValue("Fortnite", 30);
|
||||
dataset.setValue("Elden Ring", 15);
|
||||
dataset.setValue("Horizon Forbidden West", 35);
|
||||
|
||||
JFreeChart chart = ChartFactory.createPieChart3D(
|
||||
title,
|
||||
dataset,
|
||||
true,
|
||||
true,
|
||||
false);
|
||||
|
||||
PiePlot3D plot = (PiePlot3D) chart.getPlot();
|
||||
plot.setForegroundAlpha(0.6f);
|
||||
|
||||
ChartPanel chartPanel = new ChartPanel(chart);
|
||||
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
|
||||
jframe.setContentPane(chartPanel);
|
||||
jframe.pack();
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public class A {
|
|||
/**
|
||||
* Konstante für die Vorzeichenumkehr.
|
||||
*/
|
||||
public static int KONSTANTE = 100;
|
||||
public static final int KONSTANTE = 100;
|
||||
|
||||
/**
|
||||
* Addiert zwei Zahlen. Wenn das Ergebnis größer ist als
|
||||
|
|
|
@ -15,7 +15,7 @@ package pr2.vererbung.finals;
|
|||
* @return Ergebnis
|
||||
*/
|
||||
public static int sub(int a, int b) {
|
||||
int result = a + b;
|
||||
int result = a - b;
|
||||
|
||||
return (result < KONSTANTE) ? (result * -1) : (result);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
package pr2.vererbung.geometrie1;
|
||||
|
||||
public class Figur {
|
||||
|
||||
private double flaeche;
|
||||
|
||||
public Figur(double flaeche) {
|
||||
this.flaeche = flaeche;
|
||||
}
|
||||
|
||||
public void setFlaeche(double flaeche) {
|
||||
this.flaeche = flaeche;
|
||||
}
|
||||
|
||||
public double getFlaeche() {
|
||||
return this.flaeche;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,23 @@ package pr2.vererbung.geometrie1;
|
|||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO: Klassen nutzen
|
||||
|
||||
double breite1 = 2, breite2 = 4, breite3 = 10;
|
||||
double hoehe1 = 2, hoehe2 = 5, hoehe3 = 10;
|
||||
|
||||
Figur a = new Rechteck(0);
|
||||
Figur b = new Rechteck(0);
|
||||
Figur c = new Rechteck(0);
|
||||
|
||||
((Rechteck) a).flaecheRechteck(breite1, hoehe1);
|
||||
((Rechteck) b).flaecheRechteck(breite2, hoehe2);
|
||||
((Rechteck) c).flaecheRechteck(breite3, hoehe3);
|
||||
|
||||
System.out.println(((Figur) a).getFlaeche());
|
||||
System.out.println(((Figur) b).getFlaeche());
|
||||
System.out.println(((Figur) c).getFlaeche());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,36 @@
|
|||
package pr2.vererbung.geometrie1;
|
||||
|
||||
public class Rechteck {
|
||||
public class Rechteck extends Figur {
|
||||
|
||||
private double hoehe;
|
||||
private double breite;
|
||||
|
||||
public Rechteck(double flaeche) {
|
||||
super(flaeche);
|
||||
}
|
||||
|
||||
public void flaecheRechteck(double b, double h) {
|
||||
double flaeche = b * h;
|
||||
setFlaeche(flaeche);
|
||||
}
|
||||
|
||||
public double getBreite() {
|
||||
return breite;
|
||||
}
|
||||
|
||||
public void setBreite(double breite) {
|
||||
this.breite = breite;
|
||||
}
|
||||
|
||||
public double getHoehe() {
|
||||
return hoehe;
|
||||
}
|
||||
|
||||
public void setHoehe(double hoehe) {
|
||||
this.hoehe = hoehe;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ public final class Spiel {
|
|||
|
||||
// Statistik ausgeben
|
||||
System.out.println("Statistik für alle Würfel in Zahlen:");
|
||||
System.out.println("Von " + Wuerfel.counter + " würfen");
|
||||
System.out.println("Von " + Wuerfel.getCounter + " würfen");
|
||||
System.out.println(wuerfel1.statistik());
|
||||
System.out.println();
|
||||
System.out.println("Statsitik für alle Würfel in Prozent");
|
||||
System.out.println("Von " + Wuerfel.counter + " würfen");
|
||||
System.out.println("Von " + Wuerfel.getCounter + " würfen");
|
||||
System.out.println(wuerfel1.statistikProzent());
|
||||
System.out.println();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ public class Wuerfel {
|
|||
|
||||
/** Häufigkeit der Werte. */
|
||||
private static int[] haeufigkeit = new int[6];
|
||||
public static double counter = 0;
|
||||
private static double counter = 0;
|
||||
/** Zufallsgenerator. */
|
||||
private Random random = new Random();
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class Wuerfel {
|
|||
|
||||
for (int i = 0; i < haeufigkeit.length; i++) {
|
||||
|
||||
double prozent = (100/counter*haeufigkeit[i]);
|
||||
double prozent = (100 / counter * haeufigkeit[i]);
|
||||
|
||||
result.append(i + 1)
|
||||
.append(": ")
|
||||
|
@ -59,4 +59,7 @@ public class Wuerfel {
|
|||
}
|
||||
return result.toString();
|
||||
}
|
||||
public double getCounter() {
|
||||
return counter;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue