diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml
new file mode 100644
index 00000000..7135cfd1
--- /dev/null
+++ b/.github/workflows/ant.yml
@@ -0,0 +1,27 @@
+# This workflow will build a Java project with Ant
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-ant
+
+name: Java CI
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 8
+ uses: actions/setup-java@v3
+ with:
+ java-version: '8'
+ distribution: 'temurin'
+ - name: Build with Ant
+ run: ant -noinput -buildfile "GOFO Implementation/build.xml"
+ - name: Run Tests
+ run: cd 'GOFO Implementation'; ls -la; ant -noinput -buildfile build.xml; ant test
diff --git a/GOFO Implementation/build/classes/System/Administrator.class b/GOFO Implementation/build/classes/System/Administrator.class
index 4c9de0ba..41226177 100644
Binary files a/GOFO Implementation/build/classes/System/Administrator.class and b/GOFO Implementation/build/classes/System/Administrator.class differ
diff --git a/GOFO Implementation/build/classes/System/PlayGroundSchedule.class b/GOFO Implementation/build/classes/System/PlayGroundSchedule.class
index 107c2c80..355aa9a6 100644
Binary files a/GOFO Implementation/build/classes/System/PlayGroundSchedule.class and b/GOFO Implementation/build/classes/System/PlayGroundSchedule.class differ
diff --git a/GOFO Implementation/build/classes/System/Player.class b/GOFO Implementation/build/classes/System/Player.class
index fed83884..18c94fdd 100644
Binary files a/GOFO Implementation/build/classes/System/Player.class and b/GOFO Implementation/build/classes/System/Player.class differ
diff --git a/GOFO Implementation/build/classes/System/Playground.class b/GOFO Implementation/build/classes/System/Playground.class
index 1f6ae4d5..0756eebd 100644
Binary files a/GOFO Implementation/build/classes/System/Playground.class and b/GOFO Implementation/build/classes/System/Playground.class differ
diff --git a/GOFO Implementation/build/classes/System/PlaygroundOwner.class b/GOFO Implementation/build/classes/System/PlaygroundOwner.class
index 8c0b091f..9a4e4f54 100644
Binary files a/GOFO Implementation/build/classes/System/PlaygroundOwner.class and b/GOFO Implementation/build/classes/System/PlaygroundOwner.class differ
diff --git a/GOFO Implementation/build/classes/System/eWallet.class b/GOFO Implementation/build/classes/System/eWallet.class
index 8fd68bd4..73f217b3 100644
Binary files a/GOFO Implementation/build/classes/System/eWallet.class and b/GOFO Implementation/build/classes/System/eWallet.class differ
diff --git a/GOFO Implementation/build/classes/System/userProfile.class b/GOFO Implementation/build/classes/System/userProfile.class
index 75cf18aa..3802ced1 100644
Binary files a/GOFO Implementation/build/classes/System/userProfile.class and b/GOFO Implementation/build/classes/System/userProfile.class differ
diff --git a/GOFO Implementation/build/classes/UI/AdminUI.class b/GOFO Implementation/build/classes/UI/AdminUI.class
index ba5f1ba4..7e912071 100644
Binary files a/GOFO Implementation/build/classes/UI/AdminUI.class and b/GOFO Implementation/build/classes/UI/AdminUI.class differ
diff --git a/GOFO Implementation/build/classes/UI/PlayerUI.class b/GOFO Implementation/build/classes/UI/PlayerUI.class
index 2251e272..6fc0135f 100644
Binary files a/GOFO Implementation/build/classes/UI/PlayerUI.class and b/GOFO Implementation/build/classes/UI/PlayerUI.class differ
diff --git a/GOFO Implementation/build/classes/UI/SystemUI.class b/GOFO Implementation/build/classes/UI/SystemUI.class
index 185c601f..60a2ea11 100644
Binary files a/GOFO Implementation/build/classes/UI/SystemUI.class and b/GOFO Implementation/build/classes/UI/SystemUI.class differ
diff --git a/GOFO Implementation/build/classes/UI/playgroundOwnerUI.class b/GOFO Implementation/build/classes/UI/playgroundOwnerUI.class
index b2dc699f..895bd079 100644
Binary files a/GOFO Implementation/build/classes/UI/playgroundOwnerUI.class and b/GOFO Implementation/build/classes/UI/playgroundOwnerUI.class differ
diff --git a/GOFO Implementation/nbproject/build-impl.xml b/GOFO Implementation/nbproject/build-impl.xml
index 2011dd23..17d1b0d8 100644
--- a/GOFO Implementation/nbproject/build-impl.xml
+++ b/GOFO Implementation/nbproject/build-impl.xml
@@ -122,7 +122,7 @@ is divided into following sections:
-
+
@@ -412,7 +412,7 @@ is divided into following sections:
-
+
@@ -444,7 +444,7 @@ is divided into following sections:
-
+
@@ -556,7 +556,7 @@ is divided into following sections:
-
+
@@ -1255,7 +1255,7 @@ is divided into following sections:
-
+
@@ -1272,7 +1272,7 @@ is divided into following sections:
-
+
diff --git a/GOFO Implementation/nbproject/genfiles.properties b/GOFO Implementation/nbproject/genfiles.properties
index 81c098e1..c9da8434 100644
--- a/GOFO Implementation/nbproject/genfiles.properties
+++ b/GOFO Implementation/nbproject/genfiles.properties
@@ -1,6 +1,6 @@
build.xml.data.CRC32=4c7768cc
build.xml.script.CRC32=2745b79b
-build.xml.stylesheet.CRC32=8064a381@1.79.1.48
+build.xml.stylesheet.CRC32=f85dc8f2@1.108.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4c7768cc
diff --git a/GOFO Implementation/nbproject/private/private.properties b/GOFO Implementation/nbproject/private/private.properties
index 72fe7881..c1ed613f 100644
--- a/GOFO Implementation/nbproject/private/private.properties
+++ b/GOFO Implementation/nbproject/private/private.properties
@@ -1,2 +1,2 @@
compile.on.save=true
-user.properties.file=C:\\Users\\AA\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
+user.properties.file=C:\\Users\\pedra\\AppData\\Roaming\\NetBeans\\19\\build.properties
diff --git a/GOFO Implementation/nbproject/private/private.xml b/GOFO Implementation/nbproject/private/private.xml
index d3025ea5..6807a2ba 100644
--- a/GOFO Implementation/nbproject/private/private.xml
+++ b/GOFO Implementation/nbproject/private/private.xml
@@ -2,16 +2,6 @@
-
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/PlaygroundOwner.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/UI/playgroundOwnerUI.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/Playground.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/Administrator.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/PlayGroundSchedule.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/UI/SystemUI.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/userProfile.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/Player.java
- file:/F:/Fci/Year%20Four/Term%20two/Software%201/Project/2021/Project/GOFO/src/System/eWallet.java
-
+
diff --git a/GOFO Implementation/nbproject/project.properties b/GOFO Implementation/nbproject/project.properties
index cd6edaf4..ddd0c9db 100644
--- a/GOFO Implementation/nbproject/project.properties
+++ b/GOFO Implementation/nbproject/project.properties
@@ -18,8 +18,12 @@ build.test.results.dir=${build.dir}/test/results
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
+debug.modulepath=\
+ ${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
+debug.test.modulepath=\
+ ${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
@@ -34,6 +38,8 @@ javac.classpath=
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
+javac.modulepath=
+javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=1.8
@@ -41,6 +47,8 @@ javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
+javac.test.modulepath=\
+ ${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
@@ -66,9 +74,13 @@ run.classpath=\
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
+run.modulepath=\
+ ${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
+run.test.modulepath=\
+ ${javac.test.modulepath}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
diff --git a/GOFO Implementation/src/System/PlayGroundSchedule.java b/GOFO Implementation/src/System/PlayGroundSchedule.java
index 907fdece..6984af07 100644
--- a/GOFO Implementation/src/System/PlayGroundSchedule.java
+++ b/GOFO Implementation/src/System/PlayGroundSchedule.java
@@ -176,7 +176,7 @@ else if(day.equalsIgnoreCase("saturday"))
* @param time String time
* @param day String day
*/
-public void bookSlot(String player, String time,String day)
+public void bookSlot(String player, String time, String day)
{
for(int i=0; i th
System.out.println("Enter the amount to deposit");
temp = input.nextLine();
balance = stringToInt(temp);
- thePlayers.get(userIndex).getMoney(balance);
+ Option1(thePlayers, userIndex, balance);
} else if (choice.equals("2")) {
- System.out.println("Your balance is: " + thePlayers.get(userIndex).getBalance());
+ Option2(thePlayers, userIndex);
} else if (choice.equals("3")) {
Booking(input ,userIndex,thePlayers,currentUser,userBalance);
} else if (choice.equals("4")) {
@@ -77,14 +77,8 @@ public static void playerMenu(Scanner input ,int userIndex, ArrayList th
while (true) {
temp = input.nextLine();
teamNum = stringToInt(temp);
- if (teamNum >= 1 && teamNum <= 5) {
- for (int i = 0; i < teamNum; i++) {
- createTeam(thePlayers,currentUser);
- }
+ if(createMembers(teamNum, thePlayers, currentUser))
break;
- } else {
- System.out.println("please enter number from 1 to 5");
- }
}
playerMenu(input ,userIndex,thePlayers,currentUser,userBalance);
} else if (choice.equals("5")) {
@@ -115,6 +109,27 @@ public static void playerMenu(Scanner input ,int userIndex, ArrayList th
}
playerMenu(input ,userIndex,thePlayers,currentUser,userBalance);
}
+
+ public static boolean createMembers(int teamNum, ArrayList thePlayers, String currentUser) {
+ if (teamNum >= 1 && teamNum <= 5) {
+ for (int i = 0; i < teamNum; i++) {
+ createTeam(thePlayers,currentUser);
+ }
+ return true;
+ } else {
+ System.out.println("please enter number from 1 to 5");
+ return false;
+ }
+ }
+
+ public static void Option1(ArrayList thePlayers, int userIndex, int balance) {
+ thePlayers.get(userIndex).getMoney(balance);
+ }
+
+ public static void Option2(ArrayList thePlayers, int userIndex) {
+ System.out.println("Your balance is: " + thePlayers.get(userIndex).getBalance());
+ }
+
//Booking a slot for the player
public static void Booking(Scanner input ,int userIndex, ArrayList thePlayers,String currentUser,int userBalance) {
diff --git a/GOFO Implementation/test/EWalletTest.java b/GOFO Implementation/test/EWalletTest.java
new file mode 100644
index 00000000..32637444
--- /dev/null
+++ b/GOFO Implementation/test/EWalletTest.java
@@ -0,0 +1,32 @@
+import UI.PlayerUI;
+import org.junit.Test;
+import System.eWallet;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+
+public class EWalletTest {
+
+ @Test
+ public void DepositTest() {
+
+ eWallet eWallet = new eWallet();
+
+ eWallet.deposit(2);
+
+ assertEquals(2, eWallet.getBalance());
+ }
+
+ @Test
+ public void WithdrawTest() {
+ eWallet eWallet = new eWallet();
+
+ eWallet.deposit(2);
+
+ eWallet.withdraw(1);
+
+ assertEquals(1, eWallet.getBalance());
+ }
+
+}
diff --git a/GOFO Implementation/test/PlayGroundOwnerUITest.java b/GOFO Implementation/test/PlayGroundOwnerUITest.java
new file mode 100644
index 00000000..52645e61
--- /dev/null
+++ b/GOFO Implementation/test/PlayGroundOwnerUITest.java
@@ -0,0 +1,45 @@
+import org.junit.Test;
+import System.PlaygroundOwner;
+import System.Playground;
+import UI.playgroundOwnerUI;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+
+public class PlayGroundOwnerUITest {
+
+ @Test
+ public void PlaygroundExistsTest() {
+
+ PlaygroundOwner playgroundOwner = new PlaygroundOwner();
+ Playground playground = new Playground();
+ playground.setName("teste");
+ playgroundOwner.addPlayground(playground);
+
+ ArrayList playgroundOwners = new ArrayList<>();
+ playgroundOwners.add(playgroundOwner);
+
+ playgroundOwnerUI playgroundOwnerUI = new playgroundOwnerUI();
+
+ assertEquals(true, playgroundOwnerUI.playgroundExists(playgroundOwners, "teste"));
+
+ }
+
+ @Test
+ public void PlaygroundNotExistsTest() {
+
+ PlaygroundOwner playgroundOwner = new PlaygroundOwner();
+ Playground playground = new Playground();
+ playground.setName("teste123");
+ playgroundOwner.addPlayground(playground);
+
+ ArrayList playgroundOwners = new ArrayList<>();
+ playgroundOwners.add(playgroundOwner);
+
+ playgroundOwnerUI playgroundOwnerUI = new playgroundOwnerUI();
+
+ assertEquals(false, playgroundOwnerUI.playgroundExists(playgroundOwners, "teste"));
+
+ }
+}
diff --git a/GOFO Implementation/test/PlayerUiTest.java b/GOFO Implementation/test/PlayerUiTest.java
new file mode 100644
index 00000000..d1c2cf18
--- /dev/null
+++ b/GOFO Implementation/test/PlayerUiTest.java
@@ -0,0 +1,48 @@
+import System.Player;
+import UI.PlayerUI;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+
+public class PlayerUiTest {
+
+ @Test
+ public void IsExistPlayerTest() {
+
+ Player player = new Player();
+ player.setEmail("grupo@gmail.com");
+
+ ArrayList players = new ArrayList<>();
+ players.add(player);
+
+ assertEquals(true, PlayerUI.isExistPlayer(players, "grupo@gmail.com"));
+ }
+
+ @Test
+ public void IsNotExistPlayerTest() {
+
+ Player player = new Player();
+ player.setEmail("grupo@gmail.com");
+
+ ArrayList players = new ArrayList<>();
+ players.add(player);
+
+ assertEquals(false, PlayerUI.isExistPlayer(players, "grupo123@gmail.com"));
+ }
+
+ @Test
+ public void DepositTest() {
+
+ Player player = new Player();
+ player.setEmail("grupo@gmail.com");
+
+ ArrayList players = new ArrayList<>();
+ players.add(player);
+
+ PlayerUI.Option1(players, 0, 2);
+ assertEquals(2, players.get(0).getBalance());
+
+ }
+}
diff --git a/GOFO Implementation/test/PlaygroundOwnerTest.java b/GOFO Implementation/test/PlaygroundOwnerTest.java
new file mode 100644
index 00000000..51c3f580
--- /dev/null
+++ b/GOFO Implementation/test/PlaygroundOwnerTest.java
@@ -0,0 +1,32 @@
+import System.Playground;
+import System.PlaygroundOwner;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class PlaygroundOwnerTest {
+
+ @Test
+ public void ExistPlaygroundTest() {
+ PlaygroundOwner playgroundOwner = new PlaygroundOwner();
+
+ Playground playground = new Playground();
+ playground.setName("teste");
+
+ playgroundOwner.addPlayground(playground);
+
+ assertEquals(true, playgroundOwner.existPlayground("teste"));
+ }
+
+ @Test
+ public void NotExistPlaygroundTest() {
+ PlaygroundOwner playgroundOwner = new PlaygroundOwner();
+
+ Playground playground = new Playground();
+ playground.setName("teste123");
+
+ playgroundOwner.addPlayground(playground);
+
+ assertEquals(false, playgroundOwner.existPlayground("teste"));
+ }
+}
diff --git a/GOFO Implementation/test/PlaygroundTest.java b/GOFO Implementation/test/PlaygroundTest.java
new file mode 100644
index 00000000..52046081
--- /dev/null
+++ b/GOFO Implementation/test/PlaygroundTest.java
@@ -0,0 +1,18 @@
+import org.junit.Test;
+import System.Playground;
+import static org.junit.Assert.assertEquals;
+
+public class PlaygroundTest {
+
+ @Test
+ public void CheckAvailableTest() {
+
+ Playground playground = new Playground();
+ playground.setStatus("available");
+ assertEquals("available",playground.getStatus());
+
+ }
+
+
+
+}
diff --git a/GOFO Implementation/test/SystemUITest.java b/GOFO Implementation/test/SystemUITest.java
new file mode 100644
index 00000000..b10a02b8
--- /dev/null
+++ b/GOFO Implementation/test/SystemUITest.java
@@ -0,0 +1,59 @@
+import UI.SystemUI;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+import static org.junit.Assert.assertEquals;
+
+public class SystemUITest {
+
+ private final InputStream originalSystemIn = System.in;
+ private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+
+ private ByteArrayInputStream testInput;
+
+ @Before
+ public void setUpInput() {
+ System.setIn(new ByteArrayInputStream("invalidInput\n".getBytes()));
+ System.setOut(new PrintStream(outputStream));
+ }
+
+ @After
+ public void restoreSystemInAndOut() {
+ System.setIn(originalSystemIn);
+ System.setOut(System.out);
+ }
+ @Test
+ public void IsStringWithInvalidInputTest() {
+ String result = SystemUI.isString("123");
+ assertEquals("please don't enter integers or special characters", outputStream.toString().trim());
+ assertEquals("invalidInput", result);
+ }
+
+ @Test
+ public void IsStringTest() {
+ Assert.assertEquals("Teste", SystemUI.isString("Teste"));
+ }
+
+ @Test
+ public void StringToIntTest() {
+ Assert.assertEquals(1, SystemUI.stringToInt("1"));
+ }
+
+ @Test
+ public void IsDigitTest() {
+ Assert.assertEquals("1", SystemUI.isDigit("1"));
+ }
+
+ @Test
+ public void IsEmailTest() {
+ Assert.assertEquals("grupoppgg@gmail.com", SystemUI.isEmail("grupoppgg@gmail.com"));
+ }
+
+}