Finished PlayerTest

This commit is contained in:
2019-03-25 12:48:13 -06:00
parent 5a43adf7ad
commit dc28fb504d

View File

@@ -6,14 +6,27 @@ import java.io.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/**
* 2019-03-10
* Authors: Harkamal, Vikram, Haris, Siddhant, Nathan
* Player test, checks all the info about the player such as inventory, health, etc
*
*/
public class PlayerTest { public class PlayerTest {
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getCargoSpace() { public void getCargoSpace() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 60, player.getCargoSpace()); assertEquals("The instance variable for the object does not line up with the rest of the class", 60, player.getCargoSpace());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setCargoSpace() { public void setCargoSpace() {
Player player = new Player(); Player player = new Player();
@@ -21,12 +34,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 10, player.getCargoSpace()); assertEquals("The instance variable for the object does not line up with the rest of the class", 10, player.getCargoSpace());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getAttackingShips() { public void getAttackingShips() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", true, player.getAttackingShips()); assertEquals("The instance variable for the object does not line up with the rest of the class", true, player.getAttackingShips());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setAttackingShips() { public void setAttackingShips() {
Player player = new Player(); Player player = new Player();
@@ -34,12 +53,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", false, player.getAttackingShips()); assertEquals("The instance variable for the object does not line up with the rest of the class", false, player.getAttackingShips());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getRetire() { public void getRetire() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", false, player.getRetire()); assertEquals("The instance variable for the object does not line up with the rest of the class", false, player.getRetire());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setRetire() { public void setRetire() {
Player player = new Player(); Player player = new Player();
@@ -47,12 +72,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", true, player.getRetire()); assertEquals("The instance variable for the object does not line up with the rest of the class", true, player.getRetire());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getName() { public void getName() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", "Taipan", player.getName()); assertEquals("The instance variable for the object does not line up with the rest of the class", "Taipan", player.getName());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setName() { public void setName() {
Player player = new Player(); Player player = new Player();
@@ -60,12 +91,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", "a", player.getName()); assertEquals("The instance variable for the object does not line up with the rest of the class", "a", player.getName());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getHP() { public void getHP() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 100, player.getHP()); assertEquals("The instance variable for the object does not line up with the rest of the class", 100, player.getHP());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setHP() { public void setHP() {
Player player = new Player(); Player player = new Player();
@@ -73,12 +110,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getHP()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getHP());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getBank() { public void getBank() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getBank()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getBank());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setBank() { public void setBank() {
Player player = new Player(); Player player = new Player();
@@ -86,12 +129,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getBank()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getBank());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getMoney() { public void getMoney() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getMoney()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getMoney());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setMoney() { public void setMoney() {
Player player = new Player(); Player player = new Player();
@@ -99,12 +148,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getMoney()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getMoney());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getOpiumHeld() { public void getOpiumHeld() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getOpiumHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getOpiumHeld());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setOpiumHeld() { public void setOpiumHeld() {
Player player = new Player(); Player player = new Player();
@@ -112,12 +167,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getOpiumHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getOpiumHeld());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getSilkHeld() { public void getSilkHeld() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getSilkHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getSilkHeld());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setSilkHeld() { public void setSilkHeld() {
Player player = new Player(); Player player = new Player();
@@ -125,12 +186,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getSilkHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getSilkHeld());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getGeneralHeld() { public void getGeneralHeld() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getGeneralHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getGeneralHeld());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setGeneralHeld() { public void setGeneralHeld() {
Player player = new Player(); Player player = new Player();
@@ -138,12 +205,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getGeneralHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getGeneralHeld());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getArmsHeld() { public void getArmsHeld() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getArmsHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getArmsHeld());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setArmsHeld() { public void setArmsHeld() {
Player player = new Player(); Player player = new Player();
@@ -151,12 +224,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getArmsHeld()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getArmsHeld());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getLocation() { public void getLocation() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getLocation()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getLocation());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setLocation() { public void setLocation() {
Player player = new Player(); Player player = new Player();
@@ -164,12 +243,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 2, player.getLocation()); assertEquals("The instance variable for the object does not line up with the rest of the class", 2, player.getLocation());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getGuns() { public void getGuns() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 5, player.getGuns()); assertEquals("The instance variable for the object does not line up with the rest of the class", 5, player.getGuns());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setGuns() { public void setGuns() {
Player player = new Player(); Player player = new Player();
@@ -177,12 +262,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getGuns()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getGuns());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getDebt() { public void getDebt() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getDebt()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getDebt());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setDebt() { public void setDebt() {
Player player = new Player(); Player player = new Player();
@@ -190,12 +281,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getDebt()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getDebt());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getwOpium() { public void getwOpium() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwOpium()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwOpium());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setwOpium() { public void setwOpium() {
Player player = new Player(); Player player = new Player();
@@ -203,12 +300,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwOpium()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwOpium());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getwSilk() { public void getwSilk() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwSilk()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwSilk());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setwSilk() { public void setwSilk() {
Player player = new Player(); Player player = new Player();
@@ -216,12 +319,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwSilk()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwSilk());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getwGeneral() { public void getwGeneral() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwGeneral()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwGeneral());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setwGeneral() { public void setwGeneral() {
Player player = new Player(); Player player = new Player();
@@ -229,12 +338,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwGeneral()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwGeneral());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getwArms() { public void getwArms() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwArms()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getwArms());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setwArms() { public void setwArms() {
Player player = new Player(); Player player = new Player();
@@ -242,12 +357,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwArms()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getwArms());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getOpiumPrice() { public void getOpiumPrice() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 16000, player.getOpiumPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 16000, player.getOpiumPrice());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setOpiumPrice() { public void setOpiumPrice() {
Player player = new Player(); Player player = new Player();
@@ -255,12 +376,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getOpiumPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getOpiumPrice());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getSilkPrice() { public void getSilkPrice() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 1600, player.getSilkPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1600, player.getSilkPrice());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setSilkPrice() { public void setSilkPrice() {
Player player = new Player(); Player player = new Player();
@@ -268,12 +395,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getSilkPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getSilkPrice());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getArmsPrice() { public void getArmsPrice() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 160, player.getArmsPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 160, player.getArmsPrice());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setArmsPrice() { public void setArmsPrice() {
Player player = new Player(); Player player = new Player();
@@ -281,12 +414,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getArmsPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getArmsPrice());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getGeneralPrice() { public void getGeneralPrice() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 8, player.getGeneralPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 8, player.getGeneralPrice());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setGeneralPrice() { public void setGeneralPrice() {
Player player = new Player(); Player player = new Player();
@@ -294,12 +433,18 @@ public class PlayerTest {
assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getGeneralPrice()); assertEquals("The instance variable for the object does not line up with the rest of the class", 1, player.getGeneralPrice());
} }
/**
* Test this getter method to see if it returns the default values if called.
*/
@Test @Test
public void getIsPriceChanged() { public void getIsPriceChanged() {
Player player = new Player(); Player player = new Player();
assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getIsPriceChanged()); assertEquals("The instance variable for the object does not line up with the rest of the class", 0, player.getIsPriceChanged());
} }
/**
* Test this setter by changing the value of the instance variable and then seeing if the getter returns the same value
*/
@Test @Test
public void setIsPriceChanged() { public void setIsPriceChanged() {
Player player = new Player(); Player player = new Player();