u15
This commit is contained in:
parent
81ee8d3152
commit
89d7d12c66
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<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"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>u15</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,14 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=17
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=17
|
|
@ -0,0 +1,18 @@
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test-Klasse für die Spieler Klassse
|
||||||
|
* @author p8q-yhw-u1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ArrayList<Spieler> spieler = new ArrayList<Spieler>();
|
||||||
|
spieler.add(new Spieler("Sepp Maier"));
|
||||||
|
spieler.add(new Spieler("Berti Vogts"));
|
||||||
|
spieler.add(new Spieler("Paule Breitner"));
|
||||||
|
|
||||||
|
System.out.println(spieler.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Klasse für Spieler eines Fußballspiels
|
||||||
|
* @author p8q-yhw-u1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Spieler {
|
||||||
|
private static int anzahlSpieler = 0;
|
||||||
|
public static final int MAX_PLAYERS = 11;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int nummer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erzeugt ein Spieler-Objekt mit einem bestimmen Namen.
|
||||||
|
* Spielernummer wird aus der Anzahl der bereits erstellten Spieler automatisch festgelegt
|
||||||
|
* Es dürfen maximal MAX_PLAYERS (11) Spieler erstellt werden.
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public Spieler(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.nummer = ++anzahlSpieler;
|
||||||
|
if (this.nummer > MAX_PLAYERS) {
|
||||||
|
throw new IllegalStateException("Mehr als " + MAX_PLAYERS + " Spieler sind verboten!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt den Spieler in folgendem Format als String zurück:
|
||||||
|
* Name (Nummer)
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s (%d)", this.name, this.nummer);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue