diff --git a/README.md b/README.md
deleted file mode 100644
index c0daab2..0000000
--- a/README.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# Client_Server_Java
-Multi Client to one Server application using Java sockets, threads and Java Swing graphic library.
-
-## Requirements
-
-Design and develop a simple client-server application implementing a simple Quiz game.
-1. The users can connect to register to the Game Server to start a quiz game. The communication between client and server can be implemented with sockets
-2. The server can set up a game for *M* players, to be decided at load-time.
-3. The client will have a textual interface.
-4. The game can run in 3 modes: _practice_, _friendly_, or _tournament_.
-5. In the **practice** mode the user will receive N questions one after another and there is no timeout and no competition with other users: their own final result will be sent to him afterwards
-6. In the **friendly** mode, when the game starts the server sends the same set of N questions to all users, but the competition is not in real-time: each session with a user/client is managed independently from the others and when all the users have answered all the questions then the final ranking is shown to all. Use a timeout to conclude the quiz and print the results.
-7. In the **tournament** mode, when the game starts the server send to all the clients a random question among N quizzes, loaded from a file, with the 5 possible answers that will be shown to the users (only one is correct).
-
- *a*. The first user sending the correct answer will get one point.
-
- *b*. The winning user and the correct answer will be shown to all the users, along with the current rank.
-
- *c*. After *N* (configurable) questions the game ends and the final rank is visualized: a congratulation message is sent to the winner and a consolation message is sent to the others.
-
- 8. Develop also Junit testcases for the game server
- ### Optional Requirements
- 1. Extend requirement 2 so that the game will start when a timeout elapses, instead of waiting for M players: this should be configured at start-time via configuration file or command line.
- 2. Extend the client interface with a Swing GUI
- 3. Consider the tournament mode: how to guarantee fair treatment to all users considering that network delays can penalize some users with respect to others? For example, user A has a faster connection and it often receives the questions one second before the other participants: how the server could consider these delays to determine which user took actually less time to answer?
- 4. Manage the case when one client disconnects during the game: how will you manage client reconnection?
-
-
-## Contents
-
-Repository is divided between two main folders
-
-1. *server*
-
-2. *client*
-
-where each one is a Gradle Project.
-
-As the name suggets **client** contains the client application part, thus the part which allows the client to play using a graphic interface and so where all graphic logic is written. Meanwhile **server** contains all the algorithms that handle the communication between multiple clients/creation or partecipation to existing matches/answering and picking new questions.
-
-## How to run it
-
-In order to run the project, you first need to run the **server** application, thus open its Gradle project with your preferred IDE and launch the program from the **main** file located at *\src\main\java\org\example\Main.java*.
-
-Please note that you MUST open the IDE on "server" folder as starting folder and not other ones, otherwise some problems can occur regarding questions.txt file since the file is not correctly seen by the program causing the freeze of the client, this problem must be fixed.
-
-Notice that server is now listening at a default port, in this case is 9002
-
-Now, after you have launched the server, you can also launch the client, so open its Gradle project ("client" folder) and run the project from the main file located at *\src\main\java\org\example\Main.java*.
-
-Also in this case some default settings are present, in detail there is the address and the port of the server (address: localhost and port:9002).
-
-I suggest you to start two different IDE istances, one for the server folder and one for the client one, I noticed some problems regarding "questions.txt" file that isn't correctly seen if you open the project on parent Client_Server_Java-main folder, especially on Windows OS.
-
-## Future implementations
-
-Future updates of the project will allow the client to pass metadata server information as PORT and ADDRESS as parameters so without manipulating code, also it could be fine to dockerize both applications in order to have a simpler deployment phase.
-
-Since *server* and *client* projects share many common model java classes, it should be fine to separate them from both applications and then to build a unique shared JAR file, this solution will allow an easier maintainance.
-At the moment files are both duplicated inside each projects since is easier to show them during a presentation.
-
-Another big implementation is to better handle thread concurrency over shared resources, now there is a bottleneck due to the lock on a single common object, this was made since it is a simple and rapid solution, other solutions coould be to create a mutex for each shared resource and lock only the one you need and not a generic one as now.
diff --git a/server/build.gradle b/build.gradle
similarity index 100%
rename from server/build.gradle
rename to build.gradle
diff --git a/build/classes/java/main/org/example/Main.class b/build/classes/java/main/org/example/Main.class
new file mode 100644
index 0000000..3c8a4cd
Binary files /dev/null and b/build/classes/java/main/org/example/Main.class differ
diff --git a/build/classes/java/main/org/example/Server.class b/build/classes/java/main/org/example/Server.class
new file mode 100644
index 0000000..c2f9a83
Binary files /dev/null and b/build/classes/java/main/org/example/Server.class differ
diff --git a/client/build/classes/java/main/org/example/interfaces/Messages.class b/build/classes/java/main/org/example/interfaces/Messages.class
similarity index 100%
rename from client/build/classes/java/main/org/example/interfaces/Messages.class
rename to build/classes/java/main/org/example/interfaces/Messages.class
diff --git a/server/build/classes/java/main/org/example/interfaces/Registries.class b/build/classes/java/main/org/example/interfaces/Registries.class
similarity index 100%
rename from server/build/classes/java/main/org/example/interfaces/Registries.class
rename to build/classes/java/main/org/example/interfaces/Registries.class
diff --git a/server/build/classes/java/main/org/example/interfaces/Senders.class b/build/classes/java/main/org/example/interfaces/Senders.class
similarity index 100%
rename from server/build/classes/java/main/org/example/interfaces/Senders.class
rename to build/classes/java/main/org/example/interfaces/Senders.class
diff --git a/client/build/classes/java/main/org/example/model/Match.class b/build/classes/java/main/org/example/model/Match.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/Match.class
rename to build/classes/java/main/org/example/model/Match.class
diff --git a/client/build/classes/java/main/org/example/model/MatchChecker.class b/build/classes/java/main/org/example/model/MatchChecker.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/MatchChecker.class
rename to build/classes/java/main/org/example/model/MatchChecker.class
diff --git a/server/build/classes/java/main/org/example/model/Memory.class b/build/classes/java/main/org/example/model/Memory.class
similarity index 100%
rename from server/build/classes/java/main/org/example/model/Memory.class
rename to build/classes/java/main/org/example/model/Memory.class
diff --git a/client/build/classes/java/main/org/example/model/Message.class b/build/classes/java/main/org/example/model/Message.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/Message.class
rename to build/classes/java/main/org/example/model/Message.class
diff --git a/client/build/classes/java/main/org/example/model/Player.class b/build/classes/java/main/org/example/model/Player.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/Player.class
rename to build/classes/java/main/org/example/model/Player.class
diff --git a/client/build/classes/java/main/org/example/model/Question.class b/build/classes/java/main/org/example/model/Question.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/Question.class
rename to build/classes/java/main/org/example/model/Question.class
diff --git a/server/build/classes/java/main/org/example/model/QuestionOwner.class b/build/classes/java/main/org/example/model/QuestionOwner.class
similarity index 100%
rename from server/build/classes/java/main/org/example/model/QuestionOwner.class
rename to build/classes/java/main/org/example/model/QuestionOwner.class
diff --git a/client/build/classes/java/main/org/example/model/Rank.class b/build/classes/java/main/org/example/model/Rank.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/Rank.class
rename to build/classes/java/main/org/example/model/Rank.class
diff --git a/client/build/classes/java/main/org/example/model/Score.class b/build/classes/java/main/org/example/model/Score.class
similarity index 100%
rename from client/build/classes/java/main/org/example/model/Score.class
rename to build/classes/java/main/org/example/model/Score.class
diff --git a/server/build/classes/java/main/org/example/utils/SenderClient.class b/build/classes/java/main/org/example/utils/SenderClient.class
similarity index 100%
rename from server/build/classes/java/main/org/example/utils/SenderClient.class
rename to build/classes/java/main/org/example/utils/SenderClient.class
diff --git a/build/classes/java/main/org/example/utils/Utility.class b/build/classes/java/main/org/example/utils/Utility.class
new file mode 100644
index 0000000..4fb0ca4
Binary files /dev/null and b/build/classes/java/main/org/example/utils/Utility.class differ
diff --git a/build/classes/java/test/MatchChecker.class b/build/classes/java/test/MatchChecker.class
new file mode 100644
index 0000000..58ff8fe
Binary files /dev/null and b/build/classes/java/test/MatchChecker.class differ
diff --git a/server/build/classes/java/test/MatchTest.class b/build/classes/java/test/MatchTest.class
similarity index 100%
rename from server/build/classes/java/test/MatchTest.class
rename to build/classes/java/test/MatchTest.class
diff --git a/server/build/classes/java/test/MemoryTest.class b/build/classes/java/test/MemoryTest.class
similarity index 100%
rename from server/build/classes/java/test/MemoryTest.class
rename to build/classes/java/test/MemoryTest.class
diff --git a/server/build/classes/java/test/MessageTest.class b/build/classes/java/test/MessageTest.class
similarity index 100%
rename from server/build/classes/java/test/MessageTest.class
rename to build/classes/java/test/MessageTest.class
diff --git a/server/build/classes/java/test/PlayerQuestionTest.class b/build/classes/java/test/PlayerQuestionTest.class
similarity index 100%
rename from server/build/classes/java/test/PlayerQuestionTest.class
rename to build/classes/java/test/PlayerQuestionTest.class
diff --git a/server/build/classes/java/test/QuestionOwnerTest.class b/build/classes/java/test/QuestionOwnerTest.class
similarity index 100%
rename from server/build/classes/java/test/QuestionOwnerTest.class
rename to build/classes/java/test/QuestionOwnerTest.class
diff --git a/server/build/classes/java/test/QuestionTest.class b/build/classes/java/test/QuestionTest.class
similarity index 100%
rename from server/build/classes/java/test/QuestionTest.class
rename to build/classes/java/test/QuestionTest.class
diff --git a/build/classes/java/test/RankTest.class b/build/classes/java/test/RankTest.class
new file mode 100644
index 0000000..162e957
Binary files /dev/null and b/build/classes/java/test/RankTest.class differ
diff --git a/server/build/classes/java/test/ScoreTest.class b/build/classes/java/test/ScoreTest.class
similarity index 100%
rename from server/build/classes/java/test/ScoreTest.class
rename to build/classes/java/test/ScoreTest.class
diff --git a/build/classes/java/test/SenderClientTest.class b/build/classes/java/test/SenderClientTest.class
new file mode 100644
index 0000000..04e5260
Binary files /dev/null and b/build/classes/java/test/SenderClientTest.class differ
diff --git a/build/classes/java/test/UtilityTest.class b/build/classes/java/test/UtilityTest.class
new file mode 100644
index 0000000..27ffadf
Binary files /dev/null and b/build/classes/java/test/UtilityTest.class differ
diff --git a/server/build/reports/tests/test/classes/QuestionOwnerTest.html b/build/reports/tests/test/classes/QuestionOwnerTest.html
similarity index 88%
rename from server/build/reports/tests/test/classes/QuestionOwnerTest.html
rename to build/reports/tests/test/classes/QuestionOwnerTest.html
index 1c787b4..506f8cc 100644
--- a/server/build/reports/tests/test/classes/QuestionOwnerTest.html
+++ b/build/reports/tests/test/classes/QuestionOwnerTest.html
@@ -1,96 +1,96 @@
-
-
-
-
-
-Test results - Class QuestionOwnerTest
-
-
-
-
-
-
-
Class QuestionOwnerTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-test()
-0.002s
-passed
-
-
-
-
-
-
-
-
+
+
+
+
+
+Test results - Class QuestionOwnerTest
+
+
+
+
+
+
+
Class QuestionOwnerTest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Tests
+
+
+
+Test
+Duration
+Result
+
+
+
+test()
+0.015s
+passed
+
+
+
+
+
+
+
+
diff --git a/server/build/reports/tests/test/css/base-style.css b/build/reports/tests/test/css/base-style.css
similarity index 100%
rename from server/build/reports/tests/test/css/base-style.css
rename to build/reports/tests/test/css/base-style.css
diff --git a/server/build/reports/tests/test/css/style.css b/build/reports/tests/test/css/style.css
similarity index 100%
rename from server/build/reports/tests/test/css/style.css
rename to build/reports/tests/test/css/style.css
diff --git a/server/build/reports/tests/test/classes/MatchCheckerTest.html b/build/reports/tests/test/index.html
similarity index 51%
rename from server/build/reports/tests/test/classes/MatchCheckerTest.html
rename to build/reports/tests/test/index.html
index 8965de8..7e7ba23 100644
--- a/server/build/reports/tests/test/classes/MatchCheckerTest.html
+++ b/build/reports/tests/test/index.html
@@ -1,96 +1,133 @@
-
-
-
-
-
-Test results - Class MatchCheckerTest
-
-
-
-
-
-
-
Class MatchCheckerTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-test1()
-0.036s
-passed
-
-
-
-
-
-
-
-
+
+
+
+
+
+Test results - Test Summary
+
+
+
+
+
+
+
Test Summary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Packages
+
+
+
+Package
+Tests
+Failures
+Ignored
+Duration
+Success rate
+
+
+
+
+
+default-package
+
+1
+0
+0
+0.015s
+100%
+
+
+
+
+
+
Classes
+
+
+
+Class
+Tests
+Failures
+Ignored
+Duration
+Success rate
+
+
+
+
+
+QuestionOwnerTest
+
+1
+0
+0
+0.015s
+100%
+
+
+
+
+
+
+
+
+
diff --git a/server/build/reports/tests/test/js/report.js b/build/reports/tests/test/js/report.js
similarity index 100%
rename from server/build/reports/tests/test/js/report.js
rename to build/reports/tests/test/js/report.js
diff --git a/server/build/reports/tests/test/classes/RankTest.html b/build/reports/tests/test/packages/default-package.html
similarity index 71%
rename from server/build/reports/tests/test/classes/RankTest.html
rename to build/reports/tests/test/packages/default-package.html
index 7be7b3b..d638cfa 100644
--- a/server/build/reports/tests/test/classes/RankTest.html
+++ b/build/reports/tests/test/packages/default-package.html
@@ -1,96 +1,103 @@
-
-
-
-
-
-Test results - Class RankTest
-
-
-
-
-
-
-
Class RankTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-test()
-0.003s
-passed
-
-
-
-
-
-
-
-
+
+
+
+
+
+Test results - Default package
+
+
+
+
+
+
+
Default package
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Classes
+
+
+
+Class
+Tests
+Failures
+Ignored
+Duration
+Success rate
+
+
+
+
+QuestionOwnerTest
+
+1
+0
+0
+0.015s
+100%
+
+
+
+
+
+
+
+
diff --git a/server/build/test-results/test/TEST-QuestionOwnerTest.xml b/build/test-results/test/TEST-QuestionOwnerTest.xml
similarity index 69%
rename from server/build/test-results/test/TEST-QuestionOwnerTest.xml
rename to build/test-results/test/TEST-QuestionOwnerTest.xml
index c2abb94..6b67116 100644
--- a/server/build/test-results/test/TEST-QuestionOwnerTest.xml
+++ b/build/test-results/test/TEST-QuestionOwnerTest.xml
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/build/test-results/test/binary/output.bin b/build/test-results/test/binary/output.bin
new file mode 100644
index 0000000..e69de29
diff --git a/build/test-results/test/binary/output.bin.idx b/build/test-results/test/binary/output.bin.idx
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/build/test-results/test/binary/output.bin.idx differ
diff --git a/build/test-results/test/binary/results.bin b/build/test-results/test/binary/results.bin
new file mode 100644
index 0000000..bdd47c3
Binary files /dev/null and b/build/test-results/test/binary/results.bin differ
diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin
new file mode 100644
index 0000000..b01ef1d
Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ
diff --git a/build/tmp/compileTestJava/previous-compilation-data.bin b/build/tmp/compileTestJava/previous-compilation-data.bin
new file mode 100644
index 0000000..950dd58
Binary files /dev/null and b/build/tmp/compileTestJava/previous-compilation-data.bin differ
diff --git a/client/bin/main/org/example/Main.class b/client/bin/main/org/example/Main.class
deleted file mode 100644
index aa4ed89..0000000
Binary files a/client/bin/main/org/example/Main.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/AlertController.class b/client/bin/main/org/example/controller/AlertController.class
deleted file mode 100644
index e5f53ff..0000000
Binary files a/client/bin/main/org/example/controller/AlertController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/FriendlyModeController.class b/client/bin/main/org/example/controller/FriendlyModeController.class
deleted file mode 100644
index 920f382..0000000
Binary files a/client/bin/main/org/example/controller/FriendlyModeController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/LoginController.class b/client/bin/main/org/example/controller/LoginController.class
deleted file mode 100644
index 51db943..0000000
Binary files a/client/bin/main/org/example/controller/LoginController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/MatchCreatorController.class b/client/bin/main/org/example/controller/MatchCreatorController.class
deleted file mode 100644
index 679d40e..0000000
Binary files a/client/bin/main/org/example/controller/MatchCreatorController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/ModeController.class b/client/bin/main/org/example/controller/ModeController.class
deleted file mode 100644
index c45a529..0000000
Binary files a/client/bin/main/org/example/controller/ModeController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/QuestionController$1.class b/client/bin/main/org/example/controller/QuestionController$1.class
deleted file mode 100644
index 6c8ad6b..0000000
Binary files a/client/bin/main/org/example/controller/QuestionController$1.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/QuestionController$2.class b/client/bin/main/org/example/controller/QuestionController$2.class
deleted file mode 100644
index 4559cd6..0000000
Binary files a/client/bin/main/org/example/controller/QuestionController$2.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/QuestionController.class b/client/bin/main/org/example/controller/QuestionController.class
deleted file mode 100644
index 3c71d0a..0000000
Binary files a/client/bin/main/org/example/controller/QuestionController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/ResultsController.class b/client/bin/main/org/example/controller/ResultsController.class
deleted file mode 100644
index ab7d073..0000000
Binary files a/client/bin/main/org/example/controller/ResultsController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/ResultsTournamentController.class b/client/bin/main/org/example/controller/ResultsTournamentController.class
deleted file mode 100644
index 3ea5904..0000000
Binary files a/client/bin/main/org/example/controller/ResultsTournamentController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/RoomController$1$1.class b/client/bin/main/org/example/controller/RoomController$1$1.class
deleted file mode 100644
index 3e774ea..0000000
Binary files a/client/bin/main/org/example/controller/RoomController$1$1.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/RoomController$1.class b/client/bin/main/org/example/controller/RoomController$1.class
deleted file mode 100644
index 0cf5f69..0000000
Binary files a/client/bin/main/org/example/controller/RoomController$1.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/RoomController.class b/client/bin/main/org/example/controller/RoomController.class
deleted file mode 100644
index 294c9ef..0000000
Binary files a/client/bin/main/org/example/controller/RoomController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/TournamentController$1.class b/client/bin/main/org/example/controller/TournamentController$1.class
deleted file mode 100644
index 65432a1..0000000
Binary files a/client/bin/main/org/example/controller/TournamentController$1.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/TournamentController$2.class b/client/bin/main/org/example/controller/TournamentController$2.class
deleted file mode 100644
index 13fd4ae..0000000
Binary files a/client/bin/main/org/example/controller/TournamentController$2.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/TournamentController$3.class b/client/bin/main/org/example/controller/TournamentController$3.class
deleted file mode 100644
index 90a2c4f..0000000
Binary files a/client/bin/main/org/example/controller/TournamentController$3.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/TournamentController.class b/client/bin/main/org/example/controller/TournamentController.class
deleted file mode 100644
index 76692e5..0000000
Binary files a/client/bin/main/org/example/controller/TournamentController.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/WindowController$1.class b/client/bin/main/org/example/controller/WindowController$1.class
deleted file mode 100644
index 3d3ae08..0000000
Binary files a/client/bin/main/org/example/controller/WindowController$1.class and /dev/null differ
diff --git a/client/bin/main/org/example/controller/WindowController.class b/client/bin/main/org/example/controller/WindowController.class
deleted file mode 100644
index cd39e48..0000000
Binary files a/client/bin/main/org/example/controller/WindowController.class and /dev/null differ
diff --git a/client/bin/main/org/example/interfaces/Messages.class b/client/bin/main/org/example/interfaces/Messages.class
deleted file mode 100644
index 30e89a5..0000000
Binary files a/client/bin/main/org/example/interfaces/Messages.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/Match.class b/client/bin/main/org/example/model/Match.class
deleted file mode 100644
index 8daf020..0000000
Binary files a/client/bin/main/org/example/model/Match.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/MatchChecker.class b/client/bin/main/org/example/model/MatchChecker.class
deleted file mode 100644
index 077215f..0000000
Binary files a/client/bin/main/org/example/model/MatchChecker.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/Message.class b/client/bin/main/org/example/model/Message.class
deleted file mode 100644
index ad2e14c..0000000
Binary files a/client/bin/main/org/example/model/Message.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/Player.class b/client/bin/main/org/example/model/Player.class
deleted file mode 100644
index 75beb8c..0000000
Binary files a/client/bin/main/org/example/model/Player.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/Question.class b/client/bin/main/org/example/model/Question.class
deleted file mode 100644
index 72b0ed6..0000000
Binary files a/client/bin/main/org/example/model/Question.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/Rank.class b/client/bin/main/org/example/model/Rank.class
deleted file mode 100644
index 1e9fb72..0000000
Binary files a/client/bin/main/org/example/model/Rank.class and /dev/null differ
diff --git a/client/bin/main/org/example/model/Score.class b/client/bin/main/org/example/model/Score.class
deleted file mode 100644
index f889d3e..0000000
Binary files a/client/bin/main/org/example/model/Score.class and /dev/null differ
diff --git a/client/bin/main/org/example/utils/Sender.class b/client/bin/main/org/example/utils/Sender.class
deleted file mode 100644
index 303140a..0000000
Binary files a/client/bin/main/org/example/utils/Sender.class and /dev/null differ
diff --git a/client/bin/main/org/example/utils/Utility.class b/client/bin/main/org/example/utils/Utility.class
deleted file mode 100644
index 2730095..0000000
Binary files a/client/bin/main/org/example/utils/Utility.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/AlertView.class b/client/bin/main/org/example/view/AlertView.class
deleted file mode 100644
index 55f0978..0000000
Binary files a/client/bin/main/org/example/view/AlertView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/FriendlyModeView.class b/client/bin/main/org/example/view/FriendlyModeView.class
deleted file mode 100644
index 5085809..0000000
Binary files a/client/bin/main/org/example/view/FriendlyModeView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/LoginView.class b/client/bin/main/org/example/view/LoginView.class
deleted file mode 100644
index 5be1364..0000000
Binary files a/client/bin/main/org/example/view/LoginView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/MatchCreatorView.class b/client/bin/main/org/example/view/MatchCreatorView.class
deleted file mode 100644
index 98ae0fc..0000000
Binary files a/client/bin/main/org/example/view/MatchCreatorView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/ModeView.class b/client/bin/main/org/example/view/ModeView.class
deleted file mode 100644
index 90cee92..0000000
Binary files a/client/bin/main/org/example/view/ModeView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/QuestionView.class b/client/bin/main/org/example/view/QuestionView.class
deleted file mode 100644
index d7b1b16..0000000
Binary files a/client/bin/main/org/example/view/QuestionView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/ResultsTournamentView.class b/client/bin/main/org/example/view/ResultsTournamentView.class
deleted file mode 100644
index 3d761c1..0000000
Binary files a/client/bin/main/org/example/view/ResultsTournamentView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/ResultsView.class b/client/bin/main/org/example/view/ResultsView.class
deleted file mode 100644
index 58e27db..0000000
Binary files a/client/bin/main/org/example/view/ResultsView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/RoomView.class b/client/bin/main/org/example/view/RoomView.class
deleted file mode 100644
index 1611a8e..0000000
Binary files a/client/bin/main/org/example/view/RoomView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/TournamentView.class b/client/bin/main/org/example/view/TournamentView.class
deleted file mode 100644
index bae2e30..0000000
Binary files a/client/bin/main/org/example/view/TournamentView.class and /dev/null differ
diff --git a/client/bin/main/org/example/view/WindowView.class b/client/bin/main/org/example/view/WindowView.class
deleted file mode 100644
index 3ecd711..0000000
Binary files a/client/bin/main/org/example/view/WindowView.class and /dev/null differ
diff --git a/client/build.gradle b/client/build.gradle
deleted file mode 100644
index 9bc6299..0000000
--- a/client/build.gradle
+++ /dev/null
@@ -1,27 +0,0 @@
-plugins {
- id 'java'
-}
-
-group 'org.example'
-version '1.0-SNAPSHOT'
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
- testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
-}
-
-test {
- useJUnitPlatform()
-}
-
-jar {
- manifest {
- attributes(
- 'Main-Class': 'org.example.Main'
- )
- }
-}
\ No newline at end of file
diff --git a/client/build/classes/java/main/org/example/Main.class b/client/build/classes/java/main/org/example/Main.class
deleted file mode 100644
index a6a61b9..0000000
Binary files a/client/build/classes/java/main/org/example/Main.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/AlertController.class b/client/build/classes/java/main/org/example/controller/AlertController.class
deleted file mode 100644
index 47e3b05..0000000
Binary files a/client/build/classes/java/main/org/example/controller/AlertController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/FriendlyModeController.class b/client/build/classes/java/main/org/example/controller/FriendlyModeController.class
deleted file mode 100644
index 56c03db..0000000
Binary files a/client/build/classes/java/main/org/example/controller/FriendlyModeController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/LoginController.class b/client/build/classes/java/main/org/example/controller/LoginController.class
deleted file mode 100644
index f132538..0000000
Binary files a/client/build/classes/java/main/org/example/controller/LoginController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/MatchCreatorController.class b/client/build/classes/java/main/org/example/controller/MatchCreatorController.class
deleted file mode 100644
index d547633..0000000
Binary files a/client/build/classes/java/main/org/example/controller/MatchCreatorController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/ModeController.class b/client/build/classes/java/main/org/example/controller/ModeController.class
deleted file mode 100644
index 3616835..0000000
Binary files a/client/build/classes/java/main/org/example/controller/ModeController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/QuestionController$1.class b/client/build/classes/java/main/org/example/controller/QuestionController$1.class
deleted file mode 100644
index 477aa7b..0000000
Binary files a/client/build/classes/java/main/org/example/controller/QuestionController$1.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/QuestionController$2.class b/client/build/classes/java/main/org/example/controller/QuestionController$2.class
deleted file mode 100644
index 4abb1e5..0000000
Binary files a/client/build/classes/java/main/org/example/controller/QuestionController$2.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/QuestionController.class b/client/build/classes/java/main/org/example/controller/QuestionController.class
deleted file mode 100644
index 25f7c8e..0000000
Binary files a/client/build/classes/java/main/org/example/controller/QuestionController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/ResultsController.class b/client/build/classes/java/main/org/example/controller/ResultsController.class
deleted file mode 100644
index 3e70a8e..0000000
Binary files a/client/build/classes/java/main/org/example/controller/ResultsController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/ResultsTournamentController.class b/client/build/classes/java/main/org/example/controller/ResultsTournamentController.class
deleted file mode 100644
index 5088633..0000000
Binary files a/client/build/classes/java/main/org/example/controller/ResultsTournamentController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/RoomController$1.class b/client/build/classes/java/main/org/example/controller/RoomController$1.class
deleted file mode 100644
index 70ba201..0000000
Binary files a/client/build/classes/java/main/org/example/controller/RoomController$1.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/RoomController.class b/client/build/classes/java/main/org/example/controller/RoomController.class
deleted file mode 100644
index 1c98467..0000000
Binary files a/client/build/classes/java/main/org/example/controller/RoomController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/TournamentController$1.class b/client/build/classes/java/main/org/example/controller/TournamentController$1.class
deleted file mode 100644
index 43ab61b..0000000
Binary files a/client/build/classes/java/main/org/example/controller/TournamentController$1.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/TournamentController$2.class b/client/build/classes/java/main/org/example/controller/TournamentController$2.class
deleted file mode 100644
index a696473..0000000
Binary files a/client/build/classes/java/main/org/example/controller/TournamentController$2.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/TournamentController$3.class b/client/build/classes/java/main/org/example/controller/TournamentController$3.class
deleted file mode 100644
index cc30b17..0000000
Binary files a/client/build/classes/java/main/org/example/controller/TournamentController$3.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/TournamentController.class b/client/build/classes/java/main/org/example/controller/TournamentController.class
deleted file mode 100644
index 7be7f7d..0000000
Binary files a/client/build/classes/java/main/org/example/controller/TournamentController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/WindowController$1.class b/client/build/classes/java/main/org/example/controller/WindowController$1.class
deleted file mode 100644
index 26ec572..0000000
Binary files a/client/build/classes/java/main/org/example/controller/WindowController$1.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/controller/WindowController.class b/client/build/classes/java/main/org/example/controller/WindowController.class
deleted file mode 100644
index 574f396..0000000
Binary files a/client/build/classes/java/main/org/example/controller/WindowController.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/utils/Sender.class b/client/build/classes/java/main/org/example/utils/Sender.class
deleted file mode 100644
index 9adb0aa..0000000
Binary files a/client/build/classes/java/main/org/example/utils/Sender.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/utils/Utility.class b/client/build/classes/java/main/org/example/utils/Utility.class
deleted file mode 100644
index df32313..0000000
Binary files a/client/build/classes/java/main/org/example/utils/Utility.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/AlertView.class b/client/build/classes/java/main/org/example/view/AlertView.class
deleted file mode 100644
index 5dd409c..0000000
Binary files a/client/build/classes/java/main/org/example/view/AlertView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/FriendlyModeView.class b/client/build/classes/java/main/org/example/view/FriendlyModeView.class
deleted file mode 100644
index 65562ac..0000000
Binary files a/client/build/classes/java/main/org/example/view/FriendlyModeView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/LoginView.class b/client/build/classes/java/main/org/example/view/LoginView.class
deleted file mode 100644
index 12cdf30..0000000
Binary files a/client/build/classes/java/main/org/example/view/LoginView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/MatchCreatorView.class b/client/build/classes/java/main/org/example/view/MatchCreatorView.class
deleted file mode 100644
index 41db88f..0000000
Binary files a/client/build/classes/java/main/org/example/view/MatchCreatorView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/ModeView.class b/client/build/classes/java/main/org/example/view/ModeView.class
deleted file mode 100644
index a5f7dc9..0000000
Binary files a/client/build/classes/java/main/org/example/view/ModeView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/QuestionView.class b/client/build/classes/java/main/org/example/view/QuestionView.class
deleted file mode 100644
index c3a43b9..0000000
Binary files a/client/build/classes/java/main/org/example/view/QuestionView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/ResultsTournamentView.class b/client/build/classes/java/main/org/example/view/ResultsTournamentView.class
deleted file mode 100644
index 0fef1ed..0000000
Binary files a/client/build/classes/java/main/org/example/view/ResultsTournamentView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/ResultsView.class b/client/build/classes/java/main/org/example/view/ResultsView.class
deleted file mode 100644
index 9463b8a..0000000
Binary files a/client/build/classes/java/main/org/example/view/ResultsView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/RoomView.class b/client/build/classes/java/main/org/example/view/RoomView.class
deleted file mode 100644
index a251294..0000000
Binary files a/client/build/classes/java/main/org/example/view/RoomView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/TournamentView.class b/client/build/classes/java/main/org/example/view/TournamentView.class
deleted file mode 100644
index ae77fa9..0000000
Binary files a/client/build/classes/java/main/org/example/view/TournamentView.class and /dev/null differ
diff --git a/client/build/classes/java/main/org/example/view/WindowView.class b/client/build/classes/java/main/org/example/view/WindowView.class
deleted file mode 100644
index ca6aa27..0000000
Binary files a/client/build/classes/java/main/org/example/view/WindowView.class and /dev/null differ
diff --git a/client/build/tmp/compileJava/previous-compilation-data.bin b/client/build/tmp/compileJava/previous-compilation-data.bin
deleted file mode 100644
index 0912ec5..0000000
Binary files a/client/build/tmp/compileJava/previous-compilation-data.bin and /dev/null differ
diff --git a/client/gradle/wrapper/gradle-wrapper.properties b/client/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 8638801..0000000
--- a/client/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/client/gradlew b/client/gradlew
deleted file mode 100644
index 56689ce..0000000
--- a/client/gradlew
+++ /dev/null
@@ -1,234 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright © 2015-2021 the original authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-#
-# Gradle start up script for POSIX generated by Gradle.
-#
-# Important for running:
-#
-# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
-# noncompliant, but you have some other compliant shell such as ksh or
-# bash, then to run this script, type that shell name before the whole
-# command line, like:
-#
-# ksh Gradle
-#
-# Busybox and similar reduced shells will NOT work, because this script
-# requires all of these POSIX shell features:
-# * functions;
-# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
-# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
-# * compound commands having a testable exit status, especially «case»;
-# * various built-in commands including «command», «set», and «ulimit».
-#
-# Important for patching:
-#
-# (2) This script targets any POSIX shell, so it avoids extensions provided
-# by Bash, Ksh, etc; in particular arrays are avoided.
-#
-# The "traditional" practice of packing multiple parameters into a
-# space-separated string is a well documented source of bugs and security
-# problems, so this is (mostly) avoided, by progressively accumulating
-# options in "$@", and eventually passing that to Java.
-#
-# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
-# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
-# see the in-line comments for details.
-#
-# There are tweaks for specific operating systems such as AIX, CygWin,
-# Darwin, MinGW, and NonStop.
-#
-# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
-##############################################################################
-
-# Attempt to set APP_HOME
-
-# Resolve links: $0 may be a link
-app_path=$0
-
-# Need this for daisy-chained symlinks.
-while
- APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
- [ -h "$app_path" ]
-do
- ls=$( ls -ld "$app_path" )
- link=${ls#*' -> '}
- case $link in #(
- /*) app_path=$link ;; #(
- *) app_path=$APP_HOME$link ;;
- esac
-done
-
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
-APP_BASE_NAME=${0##*/}
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD=maximum
-
-warn () {
- echo "$*"
-} >&2
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-} >&2
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "$( uname )" in #(
- CYGWIN* ) cygwin=true ;; #(
- Darwin* ) darwin=true ;; #(
- MSYS* | MINGW* ) msys=true ;; #(
- NONSTOP* ) nonstop=true ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD=$JAVA_HOME/jre/sh/java
- else
- JAVACMD=$JAVA_HOME/bin/java
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
- case $MAX_FD in #(
- max*)
- MAX_FD=$( ulimit -H -n ) ||
- warn "Could not query maximum file descriptor limit"
- esac
- case $MAX_FD in #(
- '' | soft) :;; #(
- *)
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
-fi
-
-# Collect all arguments for the java command, stacking in reverse order:
-# * args from the command line
-# * the main class name
-# * -classpath
-# * -D...appname settings
-# * --module-path (only if needed)
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if "$cygwin" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
-
- JAVACMD=$( cygpath --unix "$JAVACMD" )
-
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- for arg do
- if
- case $arg in #(
- -*) false ;; # don't mess with options #(
- /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
- [ -e "$t" ] ;; #(
- *) false ;;
- esac
- then
- arg=$( cygpath --path --ignore --mixed "$arg" )
- fi
- # Roll the args list around exactly as many times as the number of
- # args, so each arg winds up back in the position where it started, but
- # possibly modified.
- #
- # NB: a `for` loop captures its iteration list before it begins, so
- # changing the positional parameters here affects neither the number of
- # iterations, nor the values presented in `arg`.
- shift # remove old arg
- set -- "$@" "$arg" # push replacement arg
- done
-fi
-
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- org.gradle.wrapper.GradleWrapperMain \
- "$@"
-
-# Use "xargs" to parse quoted args.
-#
-# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
-#
-# In Bash we could simply go:
-#
-# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
-# set -- "${ARGS[@]}" "$@"
-#
-# but POSIX shell has neither arrays nor command substitution, so instead we
-# post-process each arg (as a line of input to sed) to backslash-escape any
-# character that might be a shell metacharacter, then use eval to reverse
-# that process (while maintaining the separation between arguments), and wrap
-# the whole thing up as a single "set" statement.
-#
-# This will of course break if any of these variables contains a newline or
-# an unmatched quote.
-#
-
-eval "set -- $(
- printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
- xargs -n1 |
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
- tr '\n' ' '
- )" '"$@"'
-
-exec "$JAVACMD" "$@"
diff --git a/client/gradlew.bat b/client/gradlew.bat
deleted file mode 100644
index ac1b06f..0000000
--- a/client/gradlew.bat
+++ /dev/null
@@ -1,89 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/client/settings.gradle b/client/settings.gradle
deleted file mode 100644
index 9a0d868..0000000
--- a/client/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-rootProject.name = 'client'
-
diff --git a/client/src/main/java/org/example/Main.java b/client/src/main/java/org/example/Main.java
deleted file mode 100644
index 0a4b7b2..0000000
--- a/client/src/main/java/org/example/Main.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.example;
-
-import org.example.utils.Sender;
-import org.example.view.WindowView;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.Socket;
-
-
-
-public class Main {
- private static final int PORT = 9002;
-
- public static void main(String[] args) {
- try{
- Socket socket = new Socket("localhost", PORT);
- WindowView w = new WindowView(new Sender(socket));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/controller/AlertController.java b/client/src/main/java/org/example/controller/AlertController.java
deleted file mode 100644
index 6d8ded5..0000000
--- a/client/src/main/java/org/example/controller/AlertController.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.example.controller;
-
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.model.Question;
-import org.example.utils.Sender;
-import org.example.view.ModeView;
-import org.example.view.QuestionView;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-public class AlertController {
- public AlertController(JFrame frame, JPanel alert, String name, String type, JButton buttonYes, JButton buttonNo, Sender sender, MatchChecker mm){
- buttonYes.addActionListener(e -> {
- Message response = sender.sendAndRead(new Message(name, "RESUME",type));
- if(response != null && response.getMessage() != null && response.getEvent().equals("GAME")){
- mm.setType("practice");
- mm.setGoingOn(true);
- mm.setQuestion((Question) response.getMessage());
- frame.remove(alert);
- System.out.println(mm.getPosition());
- frame.add(new QuestionView(frame,name, (Question) response.getMessage(),sender, mm, true, null, null, null, 0,10,mm.getPosition()).getPanel());
- frame.validate();
- }
- });
- buttonNo.addActionListener(e -> {
- sender.send(new Message(name, "REMOVE"));
- frame.remove(alert);
- frame.add(new ModeView(frame,name,sender, mm).getPanel());
- frame.validate();
- });
- }
-}
diff --git a/client/src/main/java/org/example/controller/FriendlyModeController.java b/client/src/main/java/org/example/controller/FriendlyModeController.java
deleted file mode 100644
index 82bd105..0000000
--- a/client/src/main/java/org/example/controller/FriendlyModeController.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.example.controller;
-
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.utils.Sender;
-import org.example.view.MatchCreatorView;
-import org.example.view.ModeView;
-import org.example.view.RoomView;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.ArrayList;
-import java.util.Timer;
-
-public class FriendlyModeController {
-
- public FriendlyModeController(JFrame frame, JPanel panel, ArrayList matches, JButton create, JButton back, JButton reload, JPanel content, String name, Sender sender, MatchChecker mm){
- reload.addActionListener(e -> {
- Message responsef = sender.sendAndRead(new Message<>(name, "START","friendlytournament"));
- if(responsef != null && responsef.getEvent().equals("LIST") && responsef.getMessage() instanceof ArrayList>){
- ArrayList newMatches = (ArrayList) responsef.getMessage();
- content.removeAll();
- content.setLayout(new GridLayout((newMatches.size()),1));
- for(Match m : newMatches){
- JPanel content2 = new JPanel();
- content2.setLayout(new GridLayout(6,1));
- JLabel l1 = new JLabel("Match: "+m.getName());
- content2.add(l1);
- JLabel l2 = new JLabel("Mode: "+m.getType());
- content2.add(l2);
- JLabel l3 = new JLabel("Host: "+m.getHost().name);
- content2.add(l3);
- JLabel l4 = new JLabel("Size: "+m.getPlayers().size());
- content2.add(l4);
- JButton enter = new JButton("Enter");
- content2.add(enter);
- enter.addActionListener(e2 -> {
- Message response = sender.sendAndRead(new Message<>(name, "GET_IN",m.getName()));
- if(response != null && response.getMessage() != null && response.getEvent().equals("GET_IN") && response.getMessage() instanceof Match){
- Match mGet = (Match) response.getMessage();
- mm.setType(mGet.getType());
- frame.remove(panel);
- frame.add(new RoomView(frame, name, matches, mGet, sender, mm,mGet.getTime(),mGet.getNumberQuestions()).getPanel());
- frame.validate();
- }else{
- JOptionPane.showMessageDialog(frame,"Can't join to this match!","Warning!",JOptionPane.WARNING_MESSAGE);
- }
- });
- JSeparator js = new JSeparator();
- content2.add(js);
- content.add(content2);
- content2.setVisible(true);
- }
- content.setVisible(true);
- frame.revalidate();
- frame.repaint();
- }
- });
- create.addActionListener(e -> {
- frame.remove(panel);
- frame.add(new MatchCreatorView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
- });
- back.addActionListener(e -> {
- frame.remove(panel);
- frame.add(new ModeView(frame, name, sender, mm).getPanel());
- frame.validate();
- });
- }
-}
diff --git a/client/src/main/java/org/example/controller/LoginController.java b/client/src/main/java/org/example/controller/LoginController.java
deleted file mode 100644
index f0920b3..0000000
--- a/client/src/main/java/org/example/controller/LoginController.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.example.controller;
-
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.utils.Sender;
-import org.example.view.AlertView;
-import org.example.view.ModeView;
-
-import javax.swing.*;
-
-public class LoginController {
- public LoginController(JFrame frame, JPanel login, JButton jb, JTextField nameJ, Sender sender, MatchChecker mm){
- jb.addActionListener(e -> {
- String name = nameJ.getText();
- if(name != null && name.length() > 0){
- mm.setName(name);
- Message response = sender.sendAndRead(new Message(name, "NAME"));
- if(response.getMessage() != null && response.getMessage() instanceof Match){
- frame.remove(login);
- mm.setPosition(((Match) response.getMessage()).getPlayer(name).getIndexLastQuestion());
- frame.add(new AlertView(frame,name, ((Match) response.getMessage()).getType(),sender, mm).getPanel());
- frame.validate();
- }else{
- if(response.getMessage() != null && response.getMessage() instanceof String){
- JOptionPane.showMessageDialog(frame,"A user with this name is already connected","Warning!",JOptionPane.WARNING_MESSAGE);
- }else{
- frame.remove(login);
- frame.add(new ModeView(frame,name,sender, mm).getPanel());
- frame.validate();
- }
- }
- }
- });
- }
-}
diff --git a/client/src/main/java/org/example/controller/MatchCreatorController.java b/client/src/main/java/org/example/controller/MatchCreatorController.java
deleted file mode 100644
index df26531..0000000
--- a/client/src/main/java/org/example/controller/MatchCreatorController.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.example.controller;
-
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.utils.Sender;
-import org.example.view.FriendlyModeView;
-import org.example.view.RoomView;
-
-import javax.swing.*;
-import java.util.ArrayList;
-
-public class MatchCreatorController {
- public MatchCreatorController(JFrame frame, JPanel panel, JTextField nameMatch, JButton back, JButton create, String name, JSpinner maxSize, JSpinner timeMatch, JSpinner questionsSize, JComboBox modeList, ArrayList matches, Sender sender, MatchChecker mm){
- create.addActionListener(e -> {
- String nameM = nameMatch.getText();
- if(nameM != null && nameM.length() > 0){
- Message response = sender.sendAndRead(new Message(name, "NAME_CHECKER",nameM));
- if(response.getMessage() != null && response.getMessage().equals("Y")){
- JOptionPane.showMessageDialog(frame,"Game match already used!","Warning!",JOptionPane.WARNING_MESSAGE);
- }else{
- Message response2 = sender.sendAndRead(new Message(name, "CREATE",nameM+":"+maxSize.getValue()+":"+timeMatch.getValue()+":"+questionsSize.getValue()+":"+modeList.getSelectedItem()));
- if(response2.getMessage() != null){
- Match match = (Match) response2.getMessage();
- mm.setType((String) modeList.getSelectedItem());
- mm.setGoingOn(true);
- frame.remove(panel);
- frame.add(new RoomView(frame, name, matches,match, sender, mm, (Integer) timeMatch.getValue(), (Integer) questionsSize.getValue()).getPanel());
- frame.validate();
- }
- }
- }
- });
- back.addActionListener(e -> {
- frame.remove(panel);
- frame.add(new FriendlyModeView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
- });
- }
-}
diff --git a/client/src/main/java/org/example/controller/ModeController.java b/client/src/main/java/org/example/controller/ModeController.java
deleted file mode 100644
index e1005ec..0000000
--- a/client/src/main/java/org/example/controller/ModeController.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.example.controller;
-
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.model.Question;
-import org.example.utils.Sender;
-import org.example.view.FriendlyModeView;
-import org.example.view.QuestionView;
-
-import javax.swing.*;
-import java.util.ArrayList;
-import java.util.Timer;
-
-public class ModeController {
- public ModeController(JFrame frame, JPanel mode, JButton jb, JRadioButton[] list, String name, Sender sender, MatchChecker mm){
- this.controller(frame,mode,jb,list,name,sender,mm);
- }
-
- private void controller(JFrame frame, JPanel mode, JButton jb, JRadioButton[] list, String name, Sender sender, MatchChecker mm){
- jb.addActionListener(e -> {
- String value = null;
- for(JRadioButton el : list){
- if(el.isSelected())
- value = el.getText();
- }
- switch (value.toLowerCase()){
- case "practice mode":
- String[] options = {"Yes","No"};
- int result = JOptionPane.showOptionDialog(frame , "A game will start soon.\nDo you want to start it now?", "Question",
- JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
- null, options, options[0]);
- if(result == 0){
- mm.setType("practice");
- mm.setGoingOn(true);
- mm.setPosition(1);
- Message response = sender.sendAndRead(new Message<>(name, "START","practice"));
- Question q = (Question) response.getMessage();
- frame.remove(mode);
- frame.add(new QuestionView(frame,name,q,sender, mm, true, null, null, null,0, 10, mm.getPosition()).getPanel());
- frame.validate();
- }
- break;
- case "friendly/tournament mode":
- Message responsef = sender.sendAndRead(new Message<>(name, "START","friendlytournament"));
- if(responsef != null && responsef.getEvent().equals("LIST") && responsef.getMessage() != null && responsef.getMessage() instanceof ArrayList>){
- ArrayList matches = (ArrayList) responsef.getMessage();
- frame.remove(mode);
- frame.add(new FriendlyModeView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
- }
- break;
- case "tournament mode":
- break;
- }
- });
- }
-}
diff --git a/client/src/main/java/org/example/controller/QuestionController.java b/client/src/main/java/org/example/controller/QuestionController.java
deleted file mode 100644
index 6d360e7..0000000
--- a/client/src/main/java/org/example/controller/QuestionController.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.example.controller;
-
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.model.Question;
-import org.example.model.Score;
-import org.example.utils.Sender;
-import org.example.view.QuestionView;
-import org.example.view.ResultsView;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class QuestionController {
- public QuestionController(JFrame frame, JPanel question, JButton jb, JTextField answer, Question q, String name, Sender sender, MatchChecker mm, boolean lecit, Timer tQuiz, AtomicInteger seconds, JLabel label, int time, int questions, int iterator){
- if(!lecit){
- TimerTask task = new TimerTask() {
- public int i = seconds.get();
- @Override
- public void run() {
- i++;
- int minutes = i / 60;
- int secondss = i % 60;
- seconds.getAndAdd(1);
- if(secondss < 10)
- label.setText("Time passed in minutes: "+minutes+":"+"0"+secondss+"/"+time+":00");
- else label.setText("Time passed in minutes: "+minutes+":"+secondss+"/"+time+":00");
- if(i > time * 60){
- tQuiz.cancel(); //Delete timer if test is taking more than n/60 minutes
- Message response = sender.sendAndRead(new Message<>(name, "END_TIMER"));
- if(response != null && response.getEvent().equals("END_TIMER")){
- printScoresFriendly(frame, question, name, sender, mm);
- }
- }
- }
- };
- tQuiz.schedule(task, 500, 1000);
- }
- jb.addActionListener(e -> {
- if(answer.getText() != null && answer.getText().length() > 0){ //TODO: DOVREI TOGLIERE TUTTI GLI SPAZI VUOTI E CONFRONTARE LA STRINGA SOLO A QUEL PUNTO
- String text = answer.getText();
- q.checkAnswer(text);
- Message response = sender.sendAndRead(new Message<>(name, "GAME",q));
- switch (response.getEvent().toLowerCase()){
- case "game":
- frame.remove(question);
- Question newQuestion = (Question) response.getMessage();
- frame.add(new QuestionView(frame,name,newQuestion,sender, mm, true, tQuiz, seconds, label, time, questions,iterator+1).getPanel());
- frame.validate();
- break;
- case "end":
- switch (mm.getType()){
- case "practice":
- mm.setGoingOn(false);
- mm.setType(null);
- mm.setMatch(null);
- frame.remove(question);
- Score score = (Score) response.getMessage();
- frame.add(new ResultsView(frame,name,score,sender, mm,false).getPanel());
- frame.validate();
- break;
- case "friendly":
- if(tQuiz != null)
- tQuiz.cancel();
- printScoresFriendly(frame, question, name, sender, mm);
- break;
- }
- }
- }
- });
-
-
- }
-
- private void printScoresFriendly(JFrame frame, JPanel question, String name, Sender sender, MatchChecker mm){
- frame.remove(question);
- JPanel waiting = new ResultsView(frame,name, (Score) null,sender, mm,true).getPanel();
- frame.add(waiting);
- frame.validate();
- Timer t = new Timer();
- TimerTask tt = new TimerTask() {
- @Override
- public void run() {
- Message check = sender.sendAndRead(new Message<>(name, "IS_END", mm.getMatch()));
- if(check != null && check.getMessage() != null){
- if(check.getMessage() instanceof ArrayList>){
- t.cancel();
- mm.setGoingOn(false);
- mm.setType(null);
- mm.setMatch(null);
- frame.remove(waiting);
- frame.add(new ResultsView(frame,name,(ArrayList) check.getMessage(),sender, mm,false).getPanel());
- frame.validate();
- }
- }
- }
- };
- t.scheduleAtFixedRate(tt,1000,1000);
- }
-}
diff --git a/client/src/main/java/org/example/controller/ResultsController.java b/client/src/main/java/org/example/controller/ResultsController.java
deleted file mode 100644
index d63c2ae..0000000
--- a/client/src/main/java/org/example/controller/ResultsController.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.example.controller;
-
-import org.example.model.MatchChecker;
-import org.example.utils.Sender;
-import org.example.view.ModeView;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-public class ResultsController {
- public ResultsController(JFrame frame, JPanel results, JButton jb, String name, Sender sender, MatchChecker mm){
- jb.addActionListener(e -> {
- frame.remove(results);
- frame.add(new ModeView(frame,name,sender, mm).getPanel());
- frame.validate();
- });
- /*jb.addActionListener(e -> {
-
- });*/
- }
-}
diff --git a/client/src/main/java/org/example/controller/ResultsTournamentController.java b/client/src/main/java/org/example/controller/ResultsTournamentController.java
deleted file mode 100644
index b77f444..0000000
--- a/client/src/main/java/org/example/controller/ResultsTournamentController.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.example.controller;
-
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.model.Rank;
-import org.example.utils.Sender;
-import org.example.view.ModeView;
-
-import javax.swing.*;
-import java.util.ArrayList;
-
-public class ResultsTournamentController{
- public ResultsTournamentController(JFrame frame, JPanel results, JButton jb, String name, Sender sender, MatchChecker mm, ArrayList ranks){
- jb.addActionListener(e -> {
- sender.send(new Message(name, "COUNT_TOURNAMENT"));
- frame.remove(results);
- frame.add(new ModeView(frame,name,sender, mm).getPanel());
- frame.validate();
- });
- float max = ranks.get(0).points;
- String nameP = ranks.get(0).name;
- for(Rank r : ranks){
- if(r.points > max){
- nameP = r.name;
- max = r.points;
- }
- }
- if(nameP.equals(name) && max != 0){
- JOptionPane.showMessageDialog(frame,"You have won the tournament!","Winner!",JOptionPane.INFORMATION_MESSAGE);
- }else{
- JOptionPane.showMessageDialog(frame,"You have lost the tournament","You will win next time :(",JOptionPane.INFORMATION_MESSAGE);
- }
- }
-}
-
diff --git a/client/src/main/java/org/example/controller/RoomController.java b/client/src/main/java/org/example/controller/RoomController.java
deleted file mode 100644
index d394a61..0000000
--- a/client/src/main/java/org/example/controller/RoomController.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.example.controller;
-
-import org.example.model.*;
-import org.example.utils.Sender;
-import org.example.view.FriendlyModeView;
-import org.example.view.QuestionView;
-import org.example.view.TournamentView;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class RoomController {
- private static Match match;
- public RoomController(JFrame frame, JPanel panel, JButton back, JButton start, JButton readyB, JPanel content, String name, ArrayList matches, Match match, Sender sender, MatchChecker mm, int time, int questions, JLabel crome){
- RoomController.match = match;
- if(!RoomController.match.getHost().name.equals(name)){
- back.setText("Exit");
- }
- Timer t = new Timer(); //T is the timer that checks if players are ready or not
- TimerTask tt = new TimerTask() {
- AtomicInteger timerStart = new AtomicInteger(5);
-
- @Override
- public void run() {
- Message responsef = sender.sendAndRead(new Message<>(name, "UPDATE_PLAYERS",match.getName()));
- if(responsef != null && responsef.getMessage() != null && responsef.getEvent().equals("UPDATE_PLAYERS") && responsef.getMessage() instanceof Match){
- Match mmm = (Match) responsef.getMessage();
- RoomController.match = mmm;
- if(mmm.getPlayers().size() > 0){
- if(!mmm.isAvailable()){ //Match started
- t.cancel();
- Message responseD = sender.sendAndRead(new Message<>(name, "DROP_QUESTION",RoomController.match.getName()));
- if(responseD != null && responseD.getMessage() != null && responseD.getMessage() instanceof Question){
- Timer tQuiz = new Timer();
- AtomicInteger seconds = new AtomicInteger(0);
- mm.setGoingOn(true);
- mm.setMatch(RoomController.match.getName());
- mm.setPosition(1);
- if(mm.getType().equals("friendly")){
- frame.remove(panel);
- frame.add(new QuestionView(frame, name, (Question) responseD.getMessage(), sender, mm, false, tQuiz, seconds, new JLabel(), time, questions, 1).getPanel());
- frame.validate();
- } else if (mm.getType().equals("tournament")) {
- frame.remove(panel);
- frame.add(new TournamentView(frame, name, (Question) responseD.getMessage(), sender, mm, new JLabel(), questions, 1, false).getPanel());
- frame.validate();
- }
-
- }
- }else{ //Match is not started but update request is made
- content.removeAll();
- content.setLayout(new GridLayout((mmm.getPlayers().size()),1));
-
- int readyness = printerCicle(mmm,1,content);
- if(readyness == mmm.getPlayers().size()){ //All players are ready
- crome.setVisible(true);
- int val = timerStart.decrementAndGet();
- crome.setText("Seconds until start: "+val);
- if(mmm.getHost().name.equals(name)){
- start.setVisible(true);
- if(val == 0){
- sender.send(new Message(name, "FRIENDLY_START",RoomController.match.getName()));
- }
- }
- }else{ //NOt all players are ready
- timerStart.set(5);
- if(mmm.getHost().name.equals(name)){
- start.setVisible(false);
- crome.setVisible(false);
- }
- }
- content.setVisible(true);
- frame.revalidate();
- frame.repaint();
- }
- }else{ //There are no players in the room because I left
- t.cancel();
- frame.remove(panel);
- frame.add(new FriendlyModeView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
- }
- }else{ //Not valid response
- t.cancel();
- frame.remove(panel);
- frame.add(new FriendlyModeView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
-
- }
- }
- };
- t.scheduleAtFixedRate(tt,100,1000);
-
-
-
-
-
-
- back.addActionListener(e -> {
- if(RoomController.match.getHost().name.equals(name)){
- Message response = sender.sendAndRead(new Message(name, "MATCH_REMOVER",RoomController.match.getName()));
- if(response != null && response.getMessage() != null && response.getEvent().equals("MATCH_REMOVER") && response.getMessage().equals("ok")){
- t.cancel();
- frame.remove(panel);
- frame.add(new FriendlyModeView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
- }
- }else{
- t.cancel();
- sender.send(new Message(name, "REMOVE_PLAYER",RoomController.match.getName()));
- frame.remove(panel);
- frame.add(new FriendlyModeView(frame, name, matches, sender, mm).getPanel());
- frame.validate();
- }
- });
-
- readyB.addActionListener(e -> {
- sender.send(new Message(name, "UPDATE_READY", true));
- readyB.setVisible(false);
- if(RoomController.match.getHost().name.equals(name))
- start.setVisible(true);
- });
-
-
- start.addActionListener(e -> {
- sender.send(new Message(name, "FRIENDLY_START",RoomController.match.getName()));
- });
- }
-
- private int printerCicle(Match match, int i, JPanel content){
- int readiness = 0;
- for(Player p : match.getPlayers()){
- JPanel contentPl = new JPanel();
- JLabel el1 = new JLabel(i+". Name: ");
- el1.setFont(new Font(el1.getFont().getFontName(),Font.BOLD,el1.getFont().getSize()));
- contentPl.add(el1);
- JLabel el2 = new JLabel(p.name+ " - Ready: "+p.isReady());
- contentPl.add(el2);
- JSeparator sp = new JSeparator();
- contentPl.add(sp);
- i++;
- if(p.isReady())
- readiness++;
- contentPl.setVisible(true);
- content.add(contentPl);
- }
- return readiness;
- }
-}
diff --git a/client/src/main/java/org/example/controller/TournamentController.java b/client/src/main/java/org/example/controller/TournamentController.java
deleted file mode 100644
index c04644a..0000000
--- a/client/src/main/java/org/example/controller/TournamentController.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.example.controller;
-
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.model.Question;
-import org.example.model.Rank;
-import org.example.utils.Sender;
-import org.example.view.ResultsTournamentView;
-import org.example.view.TournamentView;
-
-import javax.swing.*;
-import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicInteger;
-
-//TODO: TIMER MAGARI ANCHE VISIVO SU QUANTO TEMPO IL MATCH DURA PER IL SINGOLO GIOCATORE
-//TODO: POTREI FARE TIMER CHE PARTE DA ZERO PER OGNI QUESTION E MISURA QUANTO TEMPO CI METTE A RISPONDERE AD OGNI DOMANDA
-//TODO: AL TERMINE VIENE FATTA LA SOMMA ED A PARITA' DI PUNTI VIENE DECRETATO IL MIGLIORE
-
-public class TournamentController {
- private final int DEFAULT_QUESTION_TIME = 30;
- public TournamentController(JFrame frame, JPanel question, JButton jb, ArrayList list, Question q, String name, Sender sender, MatchChecker mm, JLabel timeLabel, int questions, int iterator, boolean casistic){
- if(!casistic){
- Timer t = new Timer();
- AtomicInteger seconds = new AtomicInteger(DEFAULT_QUESTION_TIME);
- TimerTask tt = new TimerTask() {
- @Override
- public void run() {
- int got = seconds.decrementAndGet();
- if(got < 10) timeLabel.setText("Time remained for this question: 00:0"+got);
- else timeLabel.setText("Time remained for this question: 00:"+got);
- if(got == 0){ //30 seconds is the max time a question can take by default
- t.cancel();
- frame.remove(question);
- frame.add(new TournamentView(frame, name, q, sender, mm, null,questions, iterator,true).getPanel());
- frame.validate();
- }
- }
- };
- t.scheduleAtFixedRate(tt,10,1000);
-
- jb.addActionListener(e -> {
- t.cancel();
- String value = null;
- for(JRadioButton el : list){
- if(el.isSelected()){
- value = el.getText();
- break;
- }
- }
- if(value != null){
- q.checkAnswer(value);
- q.setSeconds(DEFAULT_QUESTION_TIME-seconds.get());
- Timer t2 = new Timer();
- TimerTask tt2 = new TimerTask() {
- @Override
- public void run() {
- Message response1 = sender.sendAndRead(new Message<>(name, "UPDATE_NEXT",q));
- if(response1.getMessage().equals("no")){ //I've answered clicking the button but other players haven't answered yet
- t2.cancel();
- frame.remove(question);
- frame.add(new TournamentView(frame, name, q, sender, mm, null,questions, iterator,true).getPanel());
- frame.validate();
- }else{ //I've answered clicking the button and all players have already answered
- t2.cancel();
- Message response2 = sender.sendAndRead(new Message<>(name, "GAME",q));
- switch (response2.getEvent().toLowerCase()){
- case "game":
- Question newQuestion = (Question) response2.getMessage();
- frame.remove(question);
- frame.add(new TournamentView(frame, name, newQuestion, sender, mm, timeLabel,questions, iterator+1,false).getPanel());
- frame.validate();
- break;
- case "end":
- handleEndTournament(frame, question,sender, name, mm);
- break;
- }
- }
- }
- };
- t2.scheduleAtFixedRate(tt2,10,1000);
- }
- });
- }else{ //If I've entered here I was still waiting for other players to complete the quest
- Timer t = new Timer();
- TimerTask tt = new TimerTask() {
- @Override
- public void run() {
- Message response1 = sender.sendAndRead(new Message<>(name, "UPDATE_NEXT",q));
- if(response1.getMessage().equals("ok")){
- Message response2 = sender.sendAndRead(new Message<>(name, "GAME",q));
- t.cancel();
- switch (response2.getEvent().toLowerCase()){
- case "game":
- Question newQuestion = (Question) response2.getMessage();
- frame.remove(question);
- frame.add(new TournamentView(frame, name, newQuestion, sender, mm, new JLabel(),questions, iterator+1,false).getPanel());
- frame.validate();
- break;
- case "end":
- handleEndTournament(frame, question,sender, name, mm);
- break;
- }
- }
- }
- };
- t.scheduleAtFixedRate(tt,10,1000);
- }
- }
-
- private void handleEndTournament(JFrame frame, JPanel question, Sender sender, String name, MatchChecker mm){
- Message response = sender.sendAndRead(new Message<>(name, "RETURN_RANK"));
- frame.remove(question);
- frame.add(new ResultsTournamentView(frame, name, (ArrayList) response.getMessage(), sender, mm).getPanel());
- frame.validate();
- }
-}
diff --git a/client/src/main/java/org/example/controller/WindowController.java b/client/src/main/java/org/example/controller/WindowController.java
deleted file mode 100644
index ddfb5fd..0000000
--- a/client/src/main/java/org/example/controller/WindowController.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.example.controller;
-
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-public class WindowController {
-
- public WindowController(JFrame frame, MatchChecker mm, Sender sender){
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- if(mm.isGoingOn()){
- sender.send(new Message(mm.getName(),"END", mm));
- }else{
- sender.send(new Message(mm.getName(),"END"));
- }
- sender.close();
- }
- });
- }
-}
diff --git a/client/src/main/java/org/example/interfaces/Messages.java b/client/src/main/java/org/example/interfaces/Messages.java
deleted file mode 100644
index eca0ec3..0000000
--- a/client/src/main/java/org/example/interfaces/Messages.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.example.interfaces;
-
-public interface Messages {
- public Z getOwner();
- public K getEvent();
- public Y getMessage();
- public void setEvent(K event);
- public void setMessage(Y message);
-
-}
diff --git a/client/src/main/java/org/example/model/Match.java b/client/src/main/java/org/example/model/Match.java
deleted file mode 100644
index 29a6126..0000000
--- a/client/src/main/java/org/example/model/Match.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.example.model;
-
-import org.example.utils.Utility;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Objects;
-
-public class Match implements Serializable {
- private static final long serialVersionUID = 2L;
- private ArrayList players;
- private boolean available; //Tells if the match can be join by other users
- private String type; //Practice/Tournament/Friendly
- public int id;
- private String name;
-
- private Player host;
- private int size;
- private int time; //Time in minutes of max duration of the match
-
- private int numberQuestions;
- public Match(){
- this.players = new ArrayList<>();
- this.available = false ;
- this.type = null;
- this.id = Utility.randomIDGenerator(Integer.MAX_VALUE-1);
- this.name = ""+this.id;
- this.host = null;
- this.size = 0;
- this.time = 0;
- this.numberQuestions = 0;
- }
- public Match(String type, Player host){
- this.players = new ArrayList<>();
- this.available = false ;
- this.type = type;
- this.id = Utility.randomIDGenerator(Integer.MAX_VALUE-1);
- this.name = ""+this.id;
- this.host = host;
- this.size = 1; //DEFAULT SIZE
- this.time = 0;
- this.numberQuestions = 10;
- }
- public Match(String type, String name, Player host, int size){
- this.players = new ArrayList<>();
- this.available = false ;
- this.type = type;
- this.id = Utility.randomIDGenerator(Integer.MAX_VALUE-1);
- this.name = name;
- this.host = host;
- this.size = size;
- this.time = 0;
- this.numberQuestions = 10;
- }
- public Match(String type, String name, Player host, int size, int time, int numberQuestions){
- this.players = new ArrayList<>();
- this.available = false ;
- this.type = type;
- this.id = Utility.randomIDGenerator(Integer.MAX_VALUE-1);
- this.name = name;
- this.host = host;
- this.size = size;
- this.time = time;
- this.numberQuestions = numberQuestions;
- }
-
- public int getNumberQuestions() {
- return numberQuestions;
- }
-
- public synchronized int getTime() {
- return time;
- }
-
- public synchronized void setTime(int time) {
- this.time = time;
- }
-
- public synchronized int getSize() {
- return size;
- }
-
- public synchronized ArrayList getPlayers() {
- return players;
- }
-
- public synchronized void setPlayers(ArrayList players) {
- this.players = players;
- }
-
- public synchronized boolean isAvailable() {
- return available;
- }
-
- public synchronized void setAvailable(boolean available) {
- this.available = available;
- }
-
- public synchronized String getType() {
- return type;
- }
-
- public synchronized void setType(String type) {
- this.type = type;
- }
-
- public synchronized String getName() {
- return name;
- }
-
- public synchronized void setName(String name) {
- this.name = name;
- }
-
- public synchronized Player getHost() {
- return host;
- }
-
- public synchronized void setHost(Player host) {
- this.host = host;
- }
-
- public synchronized void addPlayer(Player p){
- if(players.size() < this.size)
- players.add(p);
- }
-
- public synchronized void removePlayer(Player p){
- if(players.size() > 0)
- players.remove(p);
- }
- public synchronized String returnListOfPlayers(){
- String list = "";
- for(Player el : players){
- list = list+"\n"+el.toString();
- }
- return list;
- }
-
- public synchronized boolean containsUser(Player p){
- for(Player pp : players){
- if(pp.equals(p))
- return true;
- }
- return false;
- }
-
- public synchronized Player getPlayer(Player p){
- for(Player pp : players){
- if(pp.equals(p))
- return pp;
- }
- return null;
- }
-
- public synchronized Player getPlayer(String p){
- for(Player pp : players){
- if(pp.name.equals(p))
- return pp;
- }
- return null;
- }
-
- @Override
- public String toString() {
- return "Match{" +
- "players=" + players +
- ", available=" + available +
- ", type='" + type + '\'' +
- ", id=" + id +
- ", name='" + name + '\'' +
- ", host=" + host +
- ", size=" + size +
- ", time=" + time +
- ", numberQuestions=" + numberQuestions +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Match match = (Match) o;
- return (id == match.id) || (name.equals(match.name));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id);
- }
-
- public Player getFirstPLayer(){
- return this.players.get(0);
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/model/MatchChecker.java b/client/src/main/java/org/example/model/MatchChecker.java
deleted file mode 100644
index a0852c8..0000000
--- a/client/src/main/java/org/example/model/MatchChecker.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.example.model;
-
-import java.io.Serializable;
-
-public class MatchChecker implements Serializable {
- private String name; //Name of who was doing the match
-
- private boolean isGoingOn;
- private String type;
- private Question question;
- private String match; //Name of the match
-
- private int position;
- public MatchChecker(){
- this.isGoingOn = false;
- this.question = null;
- this.type = null;
- this.match = null;
- this.name = null;
- this.position = 1;
- }
-
- public int getPosition() {
- return position;
- }
-
- public void setPosition(int position) {
- this.position = position;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public boolean isGoingOn() {
- return isGoingOn;
- }
-
- public void setGoingOn(boolean goingOn) {
- isGoingOn = goingOn;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getMatch() {
- return match;
- }
-
- public void setMatch(String match) {
- this.match = match;
- }
-
- public Question getQuestion() {
- return question;
- }
-
- public void setQuestion(Question question) {
- this.question = question;
- }
-
- @Override
- public String toString() {
- return "MatchChecker{" +
- "name='" + name + '\'' +
- ", isGoingOn=" + isGoingOn +
- ", type='" + type + '\'' +
- ", question=" + question +
- ", match='" + match + '\'' +
- ", position=" + position +
- '}';
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/model/Message.java b/client/src/main/java/org/example/model/Message.java
deleted file mode 100644
index 6f26122..0000000
--- a/client/src/main/java/org/example/model/Message.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.example.model;
-
-import org.example.interfaces.Messages;
-
-import java.io.Serializable;
-
-public class Message implements Messages, Serializable {
- private static final long serialVersionUID = 1L;
- private String owner;
- private String event;
- private K message;
- public Message(String owner){
- this.owner = owner;
- this.event = "QUIT";
- this.message = null;
- }
- public Message(String owner, String event){
- this.owner = owner;
- this.event = event;
- this.message = null;
- }
- public Message(String owner, String event, K message){
- this.owner = owner;
- this.event = event;
- this.message = message;
- }
- public String getOwner(){
- return this.owner;
- }
-
- public String getEvent(){
- return this.event;
- }
-
- @Override
- public K getMessage() {
- return this.message;
- }
-
- public void setEvent(String event){
- this.event = event;
- }
-
- @Override
- public void setMessage(K message) {
- this.message = message;
- }
-
- @Override
- public String toString() {
- return "Message{" +
- "owner='" + owner + '\'' +
- ", event='" + event + '\'' +
- ", message='" + message + '\'' +
- '}';
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/model/Player.java b/client/src/main/java/org/example/model/Player.java
deleted file mode 100644
index 5e3aee9..0000000
--- a/client/src/main/java/org/example/model/Player.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.example.model;
-
-import org.example.utils.Utility;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Objects;
-
-public class Player implements Serializable {
- private static final long serialVersionUID = 3L;
-
- public String name;
- public ArrayList questions;
- public boolean hasFinished;
- public Score score;
- private int id;
- private boolean ready;
- private int indexLastQuestion;
- public Player(){
- this.name = null;
- this.questions = new ArrayList<>();
- this.score = null;
- this.id = Utility.randomIDGenerator(Integer.MAX_VALUE-1);
- this.hasFinished = false;
- this.ready = false;
- this.indexLastQuestion = -1;
- }
- public Player(String name){
- this.name = name;
- this.questions = new ArrayList<>();
- this.score = new Score(this.name);
- this.id = Utility.randomIDGenerator(Integer.MAX_VALUE-1);
- this.hasFinished = false;
- this.ready = false;
- this.indexLastQuestion = -1;
- }
-
- public int getIndexLastQuestion() {
- return indexLastQuestion;
- }
-
- public void setIndexLastQuestion(int indexLastQuestion) {
- this.indexLastQuestion = indexLastQuestion;
- }
-
- public boolean isReady() {
- return ready;
- }
-
- public void setReady(boolean ready) {
- this.ready = ready;
- }
-
- public boolean isHasFinished() {
- return hasFinished;
- }
-
- public void setHasFinished(boolean hasFinished) {
- this.hasFinished = hasFinished;
- }
-
- public void setName(String name){
- this.name = name;
- this.score = new Score(this.name);
- }
-
- public void clearQuestions(){
- questions.clear();
- }
- public void addQuestion(Question q){
- questions.add(q);
- }
-
- public Question pickQuestion(){
- int length = questions.size()-1;
- int random_int = (int)Math.floor(Math.random()*(length+1));
- Question q = questions.get(random_int);
- questions.remove(random_int);
- return q;
- }
- public Question popQuestion(){
- Question q = questions.get(0);
- questions.remove(0);
- return q;
- }
- public boolean hasQuestion(){
- return (this.questions.size() > 0);
- }
-
- public int getId(){
- return this.id;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Player player = (Player) o;
- return name.equals(player.name);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name);
- }
-
- @Override
- public String toString() {
- return "Player{" +
- "name='" + name + '\'' +
- ", questions=" + questions +
- ", hasFinished=" + hasFinished +
- ", score=" + score +
- ", id=" + id +
- ", ready=" + ready +
- ", indexLastQuestion=" + indexLastQuestion +
- '}';
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/model/Question.java b/client/src/main/java/org/example/model/Question.java
deleted file mode 100644
index e07ba73..0000000
--- a/client/src/main/java/org/example/model/Question.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.example.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class Question implements Serializable {
- public String quest, answer, given,wrong1,wrong2,wrong3,wrong4;
- public boolean correct;
- public int seconds; //Seconds passed in order to give the answer
- public Question(String quest, String answer){
- this.quest = quest;
- this.answer = answer;
- this.correct = false;
- this.given = null;
- this.wrong1 = null;
- this.wrong2 = null;
- this.wrong3 = null;
- this.wrong4 = null;
- }
-
- public Question(String quest, String answer, String wrong1, String wrong2, String wrong3, String wrong4){
- this.quest = quest;
- this.answer = answer;
- this.correct = false;
- this.given = null;
- this.wrong1 = wrong1;
- this.wrong2 = wrong2;
- this.wrong3 = wrong3;
- this.wrong4 = wrong4;
- }
-
- public int getSeconds() {
- return seconds;
- }
-
- public void setSeconds(int seconds) {
- this.seconds = seconds;
- }
-
- public final boolean checkAnswer(String answer){
- String newString = answer.toLowerCase().replaceAll("\\s+","");
- if(newString.equals(this.answer.toLowerCase())){
- this.correct = true;
- }else{
- this.correct = false;
- }
- this.given = answer;
- return this.correct;
- }
-
- @Override
- public String toString() {
- return "Question{" +
- "quest='" + quest + '\'' +
- ", answer='" + answer + '\'' +
- ", given='" + given + '\'' +
- ", wrong1='" + wrong1 + '\'' +
- ", wrong2='" + wrong2 + '\'' +
- ", wrong3='" + wrong3 + '\'' +
- ", wrong4='" + wrong4 + '\'' +
- ", correct=" + correct +
- '}';
- }
-
- public ArrayList getAllAnswers(){
- ArrayList answers = new ArrayList<>();
- answers.add(answer);
- if(wrong1 != null && wrong2 != null && wrong3 != null && wrong4 != null){
- answers.add(wrong1);
- answers.add(wrong2);
- answers.add(wrong3);
- answers.add(wrong4);
- }
- Collections.shuffle(answers);
- return answers;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Question question = (Question) o;
- return this.quest.equals((question.quest));
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(quest, answer, given, wrong1, wrong2, wrong3, wrong4, correct, seconds);
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/model/Rank.java b/client/src/main/java/org/example/model/Rank.java
deleted file mode 100644
index d6aacc7..0000000
--- a/client/src/main/java/org/example/model/Rank.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.example.model;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-public class Rank implements Comparable, Serializable {
- public float points;
- public String name;
-
- public Rank(String name){
- this.name = name;
- this.points = 0;
- }
- public Rank(String name, float points){
- this.name = name;
- this.points = points;
- }
-
- public void addOne(){
- this.points = this.points + 1;
- }
-
- public void addHalf(){
- this.points = this.points + 0.5f;
- }
-
- public void set(float points){
- this.points = points;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Rank rank = (Rank) o;
- return name.equals(rank.name);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name);
- }
-
- @Override
- public int compareTo(Rank o) {
- if(this.points > o.points)
- return 1;
- if(this.points == o.points)
- return 0;
- return -1;
- }
-
- @Override
- public String toString() {
- return "Rank{" +
- "points=" + points +
- ", name='" + name + '\'' +
- '}';
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/model/Score.java b/client/src/main/java/org/example/model/Score.java
deleted file mode 100644
index bab0152..0000000
--- a/client/src/main/java/org/example/model/Score.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.example.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-public class Score implements Serializable {
- public ArrayList questions;
- public String name;
- public boolean completed;
- public Score(String name){
- this.name = name;
- questions = new ArrayList<>();
- this.completed = false;
- }
-
- public boolean isCompleted() {
- return completed;
- }
-
- public void setCompleted(boolean completed) {
- this.completed = completed;
- }
-
- public int getNumberOfCorrectAnswers(){
- int i = 0;
- for(Question q : questions){
- if(q.correct)
- i++;
- }
- return i;
- }
- public int getNumberOfUnCorrectAnswers(){
- int i = 0;
- for(Question q : questions){
- if(!q.correct)
- i++;
- }
- return i;
- }
- public void merge(Score s){
- this.questions.addAll(s.questions);
- }
- public void addQuestion(Question q){
- if(q != null)
- this.questions.add(q);
- }
-
- public boolean containQuestion(Question q){
- for(Question qq : this.questions){
- if(qq.equals(q))
- return true;
- }
- return false;
- }
-
- public Question getQuestion(int i){
- if(i >= 0 && i < questions.size())
- return this.questions.get(i);
- return null;
- }
- @Override
- public String toString() {
- return "Score{" +
- "questions=" + questions +
- ", name='" + name + '\'' +
- '}';
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/utils/Sender.java b/client/src/main/java/org/example/utils/Sender.java
deleted file mode 100644
index 78c4362..0000000
--- a/client/src/main/java/org/example/utils/Sender.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.example.utils;
-import org.example.model.Message;
-
-import java.io.*;
-import java.net.Socket;
-
-public class Sender{
- public ObjectOutputStream out;
- public ObjectInputStream in;
- public Socket socket;
-
- public Sender(Socket socket){
- try {
- this.socket = socket;
- this.out = new ObjectOutputStream(socket.getOutputStream());
- this.in = new ObjectInputStream(socket.getInputStream());
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public Message sendAndRead(Message message){
- Object result;
- try{
- System.out.println("Outcoming message: "+message);
- this.out.writeObject(message);
- this.out.flush();
- this.out.reset();
- result = this.in.readObject();
- Message result2;
- if(result != null){
- result2 = (Message) result;
- System.out.println("Incoming message: "+result2);
- return result2;
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- return null;
- }
-
- public void send(Message message){
- try{
- System.out.println("Outcoming message: "+message);
- this.out.writeObject(message);
- this.out.flush();
- this.out.reset();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- public void close(){
- System.out.println("Closing the connection with the server!");
- try {
- this.socket.close();
- in.close();
- out.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- }
-}
diff --git a/client/src/main/java/org/example/utils/Utility.java b/client/src/main/java/org/example/utils/Utility.java
deleted file mode 100644
index 0fdd7b3..0000000
--- a/client/src/main/java/org/example/utils/Utility.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.example.utils;
-
-public abstract class Utility {
- public static int randomIDGenerator(int max){
- return ((int)Math.floor(Math.random()*(max+1)));
- }
-
-}
diff --git a/client/src/main/java/org/example/view/AlertView.java b/client/src/main/java/org/example/view/AlertView.java
deleted file mode 100644
index c014703..0000000
--- a/client/src/main/java/org/example/view/AlertView.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.example.view;
-
-import org.example.controller.AlertController;
-import org.example.controller.LoginController;
-import org.example.model.MatchChecker;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-
-public class AlertView {
- private JPanel alert;
- public AlertView(JFrame frame, String name, String type, Sender sender, MatchChecker mm){
- alert = new JPanel();
- alert.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = GridBagConstraints.CENTER;
- c.gridwidth = 1;
- c.insets = new Insets(5,5,5,5);
- JLabel attentionLabel = new JLabel("Warning!");
- Font font = attentionLabel.getFont();
- attentionLabel.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- c.gridx = 0;
- c.gridy = 0;
- alert.add(attentionLabel, c);
-
- JLabel attentionLabel2 = new JLabel("A previous not finished match of type "+type+" is found");
- c.gridx = 0;
- c.gridy = 1;
- alert.add(attentionLabel2, c);
-
- JLabel attentionLabel3 = new JLabel("Do you want to resume it?");
- c.gridx = 0;
- c.gridy = 2;
- alert.add(attentionLabel3, c);
-
- JSeparator sp = new JSeparator();
- c.gridx = 0;
- c.gridy = 3;
- alert.add(sp, c);
-
- JPanel pp = new JPanel();
- pp.setLayout(new GridBagLayout());
- GridBagConstraints cc = new GridBagConstraints();
- c.gridwidth = 1;
- c.gridx = 0;
- c.gridy = 4;
- alert.add(pp,c);
-
- JButton buttonYes = new JButton("Yes");
- buttonYes.setPreferredSize(new Dimension(120,50));
- cc.gridx = 0;
- cc.gridy = 0;
- buttonYes.setOpaque(true);
- pp.add(buttonYes, cc);
-
- JButton buttonNo = new JButton("No");
- buttonNo.setPreferredSize(new Dimension(120,50));
- cc.gridx = 1;
- cc.gridy = 0;
- pp.add(buttonNo, cc);
-
- AlertController lc = new AlertController(frame, alert, name, type, buttonYes, buttonNo, sender, mm);
-
- alert.setVisible(true);
- }
-
- public JPanel getPanel(){
- return this.alert;
- }
-
-}
diff --git a/client/src/main/java/org/example/view/FriendlyModeView.java b/client/src/main/java/org/example/view/FriendlyModeView.java
deleted file mode 100644
index 2219c82..0000000
--- a/client/src/main/java/org/example/view/FriendlyModeView.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.example.view;
-
-import org.example.controller.FriendlyModeController;
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Timer;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class FriendlyModeView {
- private JPanel panel;
- public FriendlyModeView(JFrame frame, String name, ArrayList matches, Sender sender, MatchChecker mm){
- panel = new JPanel();
- panel.setLayout(new GridBagLayout());
- GridBagConstraints gcc1 = new GridBagConstraints();
- gcc1.fill = GridBagConstraints.HORIZONTAL;
- gcc1.anchor = GridBagConstraints.CENTER;
- gcc1.weightx = 0;
- gcc1.weighty = 0;
- gcc1.insets = new Insets(5,5,5,5);
- JLabel title = new JLabel("Friendly mode");
- gcc1.ipady = 60;
- gcc1.gridx = 0;
- gcc1.gridy = 0;
- Font font = title.getFont();
- title.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- panel.add(title,gcc1);
-
- gcc1.ipady = 0;
-
- JLabel description = new JLabel("Select a match or create a new one.");
- gcc1.gridx = 0;
- gcc1.gridy = 1;
- panel.add(description,gcc1);
-
- JScrollPane scrollable = new JScrollPane();
- gcc1.gridx = 0;
- gcc1.gridy = 2;
- scrollable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- JPanel content = new JPanel();
- scrollable.setPreferredSize(new Dimension(350,200));
- content.setLayout(new GridLayout((matches.size()),1));
- content.setVisible(true);
- scrollable.setViewportView(content);
-
- print(matches, sender, name, frame, panel, content, mm);
- panel.add(scrollable,gcc1);
-
- JPanel panel2 = new JPanel();
- panel2.setLayout(new GridBagLayout());
- GridBagConstraints gcc2 = new GridBagConstraints();
- gcc1.gridx = 0;
- gcc1.gridy = 3;
- panel.add(panel2,gcc1);
-
- JButton reload = new JButton("Reload");
- reload.setPreferredSize(new Dimension(160,40));
- gcc2.gridx = 0;
- gcc2.gridy = 0;
- panel2.add(reload,gcc2);
-
- JLabel or = new JLabel("or");
- gcc2.gridx = 0;
- gcc2.gridy = 1;
- panel2.add(or,gcc2);
-
- JButton back = new JButton("Go Back");
- back.setPreferredSize(new Dimension(160,40));
- gcc2.gridx = 0;
- gcc2.gridy = 2;
- panel2.add(back,gcc2);
-
- JButton button = new JButton("Create a new match");
- button.setPreferredSize(new Dimension(160,40));
- gcc2.gridx = 1;
- gcc2.gridy = 2;
- panel2.add(button,gcc2);
-
-
-
- FriendlyModeController fmc = new FriendlyModeController(frame, panel, matches, button, back, reload, content, name, sender, mm);
-
- content.setVisible(true);
- panel.setVisible(true);
- }
-
- private void print(ArrayList matches, Sender sender, String name, JFrame frame, JPanel panel, JPanel content, MatchChecker mm){
- for(Match m : matches){
- JPanel content2 = new JPanel();
- content2.setLayout(new GridLayout(6,1));
- JLabel l1 = new JLabel("Match: "+m.getName());
- content2.add(l1);
- JLabel l2 = new JLabel("Mode: "+m.getType());
- content2.add(l2);
- JLabel l3 = new JLabel("Host: "+m.getHost().name);
- content2.add(l3);
- JLabel l4 = new JLabel("Size: "+m.getPlayers().size());
- content2.add(l4);
- JButton enter = new JButton("Enter");
- content2.add(enter);
- enter.addActionListener(e2 -> {
- Message response = sender.sendAndRead(new Message<>(name, "GET_IN",m.getName()));
- if(response != null && response.getMessage() != null && response.getEvent().equals("GET_IN") && response.getMessage() instanceof Match){
- Match mGet = (Match) response.getMessage();
- mm.setType(mGet.getType());
- frame.remove(panel);
- frame.add(new RoomView(frame, name, matches, mGet, sender, mm, mGet.getTime(),mGet.getNumberQuestions()).getPanel());
- frame.validate();
- }else{
- JOptionPane.showMessageDialog(frame,"Can't join to this match!","Warning!",JOptionPane.WARNING_MESSAGE);
- }
- });
- JSeparator js = new JSeparator();
- content2.add(js);
- content.add(content2);
- content2.setVisible(true);
- }
- }
- public JPanel getPanel(){
- return this.panel;
- }
-}
diff --git a/client/src/main/java/org/example/view/LoginView.java b/client/src/main/java/org/example/view/LoginView.java
deleted file mode 100644
index 0e94b6a..0000000
--- a/client/src/main/java/org/example/view/LoginView.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.example.view;
-
-import org.example.controller.LoginController;
-import org.example.model.MatchChecker;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-
-public class LoginView {
- private JPanel login;
- public LoginView(JFrame frame, Sender sender, MatchChecker mm){
- login = new JPanel();
-
- login.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = GridBagConstraints.WEST;
- c.insets = new Insets(5,5,5,5);
-
- JLabel loginLabel = new JLabel("LOG IN");
- Font font = loginLabel.getFont();
- loginLabel.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- c.ipady = 60;
- c.gridx = 0;
- c.gridy = 0;
- login.add(loginLabel,c);
-
- c.ipady = 15;
- c.gridx = 0;
- c.gridy = 1;
- login.add(new JLabel("Enter your username so to play fantastic games alone or with your friends!"),c);
-
-
-
- JTextField nameJ = new JTextField(20);
- c.gridx = 0;
- c.gridy = 3;
- login.add(nameJ,c);
-
- JLabel username = new JLabel("Username:");
- username.setLabelFor(nameJ);
- c.gridx = 0;
- c.gridy = 2;
- login.add(username,c);
-
- JSeparator sp = new JSeparator();
- sp.setPreferredSize(new Dimension(400,1));
- c.gridx = 0;
- c.gridy = 4;
- login.add(sp,c);
-
- JButton loginButton = new JButton("Log In");
- loginButton.setPreferredSize(new Dimension(120,40));
- c.gridx = 0;
- c.gridy = 5;
- login.add(loginButton,c);
-
- LoginController lc = new LoginController(frame, login, loginButton, nameJ,sender, mm);
-
- login.setVisible(true);
- }
- public JPanel getPanel(){
- return this.login;
- }
-}
diff --git a/client/src/main/java/org/example/view/MatchCreatorView.java b/client/src/main/java/org/example/view/MatchCreatorView.java
deleted file mode 100644
index ecb4dec..0000000
--- a/client/src/main/java/org/example/view/MatchCreatorView.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.example.view;
-
-import org.example.controller.MatchCreatorController;
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Timer;
-
-public class MatchCreatorView {
- private JPanel panel;
- public MatchCreatorView(JFrame frame, String name, ArrayList matches, Sender sender, MatchChecker mm){
- panel = new JPanel();
- panel.setLayout(new GridBagLayout());
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.anchor = GridBagConstraints.WEST;
- gcc.insets = new Insets(5,5,5,5);
-
- JLabel title = new JLabel("Create a new match");
- Font font = title.getFont();
- title.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- gcc.gridx = 0;
- gcc.gridy = 0;
- panel.add(title,gcc);
-
-
- JLabel description = new JLabel("Name of the match: ");
- gcc.gridy = 2;
- panel.add(description,gcc);
-
- JTextField nameMatch = new JTextField(20);
- gcc.gridy = 3;
- panel.add(nameMatch,gcc);
-
- JLabel description1 = new JLabel("Type of the match:");
- gcc.gridy = 4;
- panel.add(description1,gcc);
-
- JComboBox modeList = new JComboBox(new String[]{"friendly","tournament"});
- modeList.setSelectedIndex(0);
- gcc.gridy = 5;
- panel.add(modeList,gcc);
-
- JLabel description2 = new JLabel("Maximum number of people allowed: ");
- gcc.gridy = 6;
- panel.add(description2,gcc);
-
- SpinnerModel people = new SpinnerNumberModel(4,1,10,1);
- JSpinner maxSize = new JSpinner(people);
- gcc.gridy = 7;
- panel.add(maxSize,gcc);
-
- JLabel description3 = new JLabel("Maximum duration of the match in minutes (only for friendly mode):");
- gcc.gridy = 8;
- panel.add(description3,gcc);
-
- SpinnerModel time = new SpinnerNumberModel(1,1,10,1);
- JSpinner timeMatch = new JSpinner(time);
- gcc.gridy = 9;
- panel.add(timeMatch,gcc);
-
-
- JLabel description4 = new JLabel("Numbers of questions of the match:");
- gcc.gridy = 10;
- panel.add(description4,gcc);
-
- SpinnerModel questions = new SpinnerNumberModel(5,5,15,5);
- JSpinner questionsSize = new JSpinner(questions);
- gcc.gridy = 11;
- panel.add(questionsSize,gcc);
-
- JSeparator sp = new JSeparator();
- gcc.gridy = 12;
- panel.add(sp,gcc);
-
- JPanel pp = new JPanel();
- pp.setLayout(new GridBagLayout());
- gcc.gridy = 13;
- panel.add(pp,gcc);
-
- JButton create = new JButton("Create");
- create.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 1;
- gcc.gridy = 0;
- pp.add(create,gcc);
-
- JButton back = new JButton("Go back");
- back.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 0;
- gcc.gridy = 0;
- pp.add(back,gcc);
-
- MatchCreatorController mc = new MatchCreatorController(frame,panel,nameMatch, back, create, name,maxSize,timeMatch,questionsSize, modeList, matches, sender, mm);
-
- panel.setVisible(true);
-
- }
- public JPanel getPanel(){
- return this.panel;
- }
-}
diff --git a/client/src/main/java/org/example/view/ModeView.java b/client/src/main/java/org/example/view/ModeView.java
deleted file mode 100644
index 5dc7e88..0000000
--- a/client/src/main/java/org/example/view/ModeView.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.example.view;
-
-import org.example.controller.ModeController;
-import org.example.model.MatchChecker;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.util.Timer;
-
-public class ModeView {
- private JPanel mode;
- public ModeView(JFrame frame, String name, Sender sender, MatchChecker mm){
- print(frame,name,sender,mm);
- }
-
- private void print(JFrame frame, String name, Sender sender, MatchChecker mm){
- mode = new JPanel();
- mode.setLayout(new GridBagLayout());
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.insets = new Insets(15,15,15,15);
- gcc.anchor = GridBagConstraints.WEST;
-
- JLabel modeLabel1 = new JLabel("Choose your game mode");
- Font font = modeLabel1.getFont();
- modeLabel1.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- gcc.gridx = 0;
- gcc.gridy = 0;
- gcc.ipady = 60;
- mode.add(modeLabel1,gcc);
- gcc.ipady = 0;
- JLabel modeLabel2 = new JLabel("Welcome "+name+"! Select the mode you want to play.");
- gcc.gridx = 0;
- gcc.gridy = 1;
- mode.add(modeLabel2,gcc);
-
- JRadioButton[] list = new JRadioButton[]{
- new JRadioButton("Practice Mode", true),
- new JRadioButton("Friendly/Tournament Mode")};
- ButtonGroup group = new ButtonGroup();
- int i = 2;
- for(JRadioButton el : list){
- group.add(el);
- gcc.gridx = 0;
- gcc.gridy = i;
- mode.add(el,gcc);
- i++;
- }
-
-
- JButton select = new JButton("Select");
- select.setPreferredSize(new Dimension(120,40));
- gcc.gridx = 0;
- gcc.gridy = 6;
- mode.add(select,gcc);
-
-
- ModeController mc = new ModeController(frame,mode,select,list,name,sender, mm);
- mode.setVisible(true);
- }
- public JPanel getPanel(){
- return this.mode;
- }
-}
diff --git a/client/src/main/java/org/example/view/QuestionView.java b/client/src/main/java/org/example/view/QuestionView.java
deleted file mode 100644
index 56b7acb..0000000
--- a/client/src/main/java/org/example/view/QuestionView.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.example.view;
-
-import org.example.controller.QuestionController;
-import org.example.model.MatchChecker;
-import org.example.model.Question;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class QuestionView {
- JPanel question;
- public QuestionView(JFrame frame, String name, Question q, Sender sender, MatchChecker mm, boolean lecit, Timer tQuiz, AtomicInteger seconds, JLabel timeLabel,int time, int questions, int iterator){
- question = new JPanel();
- question.setLayout(new GridBagLayout());
-
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.anchor = GridBagConstraints.CENTER;
- gcc.insets = new Insets(5,5,5,5);
- gcc.gridwidth = 1;
-
- if(timeLabel != null){
- gcc.gridx = 0;
- gcc.gridy = 0;
- gcc.ipady=60;
- question.add(timeLabel,gcc);
-
- }
- gcc.ipady=0;
- JLabel questionLabel = new JLabel("Question "+iterator+": ");
- gcc.gridx = 0;
- gcc.gridy = 1;
- question.add(questionLabel,gcc);
-
- JLabel questionLabel2 = new JLabel(q.quest);
- Font font = questionLabel2.getFont();
- questionLabel2.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- gcc.gridx = 0;
- gcc.gridy = 2;
- question.add(questionLabel2,gcc);
-
-
- JTextField result = new JTextField(20);
- gcc.gridx = 0;
- gcc.gridy = 3;
- question.add(result,gcc);
-
- JSeparator sp = new JSeparator();
- gcc.gridx = 0;
- gcc.gridy = 4;
- gcc.weightx = 1;
- question.add(sp,gcc);
- JButton sendButton = new JButton("Send answer");
- gcc.gridx = 0;
- gcc.gridy = 5;
- sendButton.setPreferredSize(new Dimension(120,50));
- question.add(sendButton,gcc);
- mm.setQuestion(q);
- mm.setPosition(iterator);
- question.setVisible(true);
- QuestionController qc = new QuestionController(frame,question,sendButton,result,q, name, sender, mm, lecit, tQuiz, seconds, timeLabel,time, questions, iterator);
-
-
- }
-
- public JPanel getPanel(){
- return question;
- }
-}
diff --git a/client/src/main/java/org/example/view/ResultsTournamentView.java b/client/src/main/java/org/example/view/ResultsTournamentView.java
deleted file mode 100644
index bbfb062..0000000
--- a/client/src/main/java/org/example/view/ResultsTournamentView.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.example.view;
-
-import org.example.controller.ResultsController;
-import org.example.controller.ResultsTournamentController;
-import org.example.model.MatchChecker;
-import org.example.model.Question;
-import org.example.model.Rank;
-import org.example.model.Score;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-
-public class ResultsTournamentView {
- private JPanel results;
- public ResultsTournamentView(JFrame frame, String name, ArrayList ranks, Sender sender, MatchChecker mm){
- results = new JPanel();
- results.setLayout(new GridBagLayout());
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.insets = new Insets(5,5,5,5);
- gcc.anchor = GridBagConstraints.WEST;
-
- JLabel title = new JLabel("Results");
- gcc.gridx = 0;
- gcc.gridy = 0;
- results.add(title,gcc);
-
- JScrollPane scrollable = new JScrollPane();
- scrollable.setPreferredSize(new Dimension(400,350));
- scrollable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- JPanel content = new JPanel();
- content.setLayout(new GridLayout(ranks.size(),1));
- for(Rank rank : ranks){
- JPanel content2 = new JPanel();
- content2.setLayout(new GridBagLayout());
- JLabel namePlayer = new JLabel("User: "+rank.name);
- gcc.gridy=0;
- content2.add(namePlayer,gcc);
- JLabel completed = new JLabel("Points: "+rank.points);
- gcc.gridy=1;
- content2.add(completed,gcc);
- gcc.gridy=2;
- JSeparator sp = new JSeparator();
- content2.add(sp,gcc);
- content.add(content2);
- }
- scrollable.setViewportView(content);
- gcc.gridy = 1;
- results.add(scrollable,gcc);
-
- JButton button = new JButton("Return to home");
- button.setPreferredSize(new Dimension(120,50));
- gcc.gridy = 2;
- results.add(button,gcc);
-
- ResultsTournamentController rc = new ResultsTournamentController(frame, results, button, name, sender, mm, ranks);
- results.setVisible(true);
- }
-
- public JPanel getPanel(){
- return this.results;
- }
-}
diff --git a/client/src/main/java/org/example/view/ResultsView.java b/client/src/main/java/org/example/view/ResultsView.java
deleted file mode 100644
index ac66fd5..0000000
--- a/client/src/main/java/org/example/view/ResultsView.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.example.view;
-
-import org.example.controller.ResultsController;
-import org.example.model.MatchChecker;
-import org.example.model.Question;
-import org.example.model.Score;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.util.ArrayList;
-public class ResultsView {
- private JPanel results;
- public ResultsView(JFrame frame, String name, Score score, Sender sender, MatchChecker mm, boolean casistic){
- results = new JPanel();
- results.setLayout(new GridBagLayout());
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.insets = new Insets(5,5,5,5);
- gcc.anchor = GridBagConstraints.WEST;
-
- if(!casistic && score != null){
- int size = score.questions.size();
-
- JLabel scoreLabel = new JLabel("RESULTS");
- gcc.gridx = 0;
- gcc.gridy = 0;
- results.add(scoreLabel,gcc);
-
- Font font = scoreLabel.getFont();
- scoreLabel.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- JScrollPane scrollable = new JScrollPane();
- scrollable.setPreferredSize(new Dimension(400,350));
- scrollable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- int i = 1;
- JPanel content = new JPanel();
- content.setLayout(new GridLayout(size*5,1));
- for(Question q : score.questions){
- JLabel el1 = new JLabel(i+". Question: "+q.quest);
- el1.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- content.add(el1);
- JLabel el2 = new JLabel("Expected: "+q.answer);
- content.add(el2);
- JLabel el3 = new JLabel("Given: "+q.given);
- content.add(el3);
- JLabel el4 = new JLabel("Is correct?: "+q.correct);
- content.add(el4);
- JSeparator sp = new JSeparator();
- content.add(sp);
- i++;
- }
- scrollable.setViewportView(content);
- gcc.gridx = 0;
- gcc.gridy = 1;
- results.add(scrollable,gcc);
-
-
- JButton button = new JButton("Return to home");
- button.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 0;
- gcc.gridy = 2;
- results.add(button,gcc);
-
- ResultsController rc = new ResultsController(frame,results,button,name,sender, mm);
-
-
- }else{
- JLabel waiting = new JLabel("Waiting for the other players");
- gcc.gridx = 0;
- gcc.gridy = 0;
- results.add(waiting,gcc);
- }
- results.setVisible(true);
- }
- public ResultsView(JFrame frame, String name, ArrayList scores, Sender sender, MatchChecker mm, boolean casistic){
- results = new JPanel();
- results.setLayout(new GridBagLayout());
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.insets = new Insets(5,5,5,5);
- gcc.anchor = GridBagConstraints.WEST;
- if(!casistic){
- JLabel scoreLabel = new JLabel("RESULTS");
- gcc.gridx = 0;
- gcc.gridy = 0;
- results.add(scoreLabel,gcc);
-
- Font font = scoreLabel.getFont();
- scoreLabel.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
-
- JScrollPane scrollable = new JScrollPane();
- scrollable.setPreferredSize(new Dimension(400,350));
- scrollable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- JPanel content = new JPanel();
- content.setLayout(new GridLayout(scores.size(),1));
- for(Score score : scores){
- JPanel content2 = new JPanel();
- content2.setLayout(new GridLayout(score.questions.size()*7,1));
- JLabel namePlayer = new JLabel("User: "+score.name);
- namePlayer.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- content2.add(namePlayer);
- JLabel completed = new JLabel("Completed: "+score.isCompleted());
- content2.add(completed);
- for(Question q : score.questions){
- JLabel el1 = new JLabel("Question: "+q.quest);
- el1.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- content2.add(el1);
- JLabel el2 = new JLabel("Expected: "+q.answer);
- content2.add(el2);
- JLabel el3 = new JLabel("Given: "+q.given);
- content2.add(el3);
- JLabel el4 = new JLabel("Is correct?: "+q.correct);
- content2.add(el4);
- }
- JSeparator sp = new JSeparator();
- content2.add(sp);
- content.add(content2);
- }
- scrollable.setViewportView(content);
- gcc.gridy = 1;
- results.add(scrollable,gcc);
-
- JButton button = new JButton("Return to home");
- button.setPreferredSize(new Dimension(120,50));
- gcc.gridy = 2;
- results.add(button,gcc);
-
- ResultsController rc = new ResultsController(frame,results,button,name,sender, mm);
-
- }else{
- JLabel waiting = new JLabel("Waiting for the other players");
- results.add(waiting);
- }
- results.setVisible(true);
- }
- public JPanel getPanel(){
- return this.results;
- }
-}
\ No newline at end of file
diff --git a/client/src/main/java/org/example/view/RoomView.java b/client/src/main/java/org/example/view/RoomView.java
deleted file mode 100644
index 23efb18..0000000
--- a/client/src/main/java/org/example/view/RoomView.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package org.example.view;
-
-import org.example.controller.RoomController;
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Player;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Timer;
-
-public class RoomView {
- private JPanel panel;
- public RoomView(JFrame frame, String name, ArrayList matches, Match match, Sender sender, MatchChecker mm, int time, int questions){
- panel = new JPanel();
- panel.setLayout(new GridBagLayout());
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.insets = new Insets(5,0,5,5);
- gcc.anchor = GridBagConstraints.WEST;
-
- JLabel matchName = new JLabel("Name of the match: "+match.getName());
- gcc.ipady = 30;
- Font font = matchName.getFont();
- matchName.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- gcc.gridx = 0;
- gcc.gridy = 0;
- panel.add(matchName,gcc);
-
- gcc.ipady = 0;
-
- JLabel description0 = new JLabel("Mode: "+match.getType());
- gcc.gridx = 0;
- gcc.gridy = 1;
- panel.add(description0,gcc);
-
-
- JLabel description = new JLabel("Max size: "+match.getSize());
- gcc.gridx = 0;
- gcc.gridy = 2;
- panel.add(description,gcc);
-
- JLabel questionsLabel = new JLabel("Number of questions: "+questions);
- gcc.gridx = 0;
- gcc.gridy = 3;
- panel.add(questionsLabel,gcc);
-
- JLabel durationLabel = new JLabel("Maximum duration in minutes: "+time+":00");
- gcc.gridx = 0;
- gcc.gridy = 4;
- panel.add(durationLabel,gcc);
-
- JLabel title = new JLabel("Players:");
- gcc.gridx = 0;
- gcc.gridy = 5;
- panel.add(title,gcc);
-
- JPanel content = new JPanel();
- JScrollPane scrollable = new JScrollPane();
- scrollable.setPreferredSize(new Dimension(350,150));
- scrollable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
- content.setLayout(new GridLayout(match.getPlayers().size(),1));
- int i = 1;
- int readyness = 0;
- for(Player p : match.getPlayers()){
- JPanel contentPl = new JPanel();
- JLabel el1 = new JLabel(i+". Name: ");
- el1.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- contentPl.add(el1);
- JLabel el2 = new JLabel(p.name+ " - Ready: "+p.isReady());
- contentPl.add(el2);
- JSeparator sp = new JSeparator();
- contentPl.add(sp);
- i++;
- if(p.isReady())
- readyness++;
- contentPl.setVisible(true);
- content.add(contentPl);
- }
- scrollable.setViewportView(content);
- gcc.gridx = 0;
- gcc.gridy = 6;
- panel.add(scrollable,gcc);
-
-
- JPanel pp = new JPanel();
- pp.setLayout(new GridBagLayout());
- gcc.gridx = 0;
- gcc.gridy = 7;
- panel.add(pp,gcc);
-
-
- JButton readyB = new JButton("Ready");
- readyB.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 1;
- gcc.gridy = 0;
- pp.add(readyB,gcc);
-
- JButton start = new JButton("Start match");
- start.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 1;
- gcc.gridy = 0;
- pp.add(start,gcc);
- start.setVisible(false);
- /*if(!ready){
- start = new JButton("Ready");
- start.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 1;
- gcc.gridy = 0;
- pp.add(start,gcc);
- }
- if(match.getHost().name.equals(name) && ready && readyness == match.getPlayers().size()){
- start = new JButton("Start match");
- start.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 1;
- gcc.gridy = 0;
- pp.add(start,gcc);
- }*/
-
- JButton close = new JButton("Close match");
- close.setPreferredSize(new Dimension(120,50));
- gcc.gridx = 0;
- gcc.gridy = 0;
- pp.add(close,gcc);
-
-
- JLabel crome = new JLabel();
- gcc.gridx = 0;
- gcc.gridy = 8;
- crome.setVisible(false);
- panel.add(crome,gcc);
-
-
- RoomController rc = new RoomController(frame, panel, close, start, readyB, content, name, matches, match, sender, mm, time, questions,crome);
- panel.setVisible(true);
- }
- public JPanel getPanel(){
- return this.panel;
- }
-}
diff --git a/client/src/main/java/org/example/view/TournamentView.java b/client/src/main/java/org/example/view/TournamentView.java
deleted file mode 100644
index 5e66f23..0000000
--- a/client/src/main/java/org/example/view/TournamentView.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.example.view;
-
-import org.example.controller.QuestionController;
-import org.example.controller.TournamentController;
-import org.example.model.MatchChecker;
-import org.example.model.Question;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class TournamentView {
- JPanel question;
- public TournamentView(JFrame frame, String name, Question q1, Sender sender, MatchChecker mm, JLabel timeLabel, int questions, int iterator, boolean casistic){
- question = new JPanel();
- question.setLayout(new GridBagLayout());
-
- GridBagConstraints gcc = new GridBagConstraints();
- gcc.anchor = GridBagConstraints.CENTER;
-
- gcc.insets = new Insets(5,5,5,5);
-
- JButton sendButton = null;
- ArrayList elements = new ArrayList<>();
-
- if(!casistic){
- if(timeLabel != null){
- gcc.gridx = 0;
- gcc.gridy = 0;
- gcc.ipady=60;
- question.add(timeLabel,gcc);
-
- }
- gcc.ipady=0;
- JLabel questionLabel = new JLabel("Question "+iterator+": ");
- gcc.gridx = 0;
- gcc.gridy = 1;
- question.add(questionLabel,gcc);
-
- JLabel questionLabel2 = new JLabel(q1.quest);
- Font font = questionLabel2.getFont();
- questionLabel2.setFont(new Font(font.getFontName(),Font.BOLD,font.getSize()));
- gcc.gridx = 0;
- gcc.gridy = 2;
- question.add(questionLabel2,gcc);
-
- ArrayList answers = q1.getAllAnswers();
-
- for(String ans : answers){
- elements.add(new JRadioButton(ans));
- }
- ButtonGroup group = new ButtonGroup();
- int i = 3;
- gcc.anchor = GridBagConstraints.WEST;
- for(JRadioButton el : elements){
- group.add(el);
- gcc.gridx = 0;
- gcc.gridy = i;
- question.add(el,gcc);
- i++;
- }
- gcc.anchor = GridBagConstraints.CENTER;
- JSeparator sp = new JSeparator();
- gcc.gridx = 0;
- gcc.gridy = 8;
-
- question.add(sp,gcc);
-
- sendButton = new JButton("Send answer");
- gcc.gridx = 0;
- gcc.gridy = 9;
- sendButton.setPreferredSize(new Dimension(120,50));
- question.add(sendButton,gcc);
-
- mm.setQuestion(q1);
- mm.setPosition(iterator);
- }else{
- JLabel waiting = new JLabel("Waiting for the other players");
- question.add(waiting);
- }
-
- question.setVisible(true);
- TournamentController tc = new TournamentController(frame, question,sendButton,elements,q1, name,sender,mm,timeLabel,questions,iterator,casistic);
-
-
- }
-
- public JPanel getPanel(){
- return question;
- }
-}
diff --git a/client/src/main/java/org/example/view/WindowView.java b/client/src/main/java/org/example/view/WindowView.java
deleted file mode 100644
index 7425b65..0000000
--- a/client/src/main/java/org/example/view/WindowView.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.example.view;
-
-import org.example.controller.WindowController;
-import org.example.model.MatchChecker;
-import org.example.model.Message;
-import org.example.utils.Sender;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-public class WindowView {
- public WindowView(Sender sender){
- JFrame frame = new JFrame();
- frame.setTitle("Play game!");
- frame.setSize(new Dimension(600,500));
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- MatchChecker mm = new MatchChecker();
-
- LoginView login = new LoginView(frame,sender,mm);
- frame.add(login.getPanel());
-
- WindowController wc = new WindowController(frame,mm,sender);
- frame.setResizable(false);
- frame.setVisible(true);
- }
-}
-
-//TODO: L'APP NON SI CHIUDE NELLA PAGINA DI LOGIN
\ No newline at end of file
diff --git a/client/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from client/gradle/wrapper/gradle-wrapper.jar
rename to gradle/wrapper/gradle-wrapper.jar
diff --git a/server/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
similarity index 100%
rename from server/gradle/wrapper/gradle-wrapper.properties
rename to gradle/wrapper/gradle-wrapper.properties
diff --git a/server/gradlew b/gradlew
similarity index 100%
rename from server/gradlew
rename to gradlew
diff --git a/server/gradlew.bat b/gradlew.bat
similarity index 100%
rename from server/gradlew.bat
rename to gradlew.bat
diff --git a/server/questions.txt b/questions.txt
similarity index 86%
rename from server/questions.txt
rename to questions.txt
index e456d89..dcaea3a 100644
--- a/server/questions.txt
+++ b/questions.txt
@@ -14,6 +14,6 @@ Quanto fa logaritmo in base 2 di 16?;4;2;3;1;5
Quanto fa logaritmo in base 2 di 32?;5;4;3;2;1
Quanto fa logaritmo in base 2 di 64?;6;5;7;8;2
Quando è finita la seconda guerra mondiale?;1945;1944;1943;1946;1950
-Quando è iniziata per l'Italia la prima guerra mondiale?;1915;1913;1914;1911;1916
-Quando è finita la prima guerra mondiale?;1918;1945;1922;1919;1917
+Quando è iniziata per l'Italia la prima guerra mondiale?;1911;1913;1914;1915;1916
+Quando è finita la prima guerra mondiale?;1917;1945;1922;1919;1918
In che anno fu scoperta l'America?;1492;1489;1528;1842;1700
\ No newline at end of file
diff --git a/server/build/classes/java/main/org/example/Main.class b/server/build/classes/java/main/org/example/Main.class
deleted file mode 100644
index 2680ac0..0000000
Binary files a/server/build/classes/java/main/org/example/Main.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/Server.class b/server/build/classes/java/main/org/example/Server.class
deleted file mode 100644
index 5e0bfbe..0000000
Binary files a/server/build/classes/java/main/org/example/Server.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/interfaces/Messages.class b/server/build/classes/java/main/org/example/interfaces/Messages.class
deleted file mode 100644
index 33db99e..0000000
Binary files a/server/build/classes/java/main/org/example/interfaces/Messages.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/Match.class b/server/build/classes/java/main/org/example/model/Match.class
deleted file mode 100644
index 8ef7cb8..0000000
Binary files a/server/build/classes/java/main/org/example/model/Match.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/MatchChecker.class b/server/build/classes/java/main/org/example/model/MatchChecker.class
deleted file mode 100644
index 710e653..0000000
Binary files a/server/build/classes/java/main/org/example/model/MatchChecker.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/Message.class b/server/build/classes/java/main/org/example/model/Message.class
deleted file mode 100644
index 5fd0935..0000000
Binary files a/server/build/classes/java/main/org/example/model/Message.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/Player.class b/server/build/classes/java/main/org/example/model/Player.class
deleted file mode 100644
index 7c3439a..0000000
Binary files a/server/build/classes/java/main/org/example/model/Player.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/Question.class b/server/build/classes/java/main/org/example/model/Question.class
deleted file mode 100644
index df340a1..0000000
Binary files a/server/build/classes/java/main/org/example/model/Question.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/Rank.class b/server/build/classes/java/main/org/example/model/Rank.class
deleted file mode 100644
index 653e93d..0000000
Binary files a/server/build/classes/java/main/org/example/model/Rank.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/model/Score.class b/server/build/classes/java/main/org/example/model/Score.class
deleted file mode 100644
index cc28f39..0000000
Binary files a/server/build/classes/java/main/org/example/model/Score.class and /dev/null differ
diff --git a/server/build/classes/java/main/org/example/utils/Utility.class b/server/build/classes/java/main/org/example/utils/Utility.class
deleted file mode 100644
index 0e79146..0000000
Binary files a/server/build/classes/java/main/org/example/utils/Utility.class and /dev/null differ
diff --git a/server/build/classes/java/test/MatchCheckerTest.class b/server/build/classes/java/test/MatchCheckerTest.class
deleted file mode 100644
index 3985401..0000000
Binary files a/server/build/classes/java/test/MatchCheckerTest.class and /dev/null differ
diff --git a/server/build/classes/java/test/RankTest.class b/server/build/classes/java/test/RankTest.class
deleted file mode 100644
index 72ed23f..0000000
Binary files a/server/build/classes/java/test/RankTest.class and /dev/null differ
diff --git a/server/build/classes/java/test/UtilityTest.class b/server/build/classes/java/test/UtilityTest.class
deleted file mode 100644
index 2edbac5..0000000
Binary files a/server/build/classes/java/test/UtilityTest.class and /dev/null differ
diff --git a/server/build/classes/java/test/communicationTest.class b/server/build/classes/java/test/communicationTest.class
deleted file mode 100644
index dfcdb91..0000000
Binary files a/server/build/classes/java/test/communicationTest.class and /dev/null differ
diff --git a/server/build/libs/game-1.0-SNAPSHOT.jar b/server/build/libs/game-1.0-SNAPSHOT.jar
deleted file mode 100644
index e32ec74..0000000
Binary files a/server/build/libs/game-1.0-SNAPSHOT.jar and /dev/null differ
diff --git a/server/build/reports/tests/test/classes/MatchTest.html b/server/build/reports/tests/test/classes/MatchTest.html
deleted file mode 100644
index 82ec73d..0000000
--- a/server/build/reports/tests/test/classes/MatchTest.html
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-Test results - Class MatchTest
-
-
-
-
-
-
-
Class MatchTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-matchConstructor1()
-0.003s
-passed
-
-
-matchConstructor2()
-0.004s
-passed
-
-
-matchConstructor3()
-0.002s
-passed
-
-
-matchConstructor4()
-0.002s
-passed
-
-
-matchID()
-0.091s
-passed
-
-
-testSetters()
-0.004s
-passed
-
-
-togglePlayers()
-0.035s
-passed
-
-
-
-
-
Standard output
-
-Match{players=[], available=false, type='friendly', id=1987722143, name='test', host=Player{name='name', questions=[], hasFinished=false, score=Score{questions=[], name='name'}, id=986726128, ready=false, indexLastQuestion=-1}, size=4, time=0, numberQuestions=10}
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/MemoryTest.html b/server/build/reports/tests/test/classes/MemoryTest.html
deleted file mode 100644
index 661d596..0000000
--- a/server/build/reports/tests/test/classes/MemoryTest.html
+++ /dev/null
@@ -1,126 +0,0 @@
-
-
-
-
-
-Test results - Class MemoryTest
-
-
-
-
-
-
-
Class MemoryTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-memoryAdd1()
-0s
-passed
-
-
-memoryAdd2()
-0.001s
-passed
-
-
-memoryCheck()
-0.001s
-passed
-
-
-memoryClone()
-0.001s
-passed
-
-
-memoryDelete1()
-0.002s
-passed
-
-
-memoryDelete2()
-0.001s
-passed
-
-
-memoryGet()
-0.001s
-passed
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/MessageTest.html b/server/build/reports/tests/test/classes/MessageTest.html
deleted file mode 100644
index 5a2a63b..0000000
--- a/server/build/reports/tests/test/classes/MessageTest.html
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-Test results - Class MessageTest
-
-
-
-
-
-
-
Class MessageTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-testConstructor1()
-0.001s
-passed
-
-
-testConstructor2()
-0.002s
-passed
-
-
-testConstructor3()
-0.003s
-passed
-
-
-testSetterGetter()
-0.001s
-passed
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/PlayerQuestionTest.html b/server/build/reports/tests/test/classes/PlayerQuestionTest.html
deleted file mode 100644
index 53daef6..0000000
--- a/server/build/reports/tests/test/classes/PlayerQuestionTest.html
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-Test results - Class PlayerQuestionTest
-
-
-
-
-
-
-
Class PlayerQuestionTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-playerAddQuestion()
-0.001s
-passed
-
-
-playerClearQuestion()
-0.001s
-passed
-
-
-playerEquals()
-0.002s
-passed
-
-
-playerHasQuestion()
-0.001s
-passed
-
-
-playerID()
-0.075s
-passed
-
-
-playerIndex()
-0.001s
-passed
-
-
-playerPickQuestion()
-0s
-passed
-
-
-playerPopQuestion()
-0.003s
-passed
-
-
-playerReadynessFinishing()
-0.002s
-passed
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/QuestionTest.html b/server/build/reports/tests/test/classes/QuestionTest.html
deleted file mode 100644
index 1f156d9..0000000
--- a/server/build/reports/tests/test/classes/QuestionTest.html
+++ /dev/null
@@ -1,116 +0,0 @@
-
-
-
-
-
-Test results - Class QuestionTest
-
-
-
-
-
-
-
Class QuestionTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-checkAnswer()
-0.003s
-passed
-
-
-checkEquivalence()
-0.002s
-passed
-
-
-checkNull()
-0.003s
-passed
-
-
-countQuestions()
-0.006s
-passed
-
-
-getAnswers()
-0.001s
-passed
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/ScoreTest.html b/server/build/reports/tests/test/classes/ScoreTest.html
deleted file mode 100644
index 5435e17..0000000
--- a/server/build/reports/tests/test/classes/ScoreTest.html
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
-Test results - Class ScoreTest
-
-
-
-
-
-
-
Class ScoreTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-test()
-0.010s
-passed
-
-
-
-
-
Standard output
-
-Score{questions=[Question{quest='test1', answer='answer1', given='answer1', wrong1='null', wrong2='null', wrong3='null', wrong4='null', correct=true}, Question{quest='test2', answer='answer2', given='answer4', wrong1='null', wrong2='null', wrong3='null', wrong4='null', correct=false}, Question{quest='test3', answer='answer3', given='answer3', wrong1='null', wrong2='null', wrong3='null', wrong4='null', correct=true}], name='fra'}
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/UtilityTest.html b/server/build/reports/tests/test/classes/UtilityTest.html
deleted file mode 100644
index 3f16f62..0000000
--- a/server/build/reports/tests/test/classes/UtilityTest.html
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
-Test results - Class UtilityTest
-
-
-
-
-
-
-
Class UtilityTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-testGet1()
-0.004s
-passed
-
-
-testGet2()
-0.003s
-passed
-
-
-testRandomness()
-0.002s
-passed
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/classes/communicationTest.html b/server/build/reports/tests/test/classes/communicationTest.html
deleted file mode 100644
index 47c360f..0000000
--- a/server/build/reports/tests/test/classes/communicationTest.html
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-
-
-
-Test results - Class communicationTest
-
-
-
-
-
-
-
Class communicationTest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Tests
-
-
-
-Test
-Duration
-Result
-
-
-
-testDropQuestion()
-0.004s
-passed
-
-
-testHandleContinueGame()
-0.004s
-passed
-
-
-testHandleCreate()
-0.008s
-passed
-
-
-testHandleEndTimer()
-0.004s
-passed
-
-
-testHandleGaming()
-0.004s
-passed
-
-
-testHandleGetIn()
-0.003s
-passed
-
-
-testHandleIsEnd()
-0.004s
-passed
-
-
-testHandleMatchRemover()
-0.004s
-passed
-
-
-testHandleName()
-0.006s
-passed
-
-
-testHandleOthers()
-0.003s
-passed
-
-
-testHandleStartGame()
-0.030s
-passed
-
-
-testHandleUpdate()
-0.003s
-passed
-
-
-testNameChecker()
-0.004s
-passed
-
-
-testUpdateNext()
-0.004s
-passed
-
-
-
-
-
Standard output
-
-Message{owner='test', event='ERROR', message='null'}
-Message{owner='test', event='ERROR', message='null'}
-Message{owner='test', event='ERROR', message='null'}
-Message{owner='test', event='ERROR', message='null'}
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/index.html b/server/build/reports/tests/test/index.html
deleted file mode 100644
index e29ef13..0000000
--- a/server/build/reports/tests/test/index.html
+++ /dev/null
@@ -1,233 +0,0 @@
-
-
-
-
-
-Test results - Test Summary
-
-
-
-
-
-
-
Test Summary
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Packages
-
-
-
-Package
-Tests
-Failures
-Ignored
-Duration
-Success rate
-
-
-
-
-
-default-package
-
-53
-0
-0
-0.401s
-100%
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/reports/tests/test/packages/default-package.html b/server/build/reports/tests/test/packages/default-package.html
deleted file mode 100644
index 4a8daae..0000000
--- a/server/build/reports/tests/test/packages/default-package.html
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
-Test results - Default package
-
-
-
-
-
-
-
Default package
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-MatchCheckerTest.xml b/server/build/test-results/test/TEST-MatchCheckerTest.xml
deleted file mode 100644
index 001ecaa..0000000
--- a/server/build/test-results/test/TEST-MatchCheckerTest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-MatchTest.xml b/server/build/test-results/test/TEST-MatchTest.xml
deleted file mode 100644
index 6be7e65..0000000
--- a/server/build/test-results/test/TEST-MatchTest.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-MemoryTest.xml b/server/build/test-results/test/TEST-MemoryTest.xml
deleted file mode 100644
index 0ae85ed..0000000
--- a/server/build/test-results/test/TEST-MemoryTest.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-MessageTest.xml b/server/build/test-results/test/TEST-MessageTest.xml
deleted file mode 100644
index 2ce76b0..0000000
--- a/server/build/test-results/test/TEST-MessageTest.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-PlayerQuestionTest.xml b/server/build/test-results/test/TEST-PlayerQuestionTest.xml
deleted file mode 100644
index 526d825..0000000
--- a/server/build/test-results/test/TEST-PlayerQuestionTest.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-QuestionTest.xml b/server/build/test-results/test/TEST-QuestionTest.xml
deleted file mode 100644
index 10aa6b3..0000000
--- a/server/build/test-results/test/TEST-QuestionTest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-RankTest.xml b/server/build/test-results/test/TEST-RankTest.xml
deleted file mode 100644
index 29ec722..0000000
--- a/server/build/test-results/test/TEST-RankTest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-ScoreTest.xml b/server/build/test-results/test/TEST-ScoreTest.xml
deleted file mode 100644
index 533d802..0000000
--- a/server/build/test-results/test/TEST-ScoreTest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-UtilityTest.xml b/server/build/test-results/test/TEST-UtilityTest.xml
deleted file mode 100644
index 7988f8a..0000000
--- a/server/build/test-results/test/TEST-UtilityTest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/TEST-communicationTest.xml b/server/build/test-results/test/TEST-communicationTest.xml
deleted file mode 100644
index 22405b6..0000000
--- a/server/build/test-results/test/TEST-communicationTest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/server/build/test-results/test/binary/output.bin b/server/build/test-results/test/binary/output.bin
deleted file mode 100644
index 0fa7bbf..0000000
--- a/server/build/test-results/test/binary/output.bin
+++ /dev/null
@@ -1,7 +0,0 @@
-
-‰Match{players=[], available=false, type='friendly', id=1987722143, name='test', host=Player{name='name', questions=[], hasFinished=false, score=Score{questions=[], name='name'}, id=986726128, ready=false, indexLastQuestion=-1}, size=4, time=0, numberQuestions=10}
--,²Score{questions=[Question{quest='test1', answer='answer1', given='answer1', wrong1='null', wrong2='null', wrong3='null', wrong4='null', correct=true}, Question{quest='test2', answer='answer2', given='answer4', wrong1='null', wrong2='null', wrong3='null', wrong4='null', correct=false}, Question{quest='test3', answer='answer3', given='answer3', wrong1='null', wrong2='null', wrong3='null', wrong4='null', correct=true}], name='fra'}
-326Message{owner='test', event='ERROR', message='null'}
-366Message{owner='test', event='ERROR', message='null'}
-396Message{owner='test', event='ERROR', message='null'}
-3;6Message{owner='test', event='ERROR', message='null'}
diff --git a/server/build/test-results/test/binary/output.bin.idx b/server/build/test-results/test/binary/output.bin.idx
deleted file mode 100644
index 5853b25..0000000
Binary files a/server/build/test-results/test/binary/output.bin.idx and /dev/null differ
diff --git a/server/build/test-results/test/binary/results.bin b/server/build/test-results/test/binary/results.bin
deleted file mode 100644
index 65ed2cc..0000000
Binary files a/server/build/test-results/test/binary/results.bin and /dev/null differ
diff --git a/server/build/tmp/compileJava/previous-compilation-data.bin b/server/build/tmp/compileJava/previous-compilation-data.bin
deleted file mode 100644
index 4aadf0a..0000000
Binary files a/server/build/tmp/compileJava/previous-compilation-data.bin and /dev/null differ
diff --git a/server/build/tmp/compileTestJava/previous-compilation-data.bin b/server/build/tmp/compileTestJava/previous-compilation-data.bin
deleted file mode 100644
index 0ae2b93..0000000
Binary files a/server/build/tmp/compileTestJava/previous-compilation-data.bin and /dev/null differ
diff --git a/server/build/tmp/jar/MANIFEST.MF b/server/build/tmp/jar/MANIFEST.MF
deleted file mode 100644
index 58630c0..0000000
--- a/server/build/tmp/jar/MANIFEST.MF
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-
diff --git a/server/gradle/wrapper/gradle-wrapper.jar b/server/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 41d9927..0000000
Binary files a/server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/server/src/test/java/MatchCheckerTest.java b/server/src/test/java/MatchCheckerTest.java
deleted file mode 100644
index 6edf9f9..0000000
--- a/server/src/test/java/MatchCheckerTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-import org.example.model.Match;
-import org.example.model.MatchChecker;
-import org.example.model.Question;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class MatchCheckerTest {
- @Test
- public void test1(){
- MatchChecker mm = new MatchChecker();
- Assertions.assertAll(
- ()->Assertions.assertNull(mm.getQuestion()),
- ()->Assertions.assertNull(mm.getType()),
- ()->Assertions.assertNull(mm.getMatch()),
- ()->Assertions.assertNull(mm.getName()),
- ()->Assertions.assertFalse(mm.isGoingOn()),
- ()->Assertions.assertEquals(1,mm.getPosition())
- );
-
- }
- public void test2(){
- MatchChecker mm = new MatchChecker();
- mm.setType("friendly");
- mm.setQuestion(new Question("quest","answer"));
- mm.setPosition(3);
- mm.setGoingOn(true);
- mm.setName("fra");
- mm.setMatch("test");
- Assertions.assertAll(
- ()->Assertions.assertEquals("quest",mm.getQuestion().quest),
- ()->Assertions.assertEquals("answer",mm.getQuestion().answer),
- ()->Assertions.assertEquals("friendly",mm.getType()),
- ()->Assertions.assertEquals("test",mm.getMatch()),
- ()->Assertions.assertEquals("fra",mm.getName()),
- ()->Assertions.assertTrue(mm.isGoingOn()),
- ()->Assertions.assertEquals(3,mm.getPosition())
- );
- }
-}
diff --git a/server/src/test/java/UtilityTest.java b/server/src/test/java/UtilityTest.java
deleted file mode 100644
index 61408ef..0000000
--- a/server/src/test/java/UtilityTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-import org.example.model.Player;
-import org.example.model.Question;
-import org.example.utils.Utility;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-public class UtilityTest {
- private static final String QUESTION_FILE = "./questions.txt";
- @Test
- public void testRandomness(){
- ArrayList ints = new ArrayList<>();
- for(int i = 0; i < 1000; i++){
- ints.add(Utility.randomIDGenerator(Integer.MAX_VALUE-1));
- }
- Collections.sort(ints);
- for(int i = 0; i < ints.size() - 1; i++){
- Assertions.assertNotEquals(ints.get(i), ints.get(i+1));
- }
- }
-
- @Test
- public void testGet1(){
- Player p = new Player("fra");
- Assertions.assertEquals(0,p.questions.size());
- Utility.readQuestionsFromFile(QUESTION_FILE, p, 10);
- Assertions.assertEquals(10,p.questions.size());
- for(Object q : p.questions){
- Assertions.assertTrue(q instanceof Question);
- }
- for(Question q : p.questions){
- Assertions.assertAll(
- ()->Assertions.assertNotNull(q.quest),
- ()->Assertions.assertNotNull(q.correct),
- ()->Assertions.assertNotNull(q.wrong1),
- ()->Assertions.assertNotNull(q.wrong2),
- ()->Assertions.assertNotNull(q.wrong3),
- ()->Assertions.assertNotNull(q.wrong4)
- );
- }
- }
-
- @Test
- public void testGet2(){
- ArrayList players = new ArrayList<>();
- players.add(new Player("fra1"));
- players.add(new Player("fra2"));
- players.add(new Player("fra3"));
- for(Player p : players){
- Assertions.assertEquals(0,p.questions.size());
- }
- ArrayList playersNew = Utility.readQuestionsFromFile(QUESTION_FILE, players, 10);
- for(Player p : playersNew){
- Assertions.assertEquals(10,p.questions.size());
- for(Question q : p.questions){
- Assertions.assertAll(
- ()->Assertions.assertNotNull(q.quest),
- ()->Assertions.assertNotNull(q.correct),
- ()->Assertions.assertNotNull(q.wrong1),
- ()->Assertions.assertNotNull(q.wrong2),
- ()->Assertions.assertNotNull(q.wrong3),
- ()->Assertions.assertNotNull(q.wrong4)
- );
- }
- }
- }
-
-}
diff --git a/server/src/test/java/communicationTest.java b/server/src/test/java/communicationTest.java
deleted file mode 100644
index fb1822f..0000000
--- a/server/src/test/java/communicationTest.java
+++ /dev/null
@@ -1,557 +0,0 @@
-import org.example.model.*;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.Socket;
-import java.util.ArrayList;
-
-public class communicationTest {
- private final int PORT = 9002;
- @Test
- public void testHandleName() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message<>("test","NAME","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- if(result.getEvent() != null && !result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("mode",result.getEvent().toLowerCase())
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleStartGame() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","START","practice"));
- out.flush();
- out.reset();
- Message result1 = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result1.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("game",result1.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result1.getMessage() instanceof Question)
- );
- out.writeObject(new Message("test","START","friendlytournament"));
- out.flush();
- out.reset();
- Message result2 = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result2.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("list",result2.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result2.getMessage() instanceof ArrayList>)
- );
- out.writeObject(new Message("test","START","test"));
- out.flush();
- out.reset();
- Message result3 = (Message) in.readObject();
- System.out.println(result3);
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result3.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result3.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result3.getMessage())
- );
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleGaming() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","GAME",new Question("quest","answer")));
- out.flush();
- out.reset();
- Message result1 = (Message) in.readObject();
- System.out.println(result1);
- if(!result1.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result1.getOwner().toLowerCase()),
- ()->Assertions.assertTrue(result1.getEvent().toLowerCase().equals("game") || result1.getEvent().toLowerCase().equals("end")),
- ()->Assertions.assertTrue(result1.getMessage() instanceof Question || result1.getMessage() instanceof Score)
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result1.getOwner().toLowerCase()),
- ()->Assertions.assertTrue(result1.getEvent().toLowerCase().equals("error")),
- ()->Assertions.assertTrue(result1.getMessage() == null)
- );
- }
-
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleEndTimer() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","END_TIMER","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("end_timer",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
- );
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleContinueGame() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message<>("test","RESUME","practice"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("game",result.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result.getMessage() instanceof Question)
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
- );
- }
- out.writeObject(new Message<>("test","RESUME","test"));
- out.flush();
- out.reset();
- Message result2 = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result2.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result2.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result2.getMessage())
- );
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testNameChecker() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","NAME_CHECKER","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("name_checker",result.getEvent().toLowerCase())
-
- );
- if(result.getMessage() != null)
- Assertions.assertEquals("y",result.getMessage().toLowerCase());
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleCreate() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","CREATE","test:2:1:5:practice"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("create",result.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result.getMessage() instanceof Match)
-
- );
- out.writeObject(new Message("test","CREATE","test:2:1:5"));
- out.flush();
- out.reset();
- Message result2 = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result2.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result2.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result2.getMessage())
- );
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleMatchRemover() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","MATCH_REMOVER","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- System.out.println(result);
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("match_remover",result.getEvent().toLowerCase()),
- ()->Assertions.assertEquals("ok",result.getMessage().toLowerCase())
-
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleGetIn() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","GET_IN","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("get_in",result.getEvent().toLowerCase())
- );
- if(result.getMessage() != null){
- Assertions.assertTrue(result.getMessage() instanceof Match);
- }
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleUpdate() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","UPDATE_PLAYERS","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("update_players",result.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result.getMessage() instanceof Match)
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testDropQuestion() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","DROP_QUESTION","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- System.out.println(result);
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("drop_question",result.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result.getMessage() instanceof Question)
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleIsEnd() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","IS_END","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("is_end",result.getEvent().toLowerCase())
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testUpdateNext() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message("test","UPDATE_NEXT","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- if(!result.getEvent().toLowerCase().equals("error")){
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("return_rank",result.getEvent().toLowerCase()),
- ()->Assertions.assertTrue(result.getMessage() instanceof ArrayList>)
- );
- }else{
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-
- @Test
- public void testHandleOthers() throws IOException {
- Socket socket = null;
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- try{
- socket = new Socket("localhost", PORT);
- out = new ObjectOutputStream(socket.getOutputStream());
- in = new ObjectInputStream(socket.getInputStream());
- out.writeObject(new Message<>("test","test","test"));
- out.flush();
- out.reset();
- Message result = (Message) in.readObject();
- Assertions.assertAll(
- ()->Assertions.assertEquals("test",result.getOwner().toLowerCase()),
- ()->Assertions.assertEquals("error",result.getEvent().toLowerCase()),
- ()->Assertions.assertNull(result.getMessage())
-
- );
- }catch (Exception e){
- e.printStackTrace();
- }
- finally {
- if(socket != null && out != null && in != null){
- socket.close();
- in.close();
- out.close();
- }
- }
- }
-}
diff --git a/server/settings.gradle b/settings.gradle
similarity index 100%
rename from server/settings.gradle
rename to settings.gradle
diff --git a/server/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java
similarity index 90%
rename from server/src/main/java/org/example/Main.java
rename to src/main/java/org/example/Main.java
index e51161c..2877fbe 100644
--- a/server/src/main/java/org/example/Main.java
+++ b/src/main/java/org/example/Main.java
@@ -17,11 +17,12 @@ public static void main(String[] args) {
Memory matchesList = new Memory<>();
Memory onlinePLayers = new Memory<>();
Object memoryLock = new Object();
+ Object memoryLockSaved = new Object();
System.out.println("SERVER LISTENING AT PORT "+PORT);
while(true){
Socket socketClient = serverSocket.accept();
System.out.println("CONNECTION ESTABLISHED");
- Server s = new Server(socketClient,matchesSaved, matchesList,onlinePLayers,memoryLock);
+ Server s = new Server(socketClient,matchesSaved, matchesList,onlinePLayers,memoryLock,memoryLockSaved);
s.start();
}
}catch(Exception e){
diff --git a/server/src/main/java/org/example/Server.java b/src/main/java/org/example/Server.java
similarity index 66%
rename from server/src/main/java/org/example/Server.java
rename to src/main/java/org/example/Server.java
index 91736cf..5e949a0 100644
--- a/server/src/main/java/org/example/Server.java
+++ b/src/main/java/org/example/Server.java
@@ -11,7 +11,7 @@
import java.util.Iterator;
public class Server extends Thread{
- private static final String QUESTION_FILE = "questions.txt";
+ private static final String QUESTION_FILE = "./questions.txt";
private final Socket s;
private Match match;
private ObjectInputStream in;
@@ -23,9 +23,9 @@ public class Server extends Thread{
private SenderClient senderClient;
- private Object lock;
+ private Object lock,lock2;
private boolean flag;
- public Server(Socket s, Memory matchesSaved, Memory matchesList, Memory usersConnected, Object lock){
+ public Server(Socket s, Memory matchesSaved, Memory matchesList, Memory usersConnected, Object lock, Object memoryLockSaved){
this.s = s;
this.match = null;
this.player = new Player();
@@ -34,6 +34,7 @@ public Server(Socket s, Memory matchesSaved, Memory matchesList, M
this.matchesList = matchesList;
this.usersConnected = usersConnected;
this.lock = lock;
+ this.lock2 = memoryLockSaved;
try{
this.in = new ObjectInputStream(this.s.getInputStream());
this.out = new ObjectOutputStream(this.s.getOutputStream());
@@ -43,22 +44,29 @@ public Server(Socket s, Memory matchesSaved, Memory matchesList, M
}
}
public void run() {
- try {
- this.read();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ this.read(this.lock);
}
- private void read() throws IOException {
+ private void read(Object lock){
try{
- while (!flag){ //Flag is true only when client has asked to close the connection with server
- Message mex = (Message) this.in.readObject(); //Read the object sent by client
+ while (!flag){
+ Message mex = (Message) this.in.readObject();
System.out.println("Entering : "+mex);
- if(mex != null){
+ if(mex != null){ //TODO: CHECK IF MEX IS A REAL MESSAGE
switch (mex.getEvent()){
case "NAME":
- handleName(mex);
+ this.player.setName(mex.getOwner());
+ if(this.usersConnected.checkElement(this.player)){
+ this.senderClient.sendToClient(mex,"mode","no");
+ }else{
+ this.usersConnected.add(this.player);
+ this.match = this.checkPreviousMatches();
+ if(this.match != null){ //HO UN MATCH NON FINITO DA POTER FINIRE
+ this.senderClient.sendToClient(mex,"mode",this.match);
+ }else{
+ this.senderClient.sendToClient(mex,"mode");
+ }
+ }
break;
case "START":
handleStartGame(mex);
@@ -67,13 +75,13 @@ private void read() throws IOException {
handleGaming(mex);
break;
case "END":
- handleClosing(mex);
+ handleClosing(mex, lock);
break;
case "END_TIMER":
handleEndTimer(mex);
break;
case "REMOVE":
- handleRemove();
+ handleRemove(mex);
break;
case "RESUME":
handleContinueGame(mex);
@@ -115,74 +123,27 @@ private void read() throws IOException {
handleReturnRank(mex);
break;
case "COUNT_TOURNAMENT":
- handleCountTournament();
- break;
- default:
- this.senderClient.sendToClient(mex,"error");
- this.flag = true;
- break;
+ handleCountTournament(mex);
}
}
}
}
catch (Exception ee){
- System.out.println("Closing the connection with the server");
- this.s.close();
- this.in.close();
- this.out.close();
- this.flag = true;
- synchronized (lock){
- if(this.player != null)
- this.usersConnected.remove(this.player);
- if(this.match != null){
- this.matchesList.remove(this.match);
- this.matchesSaved.remove(this.match);
- }
- }
+ ee.printStackTrace();
}
}
- /**
- * Metodo usato dal client nel moemnto in cui effetta un login attraverso uno username
- * */
- private void handleName(Message mex){
- if(this.player != null){
- this.player.setName(mex.getOwner());
- synchronized (lock){
- if(this.usersConnected.checkElement(this.player)){
- this.senderClient.sendToClient(mex,"mode","no");
- }else{
- this.usersConnected.add(this.player);
- this.match = this.checkPreviousMatches();
- if(this.match != null){ //I have an unfinished match previously closed
- this.senderClient.sendToClient(mex,"mode",this.match);
- }else{
- this.senderClient.sendToClient(mex,"mode");
- }
- }
- }
- }else{
- this.senderClient.sendToClient(mex,"error");
- }
- }
- /**
- * Metodo usato dal client dal momento in cui ha visto i risultati di un match di tipo tournament e vuole tornare alla home
- * */
- private void handleCountTournament(){
- if(this.match != null){
- synchronized (lock){
- this.match.removePlayer(this.player);
- if(this.match.getPlayers().size() <= 0){
- this.matchesList.remove(this.match);
- this.match = null;
- }
+ private void handleCountTournament(Message mex){
+ synchronized (lock){
+ this.match.removePlayer(this.player);
+ if(this.match.getPlayers().size() <= 0){
+ this.matchesList.remove(this.match);
+ this.match = null;
}
}
}
- /**
- * Metodo usato per stilare la classifica di un match tournament finito
- * */
+
private void handleReturnRank(Message mex){
if(this.match != null){
ArrayList qo = new ArrayList<>();
@@ -256,23 +217,16 @@ private void handleReturnRank(Message mex){
Collections.sort(ranks);
this.senderClient.sendToClient(mex,"RETURN_RANK",ranks);
- }else{
- this.senderClient.sendToClient(mex,"error");
}
}
- /**
- * Metodo usato per impostare un utente come ready all'interno di una stanza
- * */
private void handleUpdateReady(Message mex){
if(mex.getMessage() != null){
this.player.setReady((Boolean) mex.getMessage());
}
}
- /**
- * Metodo usato per controllare se un match sia finito o se gli utenti devono ancora aspettare che gli altri finiscano
- * */
+
private void handleIsEnd(Message mex){
boolean flag = false;
if(this.match != null){
@@ -295,15 +249,10 @@ private void handleIsEnd(Message mex){
}else{
this.senderClient.sendToClient(mex,"IS_END");
}
- }else{
- this.senderClient.sendToClient(mex,"error");
}
}
- /**
- * Metodo usato per prendere la domanda successiva dell'utente che ne sta facendo richiesta all'interno di un match
- * */
private void handleDropQuestion(Message mex){
if(mex.getMessage() != null && mex.getMessage() instanceof String && this.match != null){
Question q = null;
@@ -315,14 +264,8 @@ private void handleDropQuestion(Message mex){
}
this.senderClient.sendToClient(mex,"DROP_QUESTION",q);
//}
- }else{
- this.senderClient.sendToClient(mex,"error");
}
}
-
- /**
- * Metodo usato per la rimozione di un player che è uscito da un match
- * */
private void handleRemovePlayer(Message mex){
String nameGot = (String) mex.getMessage();
Match mm = new Match(null,nameGot,null,1);
@@ -336,9 +279,6 @@ private void handleRemovePlayer(Message mex){
}
}
- /**
- * Metodo usato per aggiornare lato client la situazione di un match (i metadati del match) in cui è situato l'utente richiedente
- * */
private void handleUpdatePlayers(Message mex){
if(this.match != null){
Match m;
@@ -355,12 +295,8 @@ private void handleUpdatePlayers(Message mex){
this.senderClient.sendToClient(mex,"UPDATE_PLAYERS",new Match());
}
}
-
- /**
- * Metodo usato dal client per entrare in un match disponibile
- * */
private void handleGetIn(Message mex){
- if(mex.getMessage() != null && mex.getMessage() instanceof String && this.player != null){
+ if(mex.getMessage() != null && mex.getMessage() instanceof String){
String nameGot = (String) mex.getMessage();
Match mm = new Match(null,nameGot,null,1);
Match m;
@@ -375,14 +311,9 @@ private void handleGetIn(Message mex){
}else{
this.senderClient.sendToClient(mex,"GET_IN");
}
- }else{
- this.senderClient.sendToClient(mex,"error");
}
}
- /**
- * Metodo usato dal client in un match in modalità tournament quando finisce il timer di 30 secondi di una domanda
- * */
public void handleEndTimer(Message mex){
this.player.setHasFinished(true);
this.player.clearQuestions();
@@ -391,77 +322,65 @@ public void handleEndTimer(Message mex){
}
- /**
- * Metodo usato nella modalità tournament per sapere se l'user richiedente deve passare alla domanda successiva o aspettare
- * */
+
public void handleUpdateNext(Message mex){
Match m;
boolean flag = false;
- if(this.match != null && this.player != null){
- synchronized (lock){
- m = this.matchesList.get(this.match);
+ synchronized (lock){
+ m = this.matchesList.get(this.match);
+ }
+ if(m != null){
+ Question q = (Question) mex.getMessage();
+ if(!this.player.score.containQuestion(q)){
+ this.player.score.addQuestion(q);
}
- if(m != null){
- Question q = (Question) mex.getMessage();
- if(!this.player.score.containQuestion(q)){
- this.player.score.addQuestion(q);
- }
- for(Player p : m.getPlayers()){
- if(!p.score.containQuestion(q)){ //Not all players have answered to the question
- flag = true;
- break;
- }
+ for(Player p : m.getPlayers()){
+ if(!p.score.containQuestion(q)){ //Not all players have answered to the question
+ flag = true;
+ break;
}
- if(flag)
- this.senderClient.sendToClient(mex,"UPDATE_NEXT","no");
- else this.senderClient.sendToClient(mex,"UPDATE_NEXT","ok");
}
- }else{
- this.senderClient.sendToClient(mex,"error");
+ if(flag)
+ this.senderClient.sendToClient(mex,"UPDATE_NEXT","no");
+ else this.senderClient.sendToClient(mex,"UPDATE_NEXT","ok");
}
}
/**
* Metodo usato per la gestione di un match di tipo practice o friendly
* */
private void handleGaming(Message mex){
- if(this.match == null){
- this.senderClient.sendToClient(mex,"error");
- }else{
+ if(!this.match.getType().equals("tournament"))
+ player.score.addQuestion((Question) mex.getMessage());
+ if(player.hasQuestion()){
+ player.setHasFinished(false);
+ Question q;
if(!this.match.getType().equals("tournament"))
- player.score.addQuestion((Question) mex.getMessage());
- if(player.hasQuestion()){
- player.setHasFinished(false);
- Question q;
- if(!this.match.getType().equals("tournament"))
- q = player.pickQuestion();
- else q = player.popQuestion();
- if(q != null){
- this.senderClient.sendToClient(mex,"game",q);
- }
- }else{
- player.score.setCompleted(true);
- switch (this.match.getType()){
- case "practice":
- this.senderClient.sendToClient(mex,"end",player.score);
- this.player.score.questions.clear();
- synchronized (lock){
- this.matchesList.remove(this.match);
- }
- this.match = null;
- break;
- default:
- this.senderClient.sendToClient(mex,"end",player.score);
- break;
- }
- player.setHasFinished(true);
+ q = player.pickQuestion();
+ else q = player.popQuestion();
+ if(q != null){
+ this.senderClient.sendToClient(mex,"game",q);
+ }
+ }else{
+ player.score.setCompleted(true);
+ switch (this.match.getType()){
+ case "practice":
+ this.senderClient.sendToClient(mex,"end",player.score);
+ this.player.score.questions.clear();
+ synchronized (lock){
+ this.matchesList.remove(this.match);
+ }
+ this.match = null;
+ break;
+ default:
+ this.senderClient.sendToClient(mex,"end",player.score);
+ break;
}
+ player.setHasFinished(true);
}
}
/**
* Metodo usato per la gestione della scelta del tipo di match da interfaccia ModeView
- * (quindi gestisce la conseguenza di aver selezionato una modalità piuttosto che
- * un'altra nel menu principale e nel caso di practice, avvia il match)
* */
private void handleStartGame(Message mex){
try{
@@ -490,9 +409,6 @@ private void handleStartGame(Message mex){
}
this.senderClient.sendToClient(mex,"list",available);
break;
- default:
- this.senderClient.sendToClient(mex,"error");
- break;
}
}catch (Exception e){
e.printStackTrace();
@@ -500,11 +416,8 @@ private void handleStartGame(Message mex){
}
- /**
- * Metodo usato dal client per avviare un match di tipo friendly o tournament da una stanza d'attesa
- * */
private void handleFriendlyStartGame(Message mex){
- if(mex.getMessage() != null && mex.getMessage() instanceof String && this.match != null){
+ if(mex.getMessage() != null && mex.getMessage() instanceof String){
Match m = new Match(null, (String) mex.getMessage(),null,1);
synchronized (lock){
this.match = this.matchesList.get(m);
@@ -523,9 +436,7 @@ private void handleFriendlyStartGame(Message mex){
}
}
- /**
- * Metodo usato per verificare se esiste già un match con un nome fornito in input dal client
- * */
+
private void handleNameChecker(Message mex){
try{
String nameMatch = (String) mex.getMessage();
@@ -536,38 +447,25 @@ private void handleNameChecker(Message mex){
}else{
this.senderClient.sendToClient(mex,"NAME_CHECKER");
}
- }else{
- this.senderClient.sendToClient(mex,"err");
}
}catch (Exception e){
e.printStackTrace();
}
}
-
- /**
- * Metodo usato per la continuazione di un match di tipo practice in precedenza sospeso
- * */
private void handleContinueGame(Message mex){
try{
- if(this.match == null || this.player == null){
- this.senderClient.sendToClient(mex, "error");
- }else{
- synchronized (lock) {
- switch (mex.getMessage().toString().toLowerCase()) {
- case "practice":
- this.matchesSaved.remove(this.match);
- this.player.score = this.match.getPlayer(mex.getOwner()).score;
- this.matchesList.add(this.match);
- this.player.questions = this.getPreviousQuestions(this.player.name, this.match);
- Question q = this.player.pickQuestion();
- if (q != null) {
- this.senderClient.sendToClient(mex, "game", q);
- }
- break;
- default:
- this.senderClient.sendToClient(mex, "error");
- break;
- }
+ synchronized (lock) {
+ switch (mex.getMessage().toString().toLowerCase()) {
+ case "practice":
+ this.matchesSaved.remove(this.match);
+ this.player.score = this.match.getPlayer(mex.getOwner()).score;
+ this.matchesList.add(this.match);
+ this.player.questions = this.getPreviousQuestions(this.player.name, this.match);
+ Question q = this.player.pickQuestion();
+ if (q != null) {
+ this.senderClient.sendToClient(mex, "game", q);
+ }
+ break;
}
}
}catch (Exception e){
@@ -579,7 +477,7 @@ private void handleContinueGame(Message mex){
/**
* Metodo usato per la rimozione di un match salvato e non terminato
* */
- private void handleRemove(){
+ private void handleRemove(Message mex){
synchronized (lock){
this.matchesSaved.remove(this.match);
this.match = null;
@@ -589,7 +487,7 @@ private void handleRemove(){
/**
* Metodo usato per gestire la chiusura di una connessione con client
* */
- private void handleClosing(Message mex){
+ private void handleClosing(Message mex, Object lock){
System.out.println("Closing the connection");
synchronized (lock){
if(mex.getMessage() != null && this.match != null && this.match.getType().equals("practice")){//It happens only if I'm in practice and I haven't ended the match
@@ -600,7 +498,9 @@ private void handleClosing(Message mex){
matchesSaved.add(this.match);//TODO: E SE IL MATCH FOSSE FRIENDLY O TOURNAMENT COME LO TRATTO?
}else{
if(this.match != null && this.match.getType().equals("practice")){ //It should not enter here since match couldn't be evaluated to something and at the same thing not entering on the previous branch of the if
- this.matchesList.remove(this.match);
+ synchronized (lock){
+ this.matchesList.remove(this.match);
+ }
}
}
}
@@ -609,7 +509,7 @@ private void handleClosing(Message mex){
for(Iterator it = this.matchesList.getMemory().iterator();it.hasNext();){
Match m = it.next();
if((m.getType().equals("friendly") || m.getType().equals("tournament")) && m.containsUser(this.player)){
- if(this.player != null && this.player.equals(m.getHost())){
+ if(this.player.equals(m.getHost())){
hostDeleted = true;
}
m.removePlayer(this.player);
@@ -636,29 +536,25 @@ private void handleClosing(Message mex){
}
/**
- * Metodo usato per la creazione di match di tipo friendly o tournament
+ * Metodo usato per la creazione di match di tipo friendly or tournament
* */
private void handleCreate(Message mex){
try{
if(mex.getMessage() instanceof String){
String[] splitted = ((String) mex.getMessage()).split(":");
- if(splitted.length != 5){
- this.senderClient.sendToClient(mex,"error");
- }else{
- String name = splitted[0];
- int size = Integer.parseInt(splitted[1]);
- int time = Integer.parseInt(splitted[2]);
- int nQuestions = Integer.parseInt(splitted[3]);
- String type = splitted[4];
- synchronized (lock){
- this.match = new Match(type, name, this.player, size,time,nQuestions);
- this.player.setReady(false);
- this.match.addPlayer(this.player);
- this.match.setAvailable(true);
- this.matchesList.add(this.match);
- }
- this.senderClient.sendToClient(mex,"create",this.match);
+ String name = splitted[0];
+ int size = Integer.parseInt(splitted[1]);
+ int time = Integer.parseInt(splitted[2]);
+ int nQuestions = Integer.parseInt(splitted[3]);
+ String type = splitted[4];
+ synchronized (lock){
+ this.match = new Match(type, name, this.player, size,time,nQuestions);
+ this.player.setReady(false);
+ this.match.addPlayer(this.player);
+ this.match.setAvailable(true);
+ this.matchesList.add(this.match);
}
+ this.senderClient.sendToClient(mex,"create",this.match);
}
}catch (Exception e){
e.printStackTrace();
@@ -669,19 +565,15 @@ private void handleCreate(Message mex){
* Metodo usato per la rimozione di un match in corso o in attesa di essere avviato
* */
private void handleRemover(Message mex){
- if(this.match != null){
- synchronized (lock){
- this.matchesList.remove(this.match);
- this.match = null;
- }
- this.senderClient.sendToClient(mex,"MATCH_REMOVER","ok");
- }else{
- this.senderClient.sendToClient(mex,"error");
+ synchronized (lock){
+ this.matchesList.remove(this.match);
}
+ this.match = null;
+ this.senderClient.sendToClient(mex,"MATCH_REMOVER","ok");
}
/**
- * Metodo usato per controllare se ci sono match di tipo practice in precedenza non terminati del mio player
+ * Metodo usato per controllare se ci sono match in precedenza non terminati del mio player
* */
private synchronized Match checkPreviousMatches(){
synchronized (lock){
@@ -694,9 +586,6 @@ private synchronized Match checkPreviousMatches(){
return null;
}
- /**
- * Metodo usato per prelevare le domande rimanenti di un utente dato un match ed il nome del player
- * */
private ArrayList getPreviousQuestions(String name, Match m){
synchronized (lock){
Player p = m.getPlayer(name);
diff --git a/server/src/main/java/org/example/interfaces/Messages.java b/src/main/java/org/example/interfaces/Messages.java
similarity index 100%
rename from server/src/main/java/org/example/interfaces/Messages.java
rename to src/main/java/org/example/interfaces/Messages.java
diff --git a/server/src/main/java/org/example/interfaces/Registries.java b/src/main/java/org/example/interfaces/Registries.java
similarity index 100%
rename from server/src/main/java/org/example/interfaces/Registries.java
rename to src/main/java/org/example/interfaces/Registries.java
diff --git a/server/src/main/java/org/example/interfaces/Senders.java b/src/main/java/org/example/interfaces/Senders.java
similarity index 100%
rename from server/src/main/java/org/example/interfaces/Senders.java
rename to src/main/java/org/example/interfaces/Senders.java
diff --git a/server/src/main/java/org/example/model/Match.java b/src/main/java/org/example/model/Match.java
similarity index 100%
rename from server/src/main/java/org/example/model/Match.java
rename to src/main/java/org/example/model/Match.java
diff --git a/server/src/main/java/org/example/model/MatchChecker.java b/src/main/java/org/example/model/MatchChecker.java
similarity index 100%
rename from server/src/main/java/org/example/model/MatchChecker.java
rename to src/main/java/org/example/model/MatchChecker.java
diff --git a/server/src/main/java/org/example/model/Memory.java b/src/main/java/org/example/model/Memory.java
similarity index 100%
rename from server/src/main/java/org/example/model/Memory.java
rename to src/main/java/org/example/model/Memory.java
diff --git a/server/src/main/java/org/example/model/Message.java b/src/main/java/org/example/model/Message.java
similarity index 100%
rename from server/src/main/java/org/example/model/Message.java
rename to src/main/java/org/example/model/Message.java
diff --git a/server/src/main/java/org/example/model/Player.java b/src/main/java/org/example/model/Player.java
similarity index 100%
rename from server/src/main/java/org/example/model/Player.java
rename to src/main/java/org/example/model/Player.java
diff --git a/server/src/main/java/org/example/model/Question.java b/src/main/java/org/example/model/Question.java
similarity index 100%
rename from server/src/main/java/org/example/model/Question.java
rename to src/main/java/org/example/model/Question.java
diff --git a/server/src/main/java/org/example/model/QuestionOwner.java b/src/main/java/org/example/model/QuestionOwner.java
similarity index 100%
rename from server/src/main/java/org/example/model/QuestionOwner.java
rename to src/main/java/org/example/model/QuestionOwner.java
diff --git a/server/src/main/java/org/example/model/Rank.java b/src/main/java/org/example/model/Rank.java
similarity index 95%
rename from server/src/main/java/org/example/model/Rank.java
rename to src/main/java/org/example/model/Rank.java
index 772245a..ed0faf5 100644
--- a/server/src/main/java/org/example/model/Rank.java
+++ b/src/main/java/org/example/model/Rank.java
@@ -25,8 +25,7 @@ public void addHalf(){
}
public void set(float points){
- if(points >= 0)
- this.points = points;
+ this.points = points;
}
@Override
diff --git a/server/src/main/java/org/example/model/Score.java b/src/main/java/org/example/model/Score.java
similarity index 100%
rename from server/src/main/java/org/example/model/Score.java
rename to src/main/java/org/example/model/Score.java
diff --git a/server/src/main/java/org/example/utils/SenderClient.java b/src/main/java/org/example/utils/SenderClient.java
similarity index 100%
rename from server/src/main/java/org/example/utils/SenderClient.java
rename to src/main/java/org/example/utils/SenderClient.java
diff --git a/server/src/main/java/org/example/utils/Utility.java b/src/main/java/org/example/utils/Utility.java
similarity index 90%
rename from server/src/main/java/org/example/utils/Utility.java
rename to src/main/java/org/example/utils/Utility.java
index cf3da62..4e393a6 100644
--- a/server/src/main/java/org/example/utils/Utility.java
+++ b/src/main/java/org/example/utils/Utility.java
@@ -4,7 +4,6 @@
import org.example.model.Question;
import java.io.File;
-import java.nio.charset.StandardCharsets;
import java.util.*;
public abstract class Utility {
@@ -15,7 +14,7 @@ public static synchronized void readQuestionsFromFile(String QUESTION_FILE, Play
File questionFile = new File(QUESTION_FILE);
try{
player.clearQuestions();
- Scanner scan = new Scanner(questionFile, StandardCharsets.UTF_8);
+ Scanner scan = new Scanner(questionFile);
ArrayList quest = new ArrayList<>();
while(scan.hasNextLine()){
String[] line = scan.nextLine().split(";");
@@ -34,7 +33,7 @@ public static synchronized ArrayList readQuestionsFromFile(String QUESTI
File questionFile = new File(QUESTION_FILE);
ArrayList questions = new ArrayList<>();
try{
- Scanner scan = new Scanner(questionFile, StandardCharsets.UTF_8);
+ Scanner scan = new Scanner(questionFile);
while(scan.hasNextLine()){
String[] line = scan.nextLine().split(";");
Question q = new Question(line[0],line[1],line[2],line[3],line[4],line[5]);
diff --git a/src/test/java/MatchChecker.java b/src/test/java/MatchChecker.java
new file mode 100644
index 0000000..31712fc
--- /dev/null
+++ b/src/test/java/MatchChecker.java
@@ -0,0 +1,2 @@
+public class MatchChecker {
+}
diff --git a/server/src/test/java/MatchTest.java b/src/test/java/MatchTest.java
similarity index 100%
rename from server/src/test/java/MatchTest.java
rename to src/test/java/MatchTest.java
diff --git a/server/src/test/java/MemoryTest.java b/src/test/java/MemoryTest.java
similarity index 100%
rename from server/src/test/java/MemoryTest.java
rename to src/test/java/MemoryTest.java
diff --git a/server/src/test/java/MessageTest.java b/src/test/java/MessageTest.java
similarity index 100%
rename from server/src/test/java/MessageTest.java
rename to src/test/java/MessageTest.java
diff --git a/server/src/test/java/PlayerQuestionTest.java b/src/test/java/PlayerQuestionTest.java
similarity index 100%
rename from server/src/test/java/PlayerQuestionTest.java
rename to src/test/java/PlayerQuestionTest.java
diff --git a/server/src/test/java/QuestionOwnerTest.java b/src/test/java/QuestionOwnerTest.java
similarity index 100%
rename from server/src/test/java/QuestionOwnerTest.java
rename to src/test/java/QuestionOwnerTest.java
diff --git a/server/src/test/java/QuestionTest.java b/src/test/java/QuestionTest.java
similarity index 100%
rename from server/src/test/java/QuestionTest.java
rename to src/test/java/QuestionTest.java
diff --git a/server/src/test/java/RankTest.java b/src/test/java/RankTest.java
similarity index 85%
rename from server/src/test/java/RankTest.java
rename to src/test/java/RankTest.java
index 4695d34..e870f10 100644
--- a/server/src/test/java/RankTest.java
+++ b/src/test/java/RankTest.java
@@ -8,7 +8,6 @@ public class RankTest {
public void test(){
Rank r1 = new Rank("fra");
Rank r2 = new Rank("bru",10);
- Rank r3 = new Rank("fra");
Assertions.assertAll(
()->Assertions.assertEquals(0, r1.points),
()->Assertions.assertEquals(10, r2.points),
@@ -21,15 +20,11 @@ public void test(){
Assertions.assertEquals(1.5f, r1.points);
r1.set(4);
Assertions.assertEquals(4, r1.points);
- r1.set(-1);
- Assertions.assertEquals(4, r1.points);
Assertions.assertEquals(1, r2.compareTo(r1));
Assertions.assertNotEquals(0, r2.compareTo(r1));
Assertions.assertNotEquals(-1, r2.compareTo(r1));
Assertions.assertEquals(-1, r1.compareTo(r2));
Assertions.assertNotEquals(0, r1.compareTo(r2));
Assertions.assertNotEquals(1, r1.compareTo(r2));
- Assertions.assertNotEquals(r1,r2);
- Assertions.assertEquals(r1,r3);
}
}
diff --git a/server/src/test/java/ScoreTest.java b/src/test/java/ScoreTest.java
similarity index 100%
rename from server/src/test/java/ScoreTest.java
rename to src/test/java/ScoreTest.java
diff --git a/src/test/java/SenderClientTest.java b/src/test/java/SenderClientTest.java
new file mode 100644
index 0000000..2b295b3
--- /dev/null
+++ b/src/test/java/SenderClientTest.java
@@ -0,0 +1,3 @@
+public class SenderClientTest {
+
+}
diff --git a/src/test/java/UtilityTest.java b/src/test/java/UtilityTest.java
new file mode 100644
index 0000000..a91816c
--- /dev/null
+++ b/src/test/java/UtilityTest.java
@@ -0,0 +1,2 @@
+public class UtilityTest {
+}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy