This commit is contained in:
Alperen
2022-02-14 09:33:16 +01:00
3 changed files with 121 additions and 123 deletions

View File

@@ -1,20 +1,65 @@
public class Game {
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen
WordleServer wordleServer;
User user;
DatabaseConnector databaseConnector;// Datenbankverbindung aufstellen
private String wordle;
private String[] words;
private int count;
public Game(WordleServer wordleServer) {
this.wordleServer = wordleServer;
user = new User();
}
public void processMessage(String msg) {
System.out.println(msg);
}
// Instanzvariablen - ersetzen Sie das folgende Beispiel mit Ihren Variablen
WordleServer wordleServer;
User user;
static DatabaseConnector databaseConnector;// Datenbankverbindung aufstellen
private String ip;
private int port;
private String wordle;
private String[] words;
private int count;
private int phase;
public Game(WordleServer wordleServer, String pClientIP, int pClientPort) {
this.wordleServer = wordleServer;
this.ip = pClientIP;
this.port = pClientPort;
user = new User();
send("+OK Hello there");
}
public void processMessage(String msg) {
if (msg.equals("quit")) {
send("+OK bye");
wordleServer.closeConnection(ip, port);
}
switch (phase) {
case 0:
break;
case 1:
break;
case 2:
break;
}
}
private void send(String msg) {
wordleServer.send(ip, port, msg);
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
}

View File

@@ -29,18 +29,28 @@ public class WordleServer extends Server {
@Override
public void processNewConnection( String pClientIP, int pClientPort ) {
games.append(new Game(this));
games.append(new Game(this, pClientIP, pClientPort));
}
@Override
public void processClosingConnection( String pClientIP, int pClientPort ) {
System.out.println("Closed connection: " + pClientPort);
find(pClientIP, pClientPort);
games.remove();
}
@Override
public void processMessage( String pClientIP, int pClientPort, String pMessage ) {
games.toFirst();
games.getContent().processMessage(pMessage);
find(pClientIP, pClientPort).processMessage(pMessage);
}
private Game find(String ip, int port) {
games.toFirst();
while (games.hasAccess()) {
Game g = games.getContent();
if (g.getIp().equals(ip) && g.getPort() == port) {
return g;
}
}
return null;
}
}

145
umlet.uxf
View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="14.3.0">
<zoom_level>12</zoom_level>
<zoom_level>8</zoom_level>
<element>
<id>UMLClass</id>
<coordinates>
<x>636</x>
<y>144</y>
<w>120</w>
<h>36</h>
<x>936</x>
<y>208</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>Server</panel_attributes>
<additional_attributes/>
@@ -15,10 +15,10 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>636</x>
<y>300</y>
<w>120</w>
<h>36</h>
<x>936</x>
<y>312</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>WordleServer</panel_attributes>
<additional_attributes/>
@@ -26,10 +26,10 @@
<element>
<id>Relation</id>
<coordinates>
<x>684</x>
<y>168</y>
<w>36</w>
<h>156</h>
<x>968</x>
<y>224</y>
<w>24</w>
<h>104</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;-</panel_attributes>
<additional_attributes>10.0;10.0;10.0;110.0</additional_attributes>
@@ -37,10 +37,10 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>0</x>
<y>420</y>
<w>348</w>
<h>468</h>
<x>512</x>
<y>392</y>
<w>232</w>
<h>312</h>
</coordinates>
<panel_attributes>User
--
@@ -72,10 +72,10 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>180</x>
<y>276</y>
<w>168</w>
<h>36</h>
<x>632</x>
<y>296</y>
<w>112</w>
<h>24</h>
</coordinates>
<panel_attributes>DatabaseConnector</panel_attributes>
<additional_attributes/>
@@ -83,10 +83,10 @@
<element>
<id>Relation</id>
<coordinates>
<x>684</x>
<y>324</y>
<w>144</w>
<h>120</h>
<x>968</x>
<y>328</y>
<w>96</w>
<h>80</h>
</coordinates>
<panel_attributes>lt=&lt;.
-wordleServer</panel_attributes>
@@ -95,13 +95,16 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>516</x>
<y>420</y>
<w>360</w>
<h>132</h>
<x>856</x>
<y>392</y>
<w>240</w>
<h>88</h>
</coordinates>
<panel_attributes>Game
--
-ip: String
-port: int
-wordle: String
-words: String[]
-wordCount: int
@@ -113,24 +116,10 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>1020</x>
<y>420</y>
<w>288</w>
<h>84</h>
</coordinates>
<panel_attributes>GUI
--
+setLetter(char letter): void
+setLetterColor(byte color): void</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>108</x>
<y>156</y>
<w>120</w>
<h>36</h>
<x>584</x>
<y>216</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>QueryResult</panel_attributes>
<additional_attributes/>
@@ -138,10 +127,10 @@
<element>
<id>Relation</id>
<coordinates>
<x>336</x>
<y>408</y>
<w>204</w>
<h>48</h>
<x>736</x>
<y>384</y>
<w>136</w>
<h>32</h>
</coordinates>
<panel_attributes>lt=&lt;.
-user</panel_attributes>
@@ -150,59 +139,13 @@
<element>
<id>Relation</id>
<coordinates>
<x>864</x>
<y>408</y>
<w>180</w>
<h>48</h>
</coordinates>
<panel_attributes>lt=&lt;.
-gui</panel_attributes>
<additional_attributes>130.0;20.0;10.0;20.0</additional_attributes>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>336</x>
<y>276</y>
<w>264</w>
<h>168</h>
<x>736</x>
<y>296</y>
<w>176</w>
<h>112</h>
</coordinates>
<panel_attributes>lt=&lt;.
-databaseConnector</panel_attributes>
<additional_attributes>10.0;20.0;200.0;20.0;200.0;120.0</additional_attributes>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>1020</x>
<y>0</y>
<w>288</w>
<h>300</h>
</coordinates>
<panel_attributes>Letter
--
WHITE: byte = -1
GRAY: byte = 0
YELLOW: byte = 1
GREEN: byte = 2
-letter: char
-color: byte
--
+setColor(byte color): void
+getColor(): byte</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>1152</x>
<y>288</y>
<w>156</w>
<h>156</h>
</coordinates>
<panel_attributes>lt=&lt;.
-letters: Letter[][]</panel_attributes>
<additional_attributes>10.0;10.0;10.0;110.0</additional_attributes>
</element>
</diagram>