diff --git a/README.md b/README.md
index b6b06bc..753d5f8 100644
--- a/README.md
+++ b/README.md
@@ -1,87 +1,131 @@
# Java Examples Collection
-> Designed for the AUEB CS BSc Java Course
->> https://eclass.aueb.gr/courses/INF176/
+Designed for the AUEB CS BSc Java Course:
+https://eclass.aueb.gr/courses/INF176/
-This repository contains a collection of Java programming examples used for teaching core object-oriented programming (OOP) concepts in an engaging and applied way. Each example is organized as a separate package/module, and includes working code, documentation, and console interaction.
+This repository contains small, runnable Java examples and course projects used
+to teach core programming and object-oriented programming concepts. Topic-based
+examples live under `gr/aueb/cs/examples`, while larger mini-projects live under
+`gr/aueb/cs/projects`.
-## 📁 Project Structure
+## Project Structure
-Each top-level package contains a complete, runnable Java example:
+### `gr/aueb/cs/examples/introduction`
----
+Introductory Java examples covering variables, control flow, simple classes, and
+basic simulation.
-### 🎲 `montyhall/`
+### `gr/aueb/cs/examples/strings`
-A full implementation of the Monty Hall game:
+Examples for working with Java strings and common string operations.
-- OOP structure (`Door`, `MontyHallGame`, `Strategy`)
-- Interactive version (console-based)
-- Simulator to run thousands of trials
-- Visual comparison of strategies (switch vs stay)
+### `gr/aueb/cs/examples/inheritance`
-➡️ Teaches: classes, interfaces, composition, simulations, user interaction
+Examples for inheritance, `final`, dynamic binding, and polymorphism.
----
+### `gr/aueb/cs/examples/abstraction`
-### 🚶 `walkroutes/`
+Examples for abstract classes and salary-based employee models.
-A pedestrian routing system on a city grid:
+### `gr/aueb/cs/examples/interfaces`
-- Location graph representation
-- Obstacle-aware pathfinding
-- Modular packages: `model`, `routing`, `map`, `simulation`
+Small demonstrations of interfaces and interface-based design.
-➡️ Teaches: graphs, modular design, file input, BFS-style logic
+### `gr/aueb/cs/examples/collections`
----
+Examples using Java collections such as lists, queues, iterators, and traversal
+patterns.
-### 🎯 `demo/`
+### `gr/aueb/cs/examples/generics`
-Demonstrates the difference between:
+Examples for generic classes, generic methods, bounded type parameters,
+comparators, sorting, and type erasure.
-- `Math.random()` (static, simple, no seed)
-- `Random` class (object-based, supports seeding)
-- Repeatable pseudo-randomness
+### `gr/aueb/cs/examples/exceptions`
-➡️ Teaches: randomness, testing, debugging with seeded values
+Examples for exception handling, throwing exceptions, and safer error handling.
----
+### `gr/aueb/cs/examples/files`
-### 🏨 `hotelbooking/` *(optional extension)*
+Examples for reading and writing files, UTF-8 text, URLs, and CSV-style input.
-Simulates a basic hotel booking system with multiple room types.
+### `gr/aueb/cs/examples/unit`
-➡️ Teaches: inheritance, encapsulation, polymorphism
+A small calculator example with a matching unit test.
----
+### `gr/aueb/cs/examples/profiling`
-### 🎬 `movies/` *(optional extension)*
+Simple performance and profiling examples comparing data structures, primitive
+types, wrapper types, and buffer capacity choices.
-Loads movie reviews from a file and filters recommendations by genre, rating, or sentiment.
+### `gr/aueb/cs/examples/graphics`
-➡️ Teaches: file I/O, `ArrayList`, filtering, basic NLP
+Graphical Java examples, including a tag cloud visualization.
----
+### `gr/aueb/cs/examples/sound`
-## 🧪 How to Run
+Audio-related examples, including a simple alarm demo.
-Use the terminal or your favorite IDE (e.g., IntelliJ, Eclipse):
+### `gr/aueb/cs/examples/review`
+
+Review examples for dynamic dispatch, constructors, exceptions, anonymous
+classes, and randomness.
+
+### `gr/aueb/cs/projects`
+
+Larger examples and student-friendly mini-projects:
+
+- `montyhall`: Monty Hall game logic, strategies, console UI, and simulation.
+- `walkroute`: Walking route demos using linked structures, search, and agents.
+- `captcha`: A simple CAPTCHA generator and checker.
+- `javagotchi`: A virtual pet project.
+- `javagotchiWeb`: A Spring Boot web version of the Javagotchi project.
+
+## How to Run
+
+From the repository root, compile and run a single class by using its package
+path. For example:
```bash
-# Compile from src root
-javac montyhall/app/Main.java
-java montyhall.app.Main
+javac gr/aueb/cs/examples/introduction/Variables.java
+java gr.aueb.cs.examples.introduction.Variables
+```
+
+Another example:
+
+```bash
+javac gr/aueb/cs/examples/inheritance/Polymorphism.java
+java gr.aueb.cs.examples.inheritance.Polymorphism
+```
-# Or run another example
-javac demo/RandomComparison.java
-java demo.RandomComparison
+For examples that define multiple classes in the same package, compile the
+source file and then run the public class:
+
+```bash
+javac gr/aueb/cs/examples/interfaces/Demo.java
+java gr.aueb.cs.examples.interfaces.Demo
+```
+
+The Spring Boot project has its own README:
+
+```text
+gr/aueb/cs/projects/javagotchiWeb/README.md
+```
+
+## Running Tests
+
+The `gr/aueb/cs/examples/unit` package contains small JUnit 5 tests for the
+calculator example. Run them from the repository root with:
+
+```bash
+mvn test
```
-## ✏️ Contribution
+## Contributing
-To contribute to this repo, [this cheatsheet](/git_cheatsheet.md) may help with the first steps.
+To contribute to this repository, the [Git cheatsheet](git_cheatsheet.md) may
+help with the first steps.
-## 📄 License
+## License
This project is licensed under the [MIT License](LICENSE).
diff --git a/gr/aueb/cs/abstraction/Employee.java b/gr/aueb/cs/examples/abstraction/Employee.java
similarity index 95%
rename from gr/aueb/cs/abstraction/Employee.java
rename to gr/aueb/cs/examples/abstraction/Employee.java
index fee53b8..10adf2e 100644
--- a/gr/aueb/cs/abstraction/Employee.java
+++ b/gr/aueb/cs/examples/abstraction/Employee.java
@@ -1,5 +1,5 @@
-package gr.aueb.cs.abstraction;
+package gr.aueb.cs.examples.abstraction;
public abstract class Employee {
private String firstName;
diff --git a/gr/aueb/cs/abstraction/JuniorSalariedEmployee.java b/gr/aueb/cs/examples/abstraction/JuniorSalariedEmployee.java
similarity index 85%
rename from gr/aueb/cs/abstraction/JuniorSalariedEmployee.java
rename to gr/aueb/cs/examples/abstraction/JuniorSalariedEmployee.java
index c93cdb0..9a189fc 100644
--- a/gr/aueb/cs/abstraction/JuniorSalariedEmployee.java
+++ b/gr/aueb/cs/examples/abstraction/JuniorSalariedEmployee.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.abstraction;
+package gr.aueb.cs.examples.abstraction;
abstract public class JuniorSalariedEmployee extends SalariedEmployee {
diff --git a/gr/aueb/cs/abstraction/SalariedEmployee.java b/gr/aueb/cs/examples/abstraction/SalariedEmployee.java
similarity index 95%
rename from gr/aueb/cs/abstraction/SalariedEmployee.java
rename to gr/aueb/cs/examples/abstraction/SalariedEmployee.java
index 21a3a63..f0ee879 100644
--- a/gr/aueb/cs/abstraction/SalariedEmployee.java
+++ b/gr/aueb/cs/examples/abstraction/SalariedEmployee.java
@@ -1,5 +1,5 @@
-package gr.aueb.cs.abstraction;
+package gr.aueb.cs.examples.abstraction;
public class SalariedEmployee extends Employee {
private double weeklySalary;
diff --git a/gr/aueb/cs/collections/CollectionTest.java b/gr/aueb/cs/examples/collections/CollectionTest.java
similarity index 98%
rename from gr/aueb/cs/collections/CollectionTest.java
rename to gr/aueb/cs/examples/collections/CollectionTest.java
index bbe78ea..3be038a 100644
--- a/gr/aueb/cs/collections/CollectionTest.java
+++ b/gr/aueb/cs/examples/collections/CollectionTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.collections;
+package gr.aueb.cs.examples.collections;
// // Based on the example in the book of Deitel (pp 834, 9th edition)
// https://github.com/pdeitel/JavaHowToProgram11e_EarlyObjects/blob/7bf604beb846d3bb99b52d8b330da5e354a0224a/examples/ch16/fig16_02/CollectionTest.java
// Collection interface demonstrated via an ArrayList object.
diff --git a/gr/aueb/cs/collections/IndexTraversalError.java b/gr/aueb/cs/examples/collections/IndexTraversalError.java
similarity index 93%
rename from gr/aueb/cs/collections/IndexTraversalError.java
rename to gr/aueb/cs/examples/collections/IndexTraversalError.java
index 1eaaa02..f344677 100644
--- a/gr/aueb/cs/collections/IndexTraversalError.java
+++ b/gr/aueb/cs/examples/collections/IndexTraversalError.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.collections;
+package gr.aueb.cs.examples.collections;
import java.util.*;
diff --git a/gr/aueb/cs/collections/IteratorTraversalSafe.java b/gr/aueb/cs/examples/collections/IteratorTraversalSafe.java
similarity index 93%
rename from gr/aueb/cs/collections/IteratorTraversalSafe.java
rename to gr/aueb/cs/examples/collections/IteratorTraversalSafe.java
index 4391964..b5e6850 100644
--- a/gr/aueb/cs/collections/IteratorTraversalSafe.java
+++ b/gr/aueb/cs/examples/collections/IteratorTraversalSafe.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.collections;
+package gr.aueb.cs.examples.collections;
import java.util.ArrayList;
import java.util.Iterator;
diff --git a/gr/aueb/cs/collections/ListTest.java b/gr/aueb/cs/examples/collections/ListTest.java
similarity index 99%
rename from gr/aueb/cs/collections/ListTest.java
rename to gr/aueb/cs/examples/collections/ListTest.java
index e47d7bf..fb6c12b 100644
--- a/gr/aueb/cs/collections/ListTest.java
+++ b/gr/aueb/cs/examples/collections/ListTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.collections;
+package gr.aueb.cs.examples.collections;
// Working on the example of Deitel (pp 837, 9th edition)
// re. Lists, LinkedLists and ListIterators.
diff --git a/gr/aueb/cs/collections/PriorityQueueTest.java b/gr/aueb/cs/examples/collections/PriorityQueueTest.java
similarity index 96%
rename from gr/aueb/cs/collections/PriorityQueueTest.java
rename to gr/aueb/cs/examples/collections/PriorityQueueTest.java
index 2f27f25..2d4f1ef 100644
--- a/gr/aueb/cs/collections/PriorityQueueTest.java
+++ b/gr/aueb/cs/examples/collections/PriorityQueueTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.collections;
+package gr.aueb.cs.examples.collections;
import java.util.Comparator;
import java.util.PriorityQueue;
diff --git a/gr/aueb/cs/exceptions/DivideByZeroSafely.java b/gr/aueb/cs/examples/exceptions/DivideByZeroSafely.java
similarity index 96%
rename from gr/aueb/cs/exceptions/DivideByZeroSafely.java
rename to gr/aueb/cs/examples/exceptions/DivideByZeroSafely.java
index 7182ed9..f10d6bf 100644
--- a/gr/aueb/cs/exceptions/DivideByZeroSafely.java
+++ b/gr/aueb/cs/examples/exceptions/DivideByZeroSafely.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.exceptions;
+package gr.aueb.cs.examples.exceptions;
import java.util.InputMismatchException;
diff --git a/gr/aueb/cs/exceptions/DivideByZeroWithoutExceptionHandling.java b/gr/aueb/cs/examples/exceptions/DivideByZeroWithoutExceptionHandling.java
similarity index 95%
rename from gr/aueb/cs/exceptions/DivideByZeroWithoutExceptionHandling.java
rename to gr/aueb/cs/examples/exceptions/DivideByZeroWithoutExceptionHandling.java
index c98431b..d35559e 100644
--- a/gr/aueb/cs/exceptions/DivideByZeroWithoutExceptionHandling.java
+++ b/gr/aueb/cs/examples/exceptions/DivideByZeroWithoutExceptionHandling.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.exceptions;
+package gr.aueb.cs.examples.exceptions;
import java.util.Scanner;
diff --git a/gr/aueb/cs/examples/exceptions/ThrowTest.java b/gr/aueb/cs/examples/exceptions/ThrowTest.java
new file mode 100644
index 0000000..d133bdc
--- /dev/null
+++ b/gr/aueb/cs/examples/exceptions/ThrowTest.java
@@ -0,0 +1,11 @@
+package gr.aueb.cs.examples.exceptions;
+
+public class ThrowTest {
+ public static void main(String[] args) {
+ try {
+ throw new RuntimeException("Σφάλμα!");
+ } catch (RuntimeException e) {
+ System.out.println("Πιάστηκε εξαίρεση: " + e.getMessage());
+ }
+ }
+}
diff --git a/gr/aueb/cs/files/GreekReaderUTF8.java b/gr/aueb/cs/examples/files/GreekReaderUTF8.java
similarity index 75%
rename from gr/aueb/cs/files/GreekReaderUTF8.java
rename to gr/aueb/cs/examples/files/GreekReaderUTF8.java
index 0cff959..c25cd23 100644
--- a/gr/aueb/cs/files/GreekReaderUTF8.java
+++ b/gr/aueb/cs/examples/files/GreekReaderUTF8.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.files;
+package gr.aueb.cs.examples.files;
import java.io.*;
@@ -8,7 +8,7 @@ public static void main(String[] args) throws IOException {
// δεν είναι ασφαλές για UTF-8.
BufferedReader reader = new BufferedReader(
new InputStreamReader(
- new FileInputStream("greek.txt"), "UTF-8" // δοκιμάστε "ISO-8859-7" για πείραμα
+ new FileInputStream("gr/aueb/cs/examples/files/greek.txt"), "UTF-8" // δοκιμάστε "ISO-8859-7" για πείραμα
)
);
@@ -19,4 +19,4 @@ public static void main(String[] args) throws IOException {
reader.close();
}
-}
\ No newline at end of file
+}
diff --git a/gr/aueb/cs/files/GreekWriterUTF8.java b/gr/aueb/cs/examples/files/GreekWriterUTF8.java
similarity index 68%
rename from gr/aueb/cs/files/GreekWriterUTF8.java
rename to gr/aueb/cs/examples/files/GreekWriterUTF8.java
index 50fac0d..6a9abaf 100644
--- a/gr/aueb/cs/files/GreekWriterUTF8.java
+++ b/gr/aueb/cs/examples/files/GreekWriterUTF8.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.files;
+package gr.aueb.cs.examples.files;
import java.io.*;
@@ -7,7 +7,7 @@ public static void main(String[] args) throws IOException {
// Δημιουργία Writer με ρητή κωδικοποίηση UTF-8
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(
- new FileOutputStream("greek.txt"), "UTF-8"
+ new FileOutputStream("gr/aueb/cs/examples/files/greek.txt"), "UTF-8"
)
);
@@ -18,6 +18,6 @@ public static void main(String[] args) throws IOException {
writer.write("Αυτό είναι δοκιμαστικό αρχείο σε UTF-8.");
writer.close();
- System.out.println("Το αρχείο greek.txt γράφτηκε με επιτυχία σε UTF-8.");
+ System.out.println("Το αρχείο gr/aueb/cs/examples/files/greek.txt γράφτηκε με επιτυχία σε UTF-8.");
}
}
diff --git a/gr/aueb/cs/files/LibraryReader.java b/gr/aueb/cs/examples/files/LibraryReader.java
similarity index 92%
rename from gr/aueb/cs/files/LibraryReader.java
rename to gr/aueb/cs/examples/files/LibraryReader.java
index 09bd0ee..1517639 100644
--- a/gr/aueb/cs/files/LibraryReader.java
+++ b/gr/aueb/cs/examples/files/LibraryReader.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.files;
+package gr.aueb.cs.examples.files;
import org.w3c.dom.*;
import javax.xml.parsers.*;
@@ -7,7 +7,7 @@
public class LibraryReader {
public static void main(String[] args) throws Exception {
// Βήμα 1: Φόρτωση και parsing του XML
- File xmlFile = new File("library.xml");
+ File xmlFile = new File("gr/aueb/cs/examples/files/library.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(xmlFile);
diff --git a/gr/aueb/cs/files/RepresentationsTest.java b/gr/aueb/cs/examples/files/RepresentationsTest.java
similarity index 97%
rename from gr/aueb/cs/files/RepresentationsTest.java
rename to gr/aueb/cs/examples/files/RepresentationsTest.java
index 07c3846..dcbfc69 100644
--- a/gr/aueb/cs/files/RepresentationsTest.java
+++ b/gr/aueb/cs/examples/files/RepresentationsTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.files;
+package gr.aueb.cs.examples.files;
public class RepresentationsTest {
diff --git a/gr/aueb/cs/files/URLReader.java b/gr/aueb/cs/examples/files/URLReader.java
similarity index 96%
rename from gr/aueb/cs/files/URLReader.java
rename to gr/aueb/cs/examples/files/URLReader.java
index 8bc8711..f8b0abb 100644
--- a/gr/aueb/cs/files/URLReader.java
+++ b/gr/aueb/cs/examples/files/URLReader.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.files;
+package gr.aueb.cs.examples.files;
import java.net.URL;
import java.io.BufferedReader;
diff --git a/gr/aueb/cs/examples/files/greek.txt b/gr/aueb/cs/examples/files/greek.txt
new file mode 100644
index 0000000..2509f23
--- /dev/null
+++ b/gr/aueb/cs/examples/files/greek.txt
@@ -0,0 +1,3 @@
+Καλημέρα
+Πώς είσαι;
+Αυτό είναι δοκιμαστικό αρχείο σε UTF-8.
\ No newline at end of file
diff --git a/gr/aueb/cs/examples/files/library.xml b/gr/aueb/cs/examples/files/library.xml
new file mode 100644
index 0000000..7ed40ca
--- /dev/null
+++ b/gr/aueb/cs/examples/files/library.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/gr/aueb/cs/files/reviews.csv b/gr/aueb/cs/examples/files/reviews.csv
similarity index 100%
rename from gr/aueb/cs/files/reviews.csv
rename to gr/aueb/cs/examples/files/reviews.csv
diff --git a/gr/aueb/cs/generics/BoundedTypeParamsTest.java b/gr/aueb/cs/examples/generics/BoundedTypeParamsTest.java
similarity index 93%
rename from gr/aueb/cs/generics/BoundedTypeParamsTest.java
rename to gr/aueb/cs/examples/generics/BoundedTypeParamsTest.java
index 344b704..003db3b 100644
--- a/gr/aueb/cs/generics/BoundedTypeParamsTest.java
+++ b/gr/aueb/cs/examples/generics/BoundedTypeParamsTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.generics;
+package gr.aueb.cs.examples.generics;
public class BoundedTypeParamsTest {
public static void main(String[] args) {
diff --git a/gr/aueb/cs/generics/GenericMethodTest.java b/gr/aueb/cs/examples/generics/GenericMethodTest.java
similarity index 94%
rename from gr/aueb/cs/generics/GenericMethodTest.java
rename to gr/aueb/cs/examples/generics/GenericMethodTest.java
index 4ad7b3c..86f78ea 100644
--- a/gr/aueb/cs/generics/GenericMethodTest.java
+++ b/gr/aueb/cs/examples/generics/GenericMethodTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.generics;
+package gr.aueb.cs.examples.generics;
public class GenericMethodTest {
public static void main(String[] args) {
diff --git a/gr/aueb/cs/generics/GenericsTest.java b/gr/aueb/cs/examples/generics/GenericsTest.java
similarity index 96%
rename from gr/aueb/cs/generics/GenericsTest.java
rename to gr/aueb/cs/examples/generics/GenericsTest.java
index e618774..4fc52bb 100644
--- a/gr/aueb/cs/generics/GenericsTest.java
+++ b/gr/aueb/cs/examples/generics/GenericsTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.generics;
+package gr.aueb.cs.examples.generics;
import java.util.ArrayList;
diff --git a/gr/aueb/cs/generics/StudentSortingComparatorDemo.java b/gr/aueb/cs/examples/generics/StudentSortingComparatorDemo.java
similarity index 98%
rename from gr/aueb/cs/generics/StudentSortingComparatorDemo.java
rename to gr/aueb/cs/examples/generics/StudentSortingComparatorDemo.java
index 1f8c083..ac9026e 100644
--- a/gr/aueb/cs/generics/StudentSortingComparatorDemo.java
+++ b/gr/aueb/cs/examples/generics/StudentSortingComparatorDemo.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.generics;
+package gr.aueb.cs.examples.generics;
import java.util.*;
diff --git a/gr/aueb/cs/generics/TypeErasureTest.java b/gr/aueb/cs/examples/generics/TypeErasureTest.java
similarity index 88%
rename from gr/aueb/cs/generics/TypeErasureTest.java
rename to gr/aueb/cs/examples/generics/TypeErasureTest.java
index bb7e246..5ad9382 100644
--- a/gr/aueb/cs/generics/TypeErasureTest.java
+++ b/gr/aueb/cs/examples/generics/TypeErasureTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.generics;
+package gr.aueb.cs.examples.generics;
import java.util.ArrayList;
import java.util.List;
diff --git a/gr/aueb/cs/graphics/JavaTagCloud.java b/gr/aueb/cs/examples/graphics/JavaTagCloud.java
similarity index 99%
rename from gr/aueb/cs/graphics/JavaTagCloud.java
rename to gr/aueb/cs/examples/graphics/JavaTagCloud.java
index 37cd3ed..23e2f68 100644
--- a/gr/aueb/cs/graphics/JavaTagCloud.java
+++ b/gr/aueb/cs/examples/graphics/JavaTagCloud.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.graphics;
+package gr.aueb.cs.examples.graphics;
import java.awt.*;
import java.awt.geom.AffineTransform;
diff --git a/gr/aueb/cs/inheritance/DynamicBinding.java b/gr/aueb/cs/examples/inheritance/DynamicBinding.java
similarity index 93%
rename from gr/aueb/cs/inheritance/DynamicBinding.java
rename to gr/aueb/cs/examples/inheritance/DynamicBinding.java
index 4d378f1..da32376 100644
--- a/gr/aueb/cs/inheritance/DynamicBinding.java
+++ b/gr/aueb/cs/examples/inheritance/DynamicBinding.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.inheritance;
+package gr.aueb.cs.examples.inheritance;
class Sup {
void who() { System.out.println("who() in Sup"); }
diff --git a/gr/aueb/cs/inheritance/Final.java b/gr/aueb/cs/examples/inheritance/Final.java
similarity index 92%
rename from gr/aueb/cs/inheritance/Final.java
rename to gr/aueb/cs/examples/inheritance/Final.java
index 256ea50..18a56b0 100644
--- a/gr/aueb/cs/inheritance/Final.java
+++ b/gr/aueb/cs/examples/inheritance/Final.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.inheritance;
+package gr.aueb.cs.examples.inheritance;
public class Final {
public static void main(String[] args) {
diff --git a/gr/aueb/cs/inheritance/Polymorphism.java b/gr/aueb/cs/examples/inheritance/Polymorphism.java
similarity index 94%
rename from gr/aueb/cs/inheritance/Polymorphism.java
rename to gr/aueb/cs/examples/inheritance/Polymorphism.java
index dd28a49..4d9a111 100644
--- a/gr/aueb/cs/inheritance/Polymorphism.java
+++ b/gr/aueb/cs/examples/inheritance/Polymorphism.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.inheritance;
+package gr.aueb.cs.examples.inheritance;
class X {
int a;
diff --git a/gr/aueb/cs/interfaces/Demo.java b/gr/aueb/cs/examples/interfaces/Demo.java
similarity index 95%
rename from gr/aueb/cs/interfaces/Demo.java
rename to gr/aueb/cs/examples/interfaces/Demo.java
index e7223c5..97f9c86 100644
--- a/gr/aueb/cs/interfaces/Demo.java
+++ b/gr/aueb/cs/examples/interfaces/Demo.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.interfaces;
+package gr.aueb.cs.examples.interfaces;
interface Testable {
void test();
diff --git a/gr/aueb/cs/introduction/BreakAndContinue.java b/gr/aueb/cs/examples/introduction/BreakAndContinue.java
similarity index 95%
rename from gr/aueb/cs/introduction/BreakAndContinue.java
rename to gr/aueb/cs/examples/introduction/BreakAndContinue.java
index c890cf0..707062b 100644
--- a/gr/aueb/cs/introduction/BreakAndContinue.java
+++ b/gr/aueb/cs/examples/introduction/BreakAndContinue.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.introduction;
+package gr.aueb.cs.examples.introduction;
public class BreakAndContinue {
diff --git a/gr/aueb/cs/introduction/Human.java b/gr/aueb/cs/examples/introduction/Human.java
similarity index 95%
rename from gr/aueb/cs/introduction/Human.java
rename to gr/aueb/cs/examples/introduction/Human.java
index ceebfe1..f0c55c3 100644
--- a/gr/aueb/cs/introduction/Human.java
+++ b/gr/aueb/cs/examples/introduction/Human.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.introduction;
+package gr.aueb.cs.examples.introduction;
class Human
{
diff --git a/gr/aueb/cs/introduction/Simulator.java b/gr/aueb/cs/examples/introduction/Simulator.java
similarity index 89%
rename from gr/aueb/cs/introduction/Simulator.java
rename to gr/aueb/cs/examples/introduction/Simulator.java
index dbb6284..c264d95 100644
--- a/gr/aueb/cs/introduction/Simulator.java
+++ b/gr/aueb/cs/examples/introduction/Simulator.java
@@ -1,11 +1,8 @@
-package gr.aueb.cs.introduction;
+package gr.aueb.cs.examples.introduction;
-class Simulator {
+public class Simulator {
protected static float time;
protected int x;
-}
-
-class SimulatorDemo {
public static void main(String [] args){
@@ -22,4 +19,4 @@ public static void main(String [] args){
System.out.println("static variable time can be accessed through class name, Simulator.time: " + Simulator.time + ", ob1.time: " + ob1.time + ", ob2.time:" + ob2.time);
}
-}
\ No newline at end of file
+}
diff --git a/gr/aueb/cs/introduction/Variables.java b/gr/aueb/cs/examples/introduction/Variables.java
similarity index 98%
rename from gr/aueb/cs/introduction/Variables.java
rename to gr/aueb/cs/examples/introduction/Variables.java
index ff83738..6e06ea8 100644
--- a/gr/aueb/cs/introduction/Variables.java
+++ b/gr/aueb/cs/examples/introduction/Variables.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.introduction;
+package gr.aueb.cs.examples.introduction;
public class Variables {
diff --git a/gr/aueb/cs/profiling/ArrayListVsVectorBenchmark.java b/gr/aueb/cs/examples/profiling/ArrayListVsVectorBenchmark.java
similarity index 96%
rename from gr/aueb/cs/profiling/ArrayListVsVectorBenchmark.java
rename to gr/aueb/cs/examples/profiling/ArrayListVsVectorBenchmark.java
index ac43283..254da02 100644
--- a/gr/aueb/cs/profiling/ArrayListVsVectorBenchmark.java
+++ b/gr/aueb/cs/examples/profiling/ArrayListVsVectorBenchmark.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.profiling;
+package gr.aueb.cs.examples.profiling;
import java.util.ArrayList;
import java.util.Vector;
diff --git a/gr/aueb/cs/profiling/EnsureCapacityDemo.java b/gr/aueb/cs/examples/profiling/EnsureCapacityDemo.java
similarity index 96%
rename from gr/aueb/cs/profiling/EnsureCapacityDemo.java
rename to gr/aueb/cs/examples/profiling/EnsureCapacityDemo.java
index 44c5cd9..4c48f31 100644
--- a/gr/aueb/cs/profiling/EnsureCapacityDemo.java
+++ b/gr/aueb/cs/examples/profiling/EnsureCapacityDemo.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.profiling;
+package gr.aueb.cs.examples.profiling;
import java.util.ArrayList;
diff --git a/gr/aueb/cs/profiling/PrimitiveVsWrapperBenchmark.java b/gr/aueb/cs/examples/profiling/PrimitiveVsWrapperBenchmark.java
similarity index 96%
rename from gr/aueb/cs/profiling/PrimitiveVsWrapperBenchmark.java
rename to gr/aueb/cs/examples/profiling/PrimitiveVsWrapperBenchmark.java
index d4f4d34..f86b1e7 100644
--- a/gr/aueb/cs/profiling/PrimitiveVsWrapperBenchmark.java
+++ b/gr/aueb/cs/examples/profiling/PrimitiveVsWrapperBenchmark.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.profiling;
+package gr.aueb.cs.examples.profiling;
public class PrimitiveVsWrapperBenchmark {
public static void main(String[] args) {
diff --git a/gr/aueb/cs/profiling/ReadSpeedTest.java b/gr/aueb/cs/examples/profiling/ReadSpeedTest.java
similarity index 96%
rename from gr/aueb/cs/profiling/ReadSpeedTest.java
rename to gr/aueb/cs/examples/profiling/ReadSpeedTest.java
index df1eb8a..d9e7624 100644
--- a/gr/aueb/cs/profiling/ReadSpeedTest.java
+++ b/gr/aueb/cs/examples/profiling/ReadSpeedTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.profiling;
+package gr.aueb.cs.examples.profiling;
import java.io.*;
@@ -41,7 +41,7 @@ public static long readWithFileInputStreamAndDIYBuffer(String filename) throws I
int bytesRead = in.read(buffer, 0, buffer.length);
while (bytesRead != -1) {
- // διαβάζουμε byte-προς-byte
+ bytesRead = in.read(buffer, 0, buffer.length);
}
in.close();
@@ -68,4 +68,4 @@ public static void writeBigFile(String filename) throws IOException {
}
f.close();
}
-}
\ No newline at end of file
+}
diff --git a/gr/aueb/cs/review/AnonymousClassTest.java b/gr/aueb/cs/examples/review/AnonymousClassTest.java
similarity index 97%
rename from gr/aueb/cs/review/AnonymousClassTest.java
rename to gr/aueb/cs/examples/review/AnonymousClassTest.java
index 0144318..6709227 100644
--- a/gr/aueb/cs/review/AnonymousClassTest.java
+++ b/gr/aueb/cs/examples/review/AnonymousClassTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.review;
+package gr.aueb.cs.examples.review;
public class AnonymousClassTest {
diff --git a/gr/aueb/cs/review/ConstructorBuildingTest.java b/gr/aueb/cs/examples/review/ConstructorBuildingTest.java
similarity index 98%
rename from gr/aueb/cs/review/ConstructorBuildingTest.java
rename to gr/aueb/cs/examples/review/ConstructorBuildingTest.java
index bea3b70..48a133d 100644
--- a/gr/aueb/cs/review/ConstructorBuildingTest.java
+++ b/gr/aueb/cs/examples/review/ConstructorBuildingTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.review;
+package gr.aueb.cs.examples.review;
import java.util.ArrayList;
diff --git a/gr/aueb/cs/review/DynamicDispatchTest.java b/gr/aueb/cs/examples/review/DynamicDispatchTest.java
similarity index 91%
rename from gr/aueb/cs/review/DynamicDispatchTest.java
rename to gr/aueb/cs/examples/review/DynamicDispatchTest.java
index c9c6090..01b867a 100644
--- a/gr/aueb/cs/review/DynamicDispatchTest.java
+++ b/gr/aueb/cs/examples/review/DynamicDispatchTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.review;
+package gr.aueb.cs.examples.review;
class A{
public void method() {
diff --git a/gr/aueb/cs/review/ExceptionTest.java b/gr/aueb/cs/examples/review/ExceptionTest.java
similarity index 93%
rename from gr/aueb/cs/review/ExceptionTest.java
rename to gr/aueb/cs/examples/review/ExceptionTest.java
index dd10bdb..d5fa8a0 100644
--- a/gr/aueb/cs/review/ExceptionTest.java
+++ b/gr/aueb/cs/examples/review/ExceptionTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.review;
+package gr.aueb.cs.examples.review;
class ExceptionTest {
static int a;
diff --git a/gr/aueb/cs/review/RandomTest.java b/gr/aueb/cs/examples/review/RandomTest.java
similarity index 96%
rename from gr/aueb/cs/review/RandomTest.java
rename to gr/aueb/cs/examples/review/RandomTest.java
index 1d54003..c5bb226 100644
--- a/gr/aueb/cs/review/RandomTest.java
+++ b/gr/aueb/cs/examples/review/RandomTest.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.review;
+package gr.aueb.cs.examples.review;
import java.util.Random;
diff --git a/gr/aueb/cs/sound/ZooAlarm.java b/gr/aueb/cs/examples/sound/ZooAlarm.java
similarity index 97%
rename from gr/aueb/cs/sound/ZooAlarm.java
rename to gr/aueb/cs/examples/sound/ZooAlarm.java
index 01f4181..f0d6949 100644
--- a/gr/aueb/cs/sound/ZooAlarm.java
+++ b/gr/aueb/cs/examples/sound/ZooAlarm.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.sound;
+package gr.aueb.cs.examples.sound;
import java.awt.Toolkit;
public class ZooAlarm {
diff --git a/gr/aueb/cs/strings/StringPlay.java b/gr/aueb/cs/examples/strings/StringPlay.java
similarity index 83%
rename from gr/aueb/cs/strings/StringPlay.java
rename to gr/aueb/cs/examples/strings/StringPlay.java
index c2394c5..bbe2b36 100644
--- a/gr/aueb/cs/strings/StringPlay.java
+++ b/gr/aueb/cs/examples/strings/StringPlay.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.strings;
+package gr.aueb.cs.examples.strings;
public class StringPlay {
public static void main(String[] args) {
diff --git a/gr/aueb/cs/unit/Calculator.java b/gr/aueb/cs/examples/unit/Calculator.java
similarity index 91%
rename from gr/aueb/cs/unit/Calculator.java
rename to gr/aueb/cs/examples/unit/Calculator.java
index 23cd307..938d72e 100644
--- a/gr/aueb/cs/unit/Calculator.java
+++ b/gr/aueb/cs/examples/unit/Calculator.java
@@ -1,4 +1,4 @@
-package gr.aueb.cs.unit;
+package gr.aueb.cs.examples.unit;
public class Calculator {
diff --git a/gr/aueb/cs/unit/CalculatorTest.java b/gr/aueb/cs/examples/unit/CalculatorTest.java
similarity index 61%
rename from gr/aueb/cs/unit/CalculatorTest.java
rename to gr/aueb/cs/examples/unit/CalculatorTest.java
index bb6d78f..5ee57c4 100644
--- a/gr/aueb/cs/unit/CalculatorTest.java
+++ b/gr/aueb/cs/examples/unit/CalculatorTest.java
@@ -1,8 +1,9 @@
-package gr.aueb.cs.unit;
+package gr.aueb.cs.examples.unit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+
import static org.junit.jupiter.api.Assertions.*;
class CalculatorTest {
@@ -22,18 +23,33 @@ void testAdd() {
assertEquals(5, result, "Η πρόσθεση θα έπρεπε να επιστρέφει 5");
}
+ @Test
+ @DisplayName("Έλεγχος πρόσθεσης με αρνητικούς αριθμούς")
+ void testAddNegativeNumbers() {
+ assertEquals(-7, calculator.add(-2, -5));
+ assertEquals(3, calculator.add(10, -7));
+ }
+
@Test
@DisplayName("Έλεγχος διαίρεσης")
void testDivide() {
assertEquals(2.0, calculator.divide(10, 5));
}
+ @Test
+ @DisplayName("Έλεγχος διαίρεσης με δεκαδικό αποτέλεσμα")
+ void testDivideWithDecimalResult() {
+ assertEquals(2.5, calculator.divide(5, 2));
+ }
+
@Test
@DisplayName("Έλεγχος εξαίρεσης (Exception) στη διαίρεση με το μηδέν")
void testDivideByZero() {
- assertThrows(ArithmeticException.class, () -> {
+ ArithmeticException exception = assertThrows(ArithmeticException.class, () -> {
calculator.divide(10, 0);
}, "Θα έπρεπε να πετάει ArithmeticException");
+
+ assertEquals("Δεν μπορείς να διαιρέσεις με το μηδέν!", exception.getMessage());
}
-}
\ No newline at end of file
+}
diff --git a/gr/aueb/cs/exceptions/ThrowTest.java b/gr/aueb/cs/exceptions/ThrowTest.java
deleted file mode 100644
index ac09d18..0000000
--- a/gr/aueb/cs/exceptions/ThrowTest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package gr.aueb.cs.exceptions;
-
-public class ThrowTest {
- public static void main(String[] args) {
- throw new RuntimeException("Σφάλμα!");
- }
-}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..09fb59d
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,52 @@
+
+ 4.0.0
+
+ gr.aueb.cs
+ java-examples
+ 1.0-SNAPSHOT
+
+
+ 17
+ UTF-8
+ 5.10.2
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.jupiter.version}
+ test
+
+
+
+
+ ${project.basedir}
+ ${project.basedir}
+
+
+
+ maven-compiler-plugin
+ 3.13.0
+
+
+ gr/aueb/cs/examples/unit/**/*.java
+
+
+ **/*Test.java
+
+
+ gr/aueb/cs/examples/unit/**/*Test.java
+
+
+
+
+
+ maven-surefire-plugin
+ 3.2.5
+
+
+
+