-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from emmamickas/AddConstantArraylistAccessModi…
…fiers Add constant arraylist access modifiers
- Loading branch information
Showing
40 changed files
with
1,202 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
196 changes: 196 additions & 0 deletions
196
src/com/hotmail/kalebmarc/textfighter/item/ArmourTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
package com.hotmail.kalebmarc.textfighter.item; | ||
|
||
import static org.junit.Assert.*; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import java.io.InputStream; | ||
import java.io.PrintStream; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.util.ArrayList; | ||
import java.util.Scanner; | ||
|
||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class ArmourTest { | ||
|
||
static Armour none; | ||
|
||
static Armour basic; | ||
|
||
static Armour advanced; | ||
|
||
static InputStream sysInBackup; | ||
|
||
static ByteArrayInputStream in; | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception { | ||
|
||
sysInBackup = System.in; | ||
|
||
none = new Armour("None", 0, 0, 1); | ||
basic = new Armour("Basic", 400, 15, 5); | ||
advanced = new Armour("Advanced", 750, 30, 7); | ||
|
||
none.setOwns(true); | ||
|
||
basic.setOwns(false); | ||
|
||
advanced.setOwns(false); | ||
|
||
Armour.set(0); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDownAfterClass() throws Exception { | ||
|
||
System.setIn(sysInBackup); | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
|
||
System.setIn(sysInBackup); | ||
|
||
none.setOwns(true); | ||
|
||
basic.setOwns(false); | ||
|
||
advanced.setOwns(false); | ||
|
||
Armour.set(0); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
|
||
System.setIn(sysInBackup); | ||
} | ||
|
||
@Test | ||
public void testChooseOnly() { | ||
// Select armour when only one type is owned | ||
|
||
// Check that no armour is equipped yet | ||
assertEquals(0, Armour.get()); | ||
|
||
ByteArrayInputStream chooseIn = new ByteArrayInputStream("1".getBytes()); // Set input stream to pick armour automatically | ||
|
||
System.setIn(chooseIn); | ||
|
||
Armour.choose(); // Pick armour to equip | ||
|
||
System.setIn(sysInBackup); | ||
|
||
assertEquals(0, Armour.get()); // Check that correct armour was equipped | ||
|
||
assertEquals(none, Armour.getEquipped()); // Check for correct armour object equipped | ||
} | ||
|
||
@Test | ||
public void testChooseFirst() { | ||
// Select armour when only all three types are owned | ||
|
||
none.setOwns(true); | ||
|
||
basic.setOwns(true); | ||
|
||
advanced.setOwns(true); | ||
|
||
// Check that no armour is equipped yet | ||
assertEquals(0, Armour.get()); | ||
|
||
ByteArrayInputStream chooseIn = new ByteArrayInputStream("1".getBytes()); // Set input stream to pick armour automatically | ||
|
||
System.setIn(chooseIn); | ||
|
||
Armour.choose(); // Pick armour to equip | ||
|
||
System.setIn(sysInBackup); | ||
|
||
assertEquals(0, Armour.get()); // Check that correct armour was equipped | ||
|
||
assertEquals(none, Armour.getEquipped()); // Check for correct armour object equipped | ||
} | ||
|
||
@Test | ||
public void testChooseMiddle() { | ||
|
||
none.setOwns(true); | ||
|
||
basic.setOwns(true); | ||
|
||
advanced.setOwns(true); | ||
|
||
// Check that no armour is equipped yet | ||
assertEquals(0, Armour.get()); | ||
|
||
ByteArrayInputStream chooseIn = new ByteArrayInputStream("2".getBytes()); // Set input stream to pick armour automatically | ||
|
||
System.setIn(chooseIn); | ||
|
||
Armour.choose(); // Pick armour to equip | ||
|
||
System.setIn(sysInBackup); | ||
|
||
assertEquals(1, Armour.get()); // Check that correct armour was equipped | ||
|
||
assertEquals(basic, Armour.getEquipped()); // Check for correct armour object equipped | ||
} | ||
|
||
@Test | ||
public void testChooseLast() { | ||
|
||
none.setOwns(true); | ||
|
||
basic.setOwns(true); | ||
|
||
advanced.setOwns(true); | ||
|
||
// Check that no armour is equipped yet | ||
assertEquals(0, Armour.get()); | ||
|
||
ByteArrayInputStream chooseIn = new ByteArrayInputStream("3".getBytes()); // Set input stream to pick armour automatically | ||
|
||
System.setIn(chooseIn); | ||
|
||
Armour.choose(); // Pick armour to equip | ||
|
||
System.setIn(sysInBackup); | ||
|
||
assertEquals(2, Armour.get()); // Check that correct armour was equipped | ||
|
||
assertEquals(advanced, Armour.getEquipped()); // Check for correct armour object equipped | ||
} | ||
|
||
@Test | ||
public void testGetArmours() { | ||
// Test constant armours array access | ||
|
||
assertEquals(3, Armour.getArmours().size()); | ||
|
||
// Check all objects are the same in each list access method | ||
assertEquals("None", Armour.getArmours().get(0).getName()); | ||
assertEquals(0, Armour.getArmours().get(0).getPrice()); | ||
assertEquals(0, Armour.getArmours().get(0).getDamResist()); | ||
assertEquals(1, Armour.getArmours().get(0).getLevel()); | ||
|
||
assertEquals( "Basic", Armour.getArmours().get(1).getName()); | ||
assertEquals(400, Armour.getArmours().get(1).getPrice()); | ||
assertEquals(15, Armour.getArmours().get(1).getDamResist()); | ||
assertEquals(5, Armour.getArmours().get(1).getLevel()); | ||
|
||
assertEquals("Advanced", Armour.getArmours().get(2).getName()); | ||
assertEquals(750, Armour.getArmours().get(2).getPrice()); | ||
assertEquals(30, Armour.getArmours().get(2).getDamResist()); | ||
assertEquals(7, Armour.getArmours().get(2).getLevel()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.