Skip to content
Snippets Groups Projects
Commit 783767af authored by bluml's avatar bluml
Browse files

UNO

parents
No related branches found
No related tags found
No related merge requests found
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/UNO.iml" filepath="$PROJECT_DIR$/UNO.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="44e80353-cbea-4c4e-9480-d81435d9a232" name="Changes" comment="UNO">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/UNO.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/UNO.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/UnoHand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/UnoKarte.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2OYXzNTOEvjm8eteKN5q9MfoBpb" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"WebServerToolWindowFactoryState": "false",
"last_opened_file_path": "C:/Users/bluml/IdeaProjects/UNO/src",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\bluml\IdeaProjects\UNO\src" />
</key>
</component>
<component name="RunManager" selected="Application.UNO">
<configuration name="Main" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" />
<module name="UNO" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="UNO" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="UNO" />
<module name="UNO" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.UNO" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="44e80353-cbea-4c4e-9480-d81435d9a232" name="Changes" comment="" />
<created>1681738754187</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1681738754187</updated>
<workItem from="1681738754698" duration="8307000" />
<workItem from="1681890321022" duration="957000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="." />
<MESSAGE value="UNO" />
<option name="LAST_COMMIT_MESSAGE" value="UNO" />
</component>
</project>
\ No newline at end of file
UNO.iml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
import java.util.Scanner;
public class UNO {
public static void main(String[]args){
Scanner scanner = new Scanner(System.in);
System.out.println("Zum Starten, Start schreiben");
String start = scanner.nextLine();
if("start" .equals(start.toLowerCase())){
//Spiler Namen Abfrage und Anzahl der Spieler
System.out.println("Kurze Information: mind. 2 Player max. 4 Player");
System.out.println("Enter Player Names:");
int index;
int PlayerAnzahl = 0;
String Antwort;
String PlayerNameInput;
String PlayerName[] = new String[4];
for(index = 0; index < 4;){
PlayerAnzahl++;
PlayerNameInput = scanner.nextLine();
PlayerName[index] = PlayerNameInput;
index++;
if(index >= 2){
System.out.println("Sind das die Maximalen Spieler?");
Antwort = scanner.nextLine();
if("ja" .equals(Antwort.toLowerCase())){
index = 4;
}else {
System.out.println("Weitere Spieler:");
}
}
}
//GameLoop:
boolean win = false;
while (!win) {
UnoHand hand = new UnoHand();
hand.befuellen();
hand.mischeHand();
hand.zeigeHand();
win = true;
}
}
}
}
import java.util.ArrayList;
import java.util.Collections;
public class UnoHand {
private ArrayList<UnoKarte> hand;
public UnoHand() {
hand = new ArrayList<UnoKarte>();
}
public void fuegeKarteHinzu(UnoKarte karte) {
hand.add(karte);
}
public void mischeHand() {
Collections.shuffle(hand);
}
public void zeigeHand() {
for (UnoKarte karte : hand) {
System.out.println(karte);
}
}
public Wert wertVonZahl(int zahl) {
switch (zahl) {
case 0:
return Wert.Null;
case 1:
return Wert.Eins;
case 2:
return Wert.Zwei;
case 3:
return Wert.Drei;
case 4:
return Wert.Vier;
case 5:
return Wert.Fuenf;
case 6:
return Wert.Sechs;
case 7:
return Wert.Sieben;
case 8:
return Wert.Acht;
case 9:
return Wert.Neun;
default:
throw new IllegalArgumentException("Ungültige Zahl: " + zahl);
}
}
public void befuellen() {
for (Farbe farbe : Farbe.values()) {
if (farbe == Farbe.Wild || farbe == Farbe.Wild_Draw_Four) {
// keine Wild-Karten hinzufügen
continue;
}
for (int zahl = 0; zahl <= 9; zahl++) {
fuegeKarteHinzu(new UnoKarte(farbe, wertVonZahl(zahl)));
}
fuegeKarteHinzu(new UnoKarte(farbe, Wert.Richtungswechsel));
fuegeKarteHinzu(new UnoKarte(farbe, Wert.Aussetzen));
fuegeKarteHinzu(new UnoKarte(farbe, Wert.Zwei_Ziehen));
}
for (int i = 0; i < 4; i++) {
fuegeKarteHinzu(new UnoKarte(Farbe.Wild, Wert.Wild));
fuegeKarteHinzu(new UnoKarte(Farbe.Wild_Draw_Four, Wert.Wild_Draw_Four));
}
}
}
public class UnoKarte {
private Farbe farbe;
private Wert wert;
public UnoKarte(Farbe farbe, Wert wert) {
this.farbe = farbe;
this.wert = wert;
}
public Farbe getFarbe() {
return farbe;
}
public Wert getWert() {
return wert;
}
@Override
public String toString() {
return farbe.toString() + " " + wert.toString();
}
}
enum Farbe {
Rot, Blau, Gruen, Gelb, Wild, Wild_Draw_Four
}
enum Wert {
Null, Eins, Zwei, Drei, Vier, Fuenf, Sechs, Sieben, Acht, Neun, Aussetzen, Richtungswechsel, Zwei_Ziehen, Wild, Wild_Draw_Four
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment