mirror of
https://github.com/DerTyp7/lf05-java.git
synced 2025-11-02 14:22:30 +01:00
add stuff
This commit is contained in:
36
src/fussball/Ergebnis.java
Normal file
36
src/fussball/Ergebnis.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package fussball;
|
||||
|
||||
public class Ergebnis {
|
||||
private int tore1;
|
||||
private int tore2;
|
||||
|
||||
|
||||
public Ergebnis(int tore1, int tore2) {
|
||||
this.tore1 = tore1;
|
||||
this.tore2 = tore2;
|
||||
}
|
||||
|
||||
public void addTor1(){
|
||||
this.tore1 += 1;
|
||||
}
|
||||
|
||||
public void addTor2(){
|
||||
this.tore2 += 1;
|
||||
}
|
||||
|
||||
public int getTore1() {
|
||||
return tore1;
|
||||
}
|
||||
|
||||
public void setTore1(int tore1) {
|
||||
this.tore1 = tore1;
|
||||
}
|
||||
|
||||
public int getTore2() {
|
||||
return tore2;
|
||||
}
|
||||
|
||||
public void setTore2(int tore2) {
|
||||
this.tore2 = tore2;
|
||||
}
|
||||
}
|
||||
72
src/fussball/Mannschaft.java
Normal file
72
src/fussball/Mannschaft.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package fussball;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Mannschaft {
|
||||
private String name;
|
||||
private Torwart torwart;
|
||||
private Trainer trainer;
|
||||
private ArrayList<Spieler> spielerList;
|
||||
|
||||
|
||||
public Mannschaft(String name, Torwart torwart, Trainer trainer, ArrayList<Spieler> spielerList) {
|
||||
this.name = name;
|
||||
this.torwart = torwart;
|
||||
this.trainer = trainer;
|
||||
this.spielerList = spielerList;
|
||||
}
|
||||
|
||||
public int getMotivation(){
|
||||
int motivation = 0;
|
||||
|
||||
for (Spieler spieler: spielerList) {
|
||||
motivation += spieler.getMotivation();
|
||||
}
|
||||
motivation += torwart.getMotivation();
|
||||
|
||||
return (motivation / (spielerList.size() + 1));
|
||||
}
|
||||
|
||||
public int getStaerke(){
|
||||
int staerke = 0;
|
||||
|
||||
for (Spieler spieler: spielerList) {
|
||||
staerke += spieler.getStaerke();
|
||||
}
|
||||
staerke += torwart.getStaerke();
|
||||
|
||||
return (staerke / (spielerList.size() + 1));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Torwart getTorwart() {
|
||||
return torwart;
|
||||
}
|
||||
|
||||
public void setTorwart(Torwart torwart) {
|
||||
this.torwart = torwart;
|
||||
}
|
||||
|
||||
public Trainer getTrainer() {
|
||||
return trainer;
|
||||
}
|
||||
|
||||
public void setTrainer(Trainer trainer) {
|
||||
this.trainer = trainer;
|
||||
}
|
||||
|
||||
public ArrayList<Spieler> getSpielerList() {
|
||||
return spielerList;
|
||||
}
|
||||
|
||||
public void setSpielerList(ArrayList<Spieler> spielerList) {
|
||||
this.spielerList = spielerList;
|
||||
}
|
||||
}
|
||||
28
src/fussball/Person.java
Normal file
28
src/fussball/Person.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package fussball;
|
||||
|
||||
public abstract class Person {
|
||||
private String name;
|
||||
private int alter;
|
||||
|
||||
|
||||
public Person(String name, int alter){
|
||||
this.name = name;
|
||||
this.alter = alter;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAlter() {
|
||||
return alter;
|
||||
}
|
||||
|
||||
public void setAlter(int alter) {
|
||||
this.alter = alter;
|
||||
}
|
||||
}
|
||||
7
src/fussball/Programm.java
Normal file
7
src/fussball/Programm.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package fussball;
|
||||
|
||||
public class Programm {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
35
src/fussball/Spiel.java
Normal file
35
src/fussball/Spiel.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package fussball;
|
||||
|
||||
public class Spiel {
|
||||
private Mannschaft heim;
|
||||
private Mannschaft gast;
|
||||
private Ergebnis ergebnis;
|
||||
private StringBuilder spielverlauf;
|
||||
|
||||
public Spiel(Mannschaft heim, Mannschaft gast, Ergebnis ergebnis, StringBuilder spielverlauf) {
|
||||
this.heim = heim;
|
||||
this.gast = gast;
|
||||
this.ergebnis = ergebnis;
|
||||
this.spielverlauf = spielverlauf;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return heim.getName() + ": " + ergebnis.getTore1() ;
|
||||
}
|
||||
|
||||
public Mannschaft getHeim() {
|
||||
return heim;
|
||||
}
|
||||
|
||||
public Mannschaft getGast() {
|
||||
return gast;
|
||||
}
|
||||
|
||||
public Ergebnis getErgebnis() {
|
||||
return ergebnis;
|
||||
}
|
||||
|
||||
public StringBuilder getSpielverlauf() {
|
||||
return spielverlauf;
|
||||
}
|
||||
}
|
||||
66
src/fussball/Spieler.java
Normal file
66
src/fussball/Spieler.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package fussball;
|
||||
|
||||
public class Spieler {
|
||||
private String name;
|
||||
private int alter;
|
||||
private int staerke;
|
||||
private int torschuss;
|
||||
private int motivation;
|
||||
private int tore;
|
||||
|
||||
void Spieler(String name, int staerke, int torschuss, int motivation, int tore){
|
||||
this.name = name;
|
||||
this.staerke = staerke;
|
||||
this.torschuss = torschuss;
|
||||
this.motivation = motivation;
|
||||
this.tore = tore;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAlter() {
|
||||
return alter;
|
||||
}
|
||||
|
||||
public void setAlter(int alter) {
|
||||
this.alter = alter;
|
||||
}
|
||||
|
||||
public int getStaerke() {
|
||||
return staerke;
|
||||
}
|
||||
|
||||
public void setStaerke(int staerke) {
|
||||
this.staerke = staerke;
|
||||
}
|
||||
|
||||
public int getTorschuss() {
|
||||
return torschuss;
|
||||
}
|
||||
|
||||
public void setTorschuss(int torschuss) {
|
||||
this.torschuss = torschuss;
|
||||
}
|
||||
|
||||
public int getMotivation() {
|
||||
return motivation;
|
||||
}
|
||||
|
||||
public void setMotivation(int motivation) {
|
||||
this.motivation = motivation;
|
||||
}
|
||||
|
||||
public int getTore() {
|
||||
return tore;
|
||||
}
|
||||
|
||||
public void setTore(int tore) {
|
||||
this.tore = tore;
|
||||
}
|
||||
}
|
||||
13
src/fussball/Torwart.java
Normal file
13
src/fussball/Torwart.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package fussball;
|
||||
|
||||
public class Torwart extends Spieler{
|
||||
private int reaktion;
|
||||
|
||||
public int getReaktion() {
|
||||
return reaktion;
|
||||
}
|
||||
|
||||
public void setReaktion(int reaktion) {
|
||||
this.reaktion = reaktion;
|
||||
}
|
||||
}
|
||||
24
src/fussball/Trainer.java
Normal file
24
src/fussball/Trainer.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package fussball;
|
||||
|
||||
public class Trainer extends Person{
|
||||
private int erfahrung;
|
||||
|
||||
public Trainer(String name, int alter, int erfahrung){
|
||||
super(name, alter);
|
||||
this.erfahrung = erfahrung;
|
||||
}
|
||||
|
||||
public int getErfahrung(){
|
||||
return this.erfahrung;
|
||||
}
|
||||
|
||||
public void setErfahrung(int newErfahrung){
|
||||
this.erfahrung = newErfahrung;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
String erfahrungStr = "Erfahrung: " + this.erfahrung + "\n";
|
||||
|
||||
return erfahrungStr;
|
||||
}
|
||||
}
|
||||
15
src/motorrad/Motorrad.java
Normal file
15
src/motorrad/Motorrad.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package motorrad;
|
||||
|
||||
public class Motorrad extends Vehicle{
|
||||
|
||||
|
||||
@Override
|
||||
public void bremsen() {
|
||||
System.out.println("Bremsen");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beschleunigen() {
|
||||
System.out.println("fahren");
|
||||
}
|
||||
}
|
||||
10
src/motorrad/Programm.java
Normal file
10
src/motorrad/Programm.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package motorrad;
|
||||
|
||||
public class Programm {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Motorrad motorrad = new Motorrad();
|
||||
|
||||
motorrad.bremsen();
|
||||
}
|
||||
}
|
||||
7
src/motorrad/Vehicle.java
Normal file
7
src/motorrad/Vehicle.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package motorrad;
|
||||
|
||||
public abstract class Vehicle {
|
||||
|
||||
public abstract void bremsen();
|
||||
public abstract void beschleunigen();
|
||||
}
|
||||
10
src/rekursion/Fakultaet.java
Normal file
10
src/rekursion/Fakultaet.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package rekursion;
|
||||
|
||||
public class Fakultaet {
|
||||
public static void fak(){
|
||||
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
6
src/rollenspiel/Character.java
Normal file
6
src/rollenspiel/Character.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package rollenspiel;
|
||||
|
||||
public class Character {
|
||||
private String name;
|
||||
|
||||
}
|
||||
4
src/rollenspiel/Rollenspiel.java
Normal file
4
src/rollenspiel/Rollenspiel.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package rollenspiel;
|
||||
|
||||
public class Rollenspiel {
|
||||
}
|
||||
25
src/singletonPattern/Singleton.java
Normal file
25
src/singletonPattern/Singleton.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package singletonPattern;
|
||||
|
||||
public class Singleton {
|
||||
private static Singleton instance;
|
||||
private String speicherOrt;
|
||||
|
||||
private Singleton(String speicherOrt){
|
||||
this.speicherOrt = speicherOrt;
|
||||
}
|
||||
|
||||
public static Singleton getInstance() {
|
||||
if(instance == null){
|
||||
instance = new Singleton("test");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getSpeicherOrt() {
|
||||
return speicherOrt;
|
||||
}
|
||||
|
||||
public void setSpeicherOrt(String speicherOrt) {
|
||||
this.speicherOrt = speicherOrt;
|
||||
}
|
||||
}
|
||||
9
src/singletonPattern/SingletonMain.java
Normal file
9
src/singletonPattern/SingletonMain.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package singletonPattern;
|
||||
|
||||
public class SingletonMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Singleton.getInstance().getSpeicherOrt());
|
||||
}
|
||||
|
||||
}
|
||||
18
src/spielwiese/DreiGewinnt.java
Normal file
18
src/spielwiese/DreiGewinnt.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package spielwiese;
|
||||
|
||||
public class DreiGewinnt {
|
||||
public static void createGrid(int width, int height) {
|
||||
System.out.print(" | ");
|
||||
for (int i = 0; i < width; i++) {
|
||||
System.out.print((i + 1) + " | ");
|
||||
for (int a = 0; a < height; a++) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
System.out.print("\n");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
createGrid(5, 10);
|
||||
}
|
||||
}
|
||||
22
src/unit/Pq1.java
Normal file
22
src/unit/Pq1.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package unit;
|
||||
|
||||
public class Pq1 {
|
||||
|
||||
public static double[] pq(double p, double q){
|
||||
double[] result = new double[2];
|
||||
|
||||
double d = Math.pow(p/2, 2) - q;
|
||||
|
||||
result[0] = -(p/2) + Math.sqrt(d);
|
||||
result[1] = -(p/2) - Math.sqrt(d);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
double[] result = pq(1, -7);
|
||||
|
||||
System.out.println(result[0]);
|
||||
System.out.println(result[1]);
|
||||
}
|
||||
}
|
||||
34
src/unit/Test1.java
Normal file
34
src/unit/Test1.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package unit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Test1 {
|
||||
|
||||
@Test
|
||||
void givenPQ_whenSingleSolution_solutionOk(){
|
||||
assertEquals(Double.NaN, unit.Pq1.pq(1,1)[0], "Sehr hilfreiche Message");
|
||||
assertEquals(Double.NaN, unit.Pq1.pq(1,1)[0], "Noch eine sehr hilfreiche Message");
|
||||
assertEquals(Double.NaN, unit.Pq1.pq(1,1)[0], "Eine weitere unglaublich hilfreiche Message");
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("givenPQ_whenDoubleSolution_solutionOk")
|
||||
void givenPQ_whenSingleSolution_solutionOk(double p, double q){
|
||||
assertEquals(Double.NaN, unit.Pq1.pq(1,1)[0], "Sehr hilfreiche Message");
|
||||
}
|
||||
|
||||
static Stream<Arguments> givenPQ_whenDoubleSolution_solutionOk(){
|
||||
return Stream.of(
|
||||
Arguments.of(4,4,-2),
|
||||
Arguments.of(4,3,-2)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,14 +18,11 @@ public class Wuerfeln {
|
||||
wuerfe[i][a] = (int)(Math.random()*6)+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < anzahlExperimente; i++){
|
||||
for(int a = 0; a < anzahlWuerfe; a++){
|
||||
System.out.print(wuerfe[i][a] +" ");
|
||||
}
|
||||
System.out.print("\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user