forked from 2211945/WIZARD_PR2_DOP
Persistenz pluss erster anfang SpielCLI
parent
1571a95a08
commit
6f9157ef50
|
@ -2,4 +2,8 @@
|
|||
*.ser
|
||||
|
||||
# Object Data
|
||||
*.o
|
||||
*.o
|
||||
|
||||
#sonstiges
|
||||
.idea
|
||||
out
|
|
@ -0,0 +1,7 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="20 (2)" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/WIAZRD_DOP_PR2.iml" filepath="$PROJECT_DIR$/WIAZRD_DOP_PR2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -6,7 +6,9 @@ written on: 05 / 10 / 2023 at: 23:31
|
|||
*/
|
||||
package Domain.Enums;
|
||||
|
||||
public enum Geschlecht {
|
||||
import java.io.Serializable;
|
||||
|
||||
public enum Geschlecht implements Serializable {
|
||||
|
||||
M, W, D, KI;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ package Domain;
|
|||
|
||||
import Domain.Enums.Geschlecht;
|
||||
|
||||
public class Spieler {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Spieler implements Serializable {
|
||||
|
||||
// Statische Konstanten
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@ written on: 05 / 10 / 2023 at: 23:25
|
|||
*/
|
||||
package Facade;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import Domain.Spieler;
|
||||
import Domain.Enums.Geschlecht;
|
||||
|
||||
public class Spiel {
|
||||
public class Spiel implements Serializable {
|
||||
|
||||
private boolean istGestartet;
|
||||
private boolean istBeendet;
|
||||
|
|
|
@ -6,6 +6,32 @@ written on: 05 / 10 / 2023 at: 23:25
|
|||
*/
|
||||
package Infrastructure;
|
||||
|
||||
import Facade.Spiel;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Persistenz {
|
||||
|
||||
final static String FILE_NAME = "WIZARD_DATA_";
|
||||
|
||||
public static boolean sindDatenVorhanden(String name){
|
||||
File f = new File(FILE_NAME + name + ".ser");
|
||||
if(f.exists()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void speichereDaten(String name, Spiel spiel) throws IOException {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(FILE_NAME + name + ".ser"));
|
||||
oos.writeObject(spiel);
|
||||
oos.close();
|
||||
}
|
||||
|
||||
public static Object ladeDaten(String name) throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(FILE_NAME + name + ".ser"));
|
||||
Object spiel = ois.readObject();
|
||||
ois.close();
|
||||
return spiel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import Facade.Spiel;
|
||||
import Infrastructure.Persistenz;
|
||||
import UI.SpielCLI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLOutput;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
String name = "Wizard";
|
||||
Spiel spiel = null;
|
||||
|
||||
if(Persistenz.sindDatenVorhanden(name)){
|
||||
try{
|
||||
System.out.println("Lade daten");
|
||||
spiel = (Spiel) Persistenz.ladeDaten(name);
|
||||
}catch(IOException e){
|
||||
System.out.println("Konnte file nicht laden.");
|
||||
System.out.println(e.getLocalizedMessage());
|
||||
|
||||
}catch(ClassNotFoundException cnfe){
|
||||
System.out.println("Konnte file nicht laden.");
|
||||
System.out.println(cnfe.getLocalizedMessage());
|
||||
}finally{
|
||||
if(spiel == null){
|
||||
System.out.println("Initialisiere neues Spiel");
|
||||
spiel = new Spiel();
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
spiel = new Spiel();
|
||||
}
|
||||
|
||||
new SpielCLI(spiel);
|
||||
|
||||
try {
|
||||
Persistenz.speichereDaten(name, spiel);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Konnte Daten nicht speicher!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,51 @@ written on: 05 / 10 / 2023 at: 23:25
|
|||
|
||||
package UI;
|
||||
|
||||
import Facade.Spiel;
|
||||
|
||||
import java.sql.SQLOutput;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
||||
|
||||
public class SpielCLI {
|
||||
int x = 12;
|
||||
|
||||
//Kommentar
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
private Spiel spiel;
|
||||
public SpielCLI(Spiel spiel){
|
||||
this.spiel = spiel;
|
||||
hauptmenue();
|
||||
}
|
||||
|
||||
|
||||
public void hauptmenue(){
|
||||
mainloop:
|
||||
while(true){
|
||||
System.out.println("Hallo Wanderer");
|
||||
System.out.println("Was sillst du tun");
|
||||
System.out.println("--------Hauptmenü--------");
|
||||
System.out.println("-1- Spiel starten");
|
||||
System.out.println("-2- Exit");
|
||||
|
||||
int input = 0;
|
||||
|
||||
try{
|
||||
input = Integer.parseInt(sc.nextLine());
|
||||
}catch(NumberFormatException e){
|
||||
System.out.println("Diese eingabe ist ungültig.");
|
||||
}
|
||||
|
||||
switch(input){
|
||||
case 1:
|
||||
System.out.println("Noch nicht implementiert.");
|
||||
break;
|
||||
case 2:
|
||||
break mainloop;
|
||||
case 0:
|
||||
System.out.println("Diese eingabe ist nicht vergeben.");
|
||||
}
|
||||
}
|
||||
System.out.println("auf wiedersehen!");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?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$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,5 @@
|
|||
# Serialized Data
|
||||
*.ser
|
||||
|
||||
# Object Data
|
||||
*.o
|
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,7 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="20 (2)" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/WIAZRD_DOP_PR2.iml" filepath="$PROJECT_DIR$/WIAZRD_DOP_PR2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,48 @@
|
|||
# Wizard PR2 Prof. Dopatka
|
||||
|
||||
Gruppe Studienleistung bereits vorhanden
|
||||
|
||||
## Teilnehmer
|
||||
|
||||
- Kai Sellman
|
||||
- Odin Selimovic
|
||||
- Mohammad Hawrami
|
||||
- Philipp Kotte
|
||||
|
||||
## Dopatka Regeln wie Klassen anzulegen sind
|
||||
|
||||
1. statische Konstante
|
||||
2. statische Attribute(zB. zähler)
|
||||
3. Attribute jedes Objektes
|
||||
4. Konstruktoren (default und spezifische)
|
||||
5. statische Methoden
|
||||
6. Getter und Setter
|
||||
7. @Overrides
|
||||
8. öffentliche Methodes
|
||||
9. Hilfsmethoden (privat)
|
||||
|
||||
## Für das Arbeiten mit geschützten Mainbranch
|
||||
|
||||
Wenn Änderungen durchgeführt werden müssen, kann dieses nicht direkt auf dem main-Branch gepusht werden sondern muss mit einem Separatem Branch und Pull-Request durchgeführt werden.
|
||||
Die Schritte um einen Feature-Branch zu erstellen sind folgende:
|
||||
|
||||
#### 1. Erstellen eines neuen Branch auf Basis des aktuellen main:
|
||||
|
||||
`git checkout -b <Branchname>`
|
||||
|
||||
> Switchen zwischen den branches:
|
||||
> `git checkout <Branchname>`
|
||||
|
||||
Hier wird das Feature Ausgearbeitet und fertiggestellt.
|
||||
|
||||
#### 2. Aktualisieren mit Mainbranch
|
||||
|
||||
Besonders wenn eine Weile an dem Feature Branch gearbeitet wurde, können bereits Änderungen auf Main durchgeführt worde sein. Daher wird vor dem Pull Request der Feature-Branch mit dem Main-Branch gemerget.
|
||||
|
||||
> Mergen des Main-Branch in den Feature Branch
|
||||
> `git pull origin main`
|
||||
|
||||
#### 3. Pull Request
|
||||
|
||||
Danach damit wir alle die Changes mitbekommen muss ein Pull Request auf Gitea gestellt werden.
|
||||
Im zuge dessen findet eine Code Review von einem beliebigen Teammitglied statt, damit dieser frei gegeben werden kann.
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
<?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$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue