Skip to content

Commit

Permalink
Added more progressive tests to Monopoly problem
Browse files Browse the repository at this point in the history
  • Loading branch information
xpmatteo committed Dec 12, 2014
1 parent 33fae32 commit 90dc99f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/java/it/xpug/ocp/monopoly/MonopolyPlayer.java
@@ -1,14 +1,16 @@
package it.xpug.ocp.monopoly;

import java.util.*;


public class MonopolyPlayer {

private int balance;
private String playerName;
private List<Object> ownedProperties = new ArrayList<Object>();

public MonopolyPlayer(String playerName) {
}

public void landsOn(String squareName) {
this.playerName = playerName;
}

public void setBalance(int newBalance) {
Expand All @@ -23,7 +25,19 @@ public Object location() {
return null;
}

public String playerName() {
return playerName;
}

public void addOwnedProperty(String squareName) {
ownedProperties.add(squareName);
}

public boolean isOwned(String squareName) {
return ownedProperties.contains(squareName);
}

public void landsOn(String squareName) {
}

}
29 changes: 29 additions & 0 deletions src/test/java/it/xpug/ocp/monopoly/MonopolyTest.java
Expand Up @@ -59,6 +59,35 @@ public void incomeTax() throws Exception {
assertEquals(1000 - 100, bob.balance());
}

@Test@Ignore
public void nameGift() throws Exception {
// This square exists only in some very rare editions of Monopoly
// The player receives one euro for each letter of his or her name
alice.setBalance(100);
alice.landsOn("GIFT OF NAME");
assertEquals(100 + 5, alice.balance());

bob.setBalance(100);
bob.landsOn("GITF OF NAME");
assertEquals(1000 + 3, bob.balance());
}

@Test@Ignore
public void utilityTax() throws Exception {
// This square exists only in some very rare editions of Monopoly
// The player pays 10 for every Utility he or she owns
// The utilities are: ELECTRIC COMPANY and WATER WORKS
alice.setBalance(1000);
alice.addOwnedProperty("ELECTRIC COMPANY");
alice.landsOn("UTILITY TAX");
assertEquals(1000 - 10, alice.balance());

bob.setBalance(1000);
bob.addOwnedProperty("ELECTRIC COMPANY");
bob.addOwnedProperty("WATER WORKS");
bob.landsOn("UTILITY TAX");
assertEquals(1000 - 20, bob.balance());
}

@Test@Ignore
public void payRentOnUnimprovedProperty() throws Exception {
Expand Down

0 comments on commit 90dc99f

Please sign in to comment.