From 2905e4fb1f51868d42a4c0ce4de9632c4defa3eb Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 16 Sep 2022 12:41:42 -0400 Subject: [PATCH] Added Comments to the New Tests and Object Files --- .../world/data/objects/PlayerData.java | 17 +++++++++++- .../world/data/objects/PlayerWorld.java | 10 +++++++ .../world/data/objects/WorldSystemData.java | 25 ++++++++++++++++++ .../world/data/objects/TestPlayerData.java | 19 ++++++++++++- .../world/data/objects/TestPlayerWorld.java | 6 +++++ .../data/objects/TestWorldSystemData.java | 20 ++++++++++++-- .../world/data/objects/PlayerData.class | Bin 1123 -> 1123 bytes .../world/data/objects/PlayerWorld.class | Bin 529 -> 529 bytes .../world/data/objects/WorldSystemData.class | Bin 1636 -> 1636 bytes .../world/data/objects/TestPlayerData.class | Bin 1370 -> 1484 bytes .../world/data/objects/TestPlayerWorld.class | Bin 875 -> 875 bytes .../data/objects/TestWorldSystemData.class | Bin 2635 -> 2635 bytes 12 files changed, 93 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/butzlabben/world/data/objects/PlayerData.java b/src/main/java/de/butzlabben/world/data/objects/PlayerData.java index bac1f02..bf64723 100644 --- a/src/main/java/de/butzlabben/world/data/objects/PlayerData.java +++ b/src/main/java/de/butzlabben/world/data/objects/PlayerData.java @@ -8,19 +8,34 @@ public class PlayerData { //TODO Write Tests private List playerWorlds; - + /** + * Inits a new Player Object + */ public PlayerData() { playerWorlds = new ArrayList(); } + /** + * adds a world to the playerWorlds Array + * @param world the world data object to be added + */ public void addWorld(PlayerWorld world) { playerWorlds.add(world); } + /** + * gets the current count of worlds that the player owns + * @return + */ public int getWorldCount() { return playerWorlds.size(); } + /** + * returns the world at a certain index + * @param index index of the world you want + * @return the World Data Object + */ public PlayerWorld getWorldAt(int index) { return playerWorlds.get(index); } diff --git a/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java b/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java index 6d94358..75bb550 100644 --- a/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java +++ b/src/main/java/de/butzlabben/world/data/objects/PlayerWorld.java @@ -4,11 +4,21 @@ public class PlayerWorld { private int worldNumber; private long lastLoaded; + /** + * Creates an new Player World Data Structure if the worldNumber given + * @param worldNumber the index of the world held by the player + */ public PlayerWorld(int worldNumber) { this.worldNumber = worldNumber; this.lastLoaded = -1; } + /** + * gets the world player index + * (player index = the index of the world in the player's + * world array) + * @return the world number + */ public int getWorldNumber() { return worldNumber; } diff --git a/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java b/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java index 0b1dd60..9af4cef 100644 --- a/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java +++ b/src/main/java/de/butzlabben/world/data/objects/WorldSystemData.java @@ -13,10 +13,21 @@ import java.util.Map; public class WorldSystemData { public Map players; + + /** + * Creates the WorldSystemData objects + * and creates a blank map to hold player data + * with the uuid is the key + */ public WorldSystemData() { players = new HashMap(); } + /** + * Adds a Player to the data record + * @param uuid the UUID of the player to be added + * @return returns whether the player was added successfully or not + */ public Boolean addplayer(String uuid) { if (players.get(uuid) == null) { players.put(uuid, new PlayerData()); @@ -25,16 +36,30 @@ public class WorldSystemData { return false; } + /** + * adds a world Object to the player specified + * @param uuid the UUID of the player + * @param world the World Object to be added + */ public void addWorldToPlayer(String uuid, PlayerWorld world) { if (players.get(uuid) != null) { players.get(uuid).addWorld(world); } } + /** + * Gets the Amount of playerdata stored by WorldSystem + * @return player count + */ public int getPlayers() { return players.size(); } + /** + * returns the player data of the specifed uuid + * @param uuid the UUID of the player you want + * @return returns the player data object + */ public PlayerData getPlayer(String uuid) { return players.get(uuid); } diff --git a/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java b/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java index 52f33cc..37b45ae 100644 --- a/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java +++ b/src/test/java/de/butzlabben/world/data/objects/TestPlayerData.java @@ -7,6 +7,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class TestPlayerData { + /** + * Tests the Basic Initalization of a PlayerData Object + */ @Test public void testPlayerDataInit() { PlayerData pd = new PlayerData(); @@ -14,19 +17,33 @@ public class TestPlayerData { assertEquals(0, pd.getWorldCount()); } + /** + * Tests adding one world to the player + */ @Test public void testAddWorld() { PlayerData pd = new PlayerData(); pd.addWorld(new PlayerWorld(pd.getWorldCount())); assertEquals(1, pd.getWorldCount()); + } + + /** + * Tests adding multiple worlds to the player + */ + @Test + public void testAddMultipleWorlds() { + PlayerData pd = new PlayerData(); for (int i = 0; i < 5; i++) { pd.addWorld(new PlayerWorld(pd.getWorldCount())); } - assertEquals(6, pd.getWorldCount()); + assertEquals(5, pd.getWorldCount()); } + /** + * Tests geting a world at a specified index + */ @Test public void testGetWorldAtIndex() { PlayerData pd = new PlayerData(); diff --git a/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java b/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java index 900c72e..9964ed7 100644 --- a/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java +++ b/src/test/java/de/butzlabben/world/data/objects/TestPlayerWorld.java @@ -6,12 +6,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class TestPlayerWorld { + /** + * Tests the basic initiazlization of a new World with an id of 0 + */ @Test public void testPlayerWorldInit() { PlayerWorld pw = new PlayerWorld(0); assertEquals(0,pw.getWorldNumber()); } + /** + * Test the initiazlization of a world with a index other than 0 + */ @Test public void testPlayerWorldInit2() { PlayerWorld pw = new PlayerWorld(6); diff --git a/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java b/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java index 028661a..7c3e0b3 100644 --- a/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java +++ b/src/test/java/de/butzlabben/world/data/objects/TestWorldSystemData.java @@ -6,6 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class TestWorldSystemData { + /** + * Test the base initiaztaion of the WorldSystemData Object + */ @Test public void testWorldSystemDataInit() { WorldSystemData wsd = new WorldSystemData(); @@ -13,6 +16,9 @@ public class TestWorldSystemData { assertEquals(0, wsd.getPlayers()); } + /** + * Tests adding a basic player + */ @Test public void testAddPlayer() { WorldSystemData wsd = new WorldSystemData(); @@ -23,6 +29,9 @@ public class TestWorldSystemData { } + /** + * Test adding multiple Players + */ @Test public void testAddMultiplePlayers() { WorldSystemData wsd = new WorldSystemData(); @@ -38,7 +47,9 @@ public class TestWorldSystemData { } - + /** + * Tests adding Duplicate PLayers + */ @Test public void testAddDulpicatePlayer() { WorldSystemData wsd = new WorldSystemData(); @@ -51,6 +62,9 @@ public class TestWorldSystemData { assertEquals(1, wsd.getPlayers()); } + /** + * Tests adding a world to a player + */ @Test public void testAddWorldToPlayer() { WorldSystemData wsd = new WorldSystemData(); @@ -62,7 +76,9 @@ public class TestWorldSystemData { assertEquals(1, wsd.getPlayer("Blank_UUID").getWorldCount()); } - + /** + * Tests adding mulitple worlds a player + */ @Test public void testAddMultipleWorldsToPlayer() { WorldSystemData wsd = new WorldSystemData(); diff --git a/target/classes/de/butzlabben/world/data/objects/PlayerData.class b/target/classes/de/butzlabben/world/data/objects/PlayerData.class index 2d2c1f6a122141379ee7e298e6b970b752c7751a..4c6d7fc9ea09d51722de0f0c733b03815b2018be 100644 GIT binary patch delta 43 xcmaFN@t9*n6f-9u0}BH`5DH9AW_D&3XW(X#n7o?Vn^Au9cV<^cjmfqwY5>np2}u9| delta 43 zcmaFN@t9*n6f-9e0}BH$13v@b14$+Z F8352}1ttIh delta 55 zcmbQpGLdD&LPlP81{MYm22LOpVBng(j?qn)mqCnyfq{pC5lFH!h%-n4X+{QVAj!la F0|3mo1q=WH diff --git a/target/classes/de/butzlabben/world/data/objects/WorldSystemData.class b/target/classes/de/butzlabben/world/data/objects/WorldSystemData.class index d75b56edee1d078042c3ffe552db061aabf4b7ad..110cdddf58b33ecc5290ec91e068194a3652f838 100644 GIT binary patch delta 65 zcmaFD^Mq%^Mix#n1{MZ!27U&K$-7t*coi6U859}h8I%}Q7*r;!vu1MY0!8!~7$hgFvu1M20!8G2P+{^+ T);LDx$v;?K8PzA-v8e$7p#=J0~!)9JG-0Nnc0#2SeEb8mp1^XI2p=skzS8`QG6Bz=XYV;AB4T`&21P& zYAi0bgzD;%orDDkYe=b2-M6n`K=8bz9HV$WWGAr0n&KYVAUBT;3MgU|Rc_M1Z0ur> zlZ7m5@StIz(-QH3sG-hYpu+xvIy%vNg?aG=yQ2<`!oB4_LOx@4=BLm7a=ZY_RIDJ$ z%@(mtml}O$z9sS`ayUX`p1@lq*#1j!Ox6m-1k!}5jhX#_CV!D>puUW@Q>Ryhzxn*F P2^TF@O}J*0Dgvz^Zi_7J delta 223 zcmWNLJx&5~6vThK|6LXq!bd<*F>xXCxgb$oDGZ%-h68vB3lG2{{vBta*~S*68ImH>c7$g{k86+oLG8+K^nIZ*68IRzQG7=##v8H6WWG8+K^m$3%K diff --git a/target/test-classes/de/butzlabben/world/data/objects/TestWorldSystemData.class b/target/test-classes/de/butzlabben/world/data/objects/TestWorldSystemData.class index 5752482024c953bc7da1c6aa26468ebc1690fc76..34303e4e51c9eb2fcfac7ecbcba960f74ce885d2 100644 GIT binary patch delta 179 zcmX>ta$00VEgL5v0|$cu5DHFiW6Kqk0P-Y(JZT1T1{nr<2D!;B?0t%=Kv6ZIs0L6} z6DX<;ywJq8B`gUOrOXGod@RapR4Spij916A1qRoMaM?I)*jbcnhEW!-_Y zota$00VEgL5{0|x^yg8&2HM*|P?Z5tl@U;tF@qk1$>bD{4p9rB ztR+y^8YpW6RA