diff --git a/bin/controller/Cashflow.class b/bin/controller/Cashflow.class index d6dc11f..79d608d 100644 Binary files a/bin/controller/Cashflow.class and b/bin/controller/Cashflow.class differ diff --git a/src/controller/Cashflow.java b/src/controller/Cashflow.java index e014536..ab4cab2 100644 --- a/src/controller/Cashflow.java +++ b/src/controller/Cashflow.java @@ -9,7 +9,7 @@ public class Cashflow private GameBoard _board; private Player[] _players; - private CardStack[] _cards; + //private CardStack[] _cards; public static void main(String[] args) { @@ -42,7 +42,6 @@ public void go() // Initialize game board // Initialize GUI // Initialize players (pick professions) - // Initialize cards /* @@ -58,12 +57,13 @@ public void play() { while(!isWinner()) { + // TODO Play method + // Get player whose turn it is // Check down sized (check if player's downsize counter is 0) // Check charity (Check if charity counter is 0) // Roll dice // Move player (Have to wrap tiles to next tile after last tile is the beginning) - // Get card from tile (Method in tile to get card from its type or perform action for baby, down size, or charity) - // Perform card/tile action + // Call tile's getLandedOn method // Update current/all players' financials // Increment player array (Also needs to wrap like tiles array) } @@ -76,7 +76,6 @@ public boolean isWinner() if(p.hasWon()) { return true; - break; } else return false; diff --git a/src/model/DealTile.java b/src/model/DealTile.java index 0865435..d99ee2c 100644 --- a/src/model/DealTile.java +++ b/src/model/DealTile.java @@ -2,9 +2,50 @@ public class DealTile extends Tile { + private static SmallDealStack _smallDealStack; + private static BigDealStack _bigDealStack; + private static int _stockPrice; + public DealTile(String type, int boardIndex) { super(type, boardIndex); + _smallDealStack = new SmallDealStack(); + _bigDealStack = new BigDealStack(); + } + + @Override + public void getLandedOn() + { + // TODO + // Ask user to decide big/small deal: + // Pick card from big/small deal stack: + // If stock, update price, then ask user if they want to buy and ask everyone if they want to sell: + // If property, ask user if they want to do it: + // If yes, call ButIncomeProperty method: + // Else, do nothing: + } + + public void buyIncomeProperty(Player p, DealCard d) + { + FinancialStatement f = p.getFinancialStatement(); + + f.increaseCashBalance(-d.getDownPayment()); // Watch out for negatives + f.increasePassiveIncome(d.getCashFlowChange()); + + OwnedRealEstate newProperty = new OwnedRealEstate(d.getTitle(), d.getCost(), d.getDownPayment()); + f.addProperty(newProperty); + } + + public void updateStockPrice(DealCard d) + { + _stockPrice = d.getCost(); + } + + public void buyStock(Player p) + { } + + + } diff --git a/src/model/FinancialStatement.java b/src/model/FinancialStatement.java index 27e1816..f1187f4 100644 --- a/src/model/FinancialStatement.java +++ b/src/model/FinancialStatement.java @@ -1,7 +1,11 @@ package model; +import java.util.ArrayList; + + public class FinancialStatement { + private int _cashBalance; private double salary; private double interest; private double[] realEstate; @@ -10,14 +14,17 @@ public class FinancialStatement public static double assets; //sorry i had to make this change to use w/ cards if i messed something up just change it im sorry!! private double liabilities; private double income; + private Stock _stock; + private ArrayList _realEstate = new ArrayList(); public FinancialStatement(Profession p) { + // TODO Set each major line item to the sum of the smaller ones salary = p.getSalary(); } - public void setChildExp(int i) // One fo these for each of the little line items that actually change + public void setChildExp(int i) // One of these for each of the little line items that actually change { //childExp = i; update(); @@ -33,7 +40,19 @@ private void update() } - + public void buyStock(int numShares, int sharePrice) + { + _stock = new Stock(numShares, sharePrice); + int cashOut = _stock.getCashOut(); + _cashBalance += cashOut; // getCashOut() will negate the value automatically so we will add not subtract + } + + public void sellStock() + { + _cashBalance += _stock.getSharePrice() * _stock.getNumShares(); + _stock = null; + } + Profession p = new Profession("Teacher", 3300, 500, 500, 100, 100, 200, 700, 0, 0, 200, 400, 50000, 12000, 5000, 4000); @@ -67,4 +86,12 @@ public void display() { } + + public int getCashBalance() { + return _cashBalance; + } + + public void increaseCashBalance(int cashIncrease) { + this._cashBalance =+ cashIncrease; + } } diff --git a/src/model/GameBoard.java b/src/model/GameBoard.java index 874ca93..23026f9 100644 --- a/src/model/GameBoard.java +++ b/src/model/GameBoard.java @@ -2,6 +2,7 @@ import java.util.LinkedList; import java.util.Queue; +import model.TileCircularLinkedList.Node; public class GameBoard { @@ -20,4 +21,30 @@ public GameBoard() _tiles.addTiles(t1, t2, t3, t4); } + + // TODO This method will move the player and return true if they passed a payday along the way. + // It also removes the player from the _players ArrayList of their initial tile and adds them to the + // arraylist of the tile they land on + public boolean movePlayer(Player p, int distance) + { + int currentLocation = p.getLocation(); + Node currentNode = _tiles.get(currentLocation); + Tile currentTile = _tiles.elementAt(currentLocation); + currentTile.removePlayer(p); + boolean passedPayday = false; + for(int i=0; i>>>>>> branch 'master' of https://github.uconn.edu/joh13010/2102-Group-Project-Spring-2017.git public void Action(Player player){ currentcard = _marketCardStack.pop(); currentcard.display(); //will be a method in MarketCard to display the GUI for the card diff --git a/src/model/OwnedRealEstate.java b/src/model/OwnedRealEstate.java new file mode 100644 index 0000000..7c2c321 --- /dev/null +++ b/src/model/OwnedRealEstate.java @@ -0,0 +1,33 @@ +package model; + +public class OwnedRealEstate +{ + private String _name; + private int _price; + private int _downPayment; + + public OwnedRealEstate(String name, int price, int downPayment) + { + _name = name; + _price = price; + _downPayment = downPayment; + } + + public String getName() { + return _name; + } + + public int getPrice() { + return _price; + } + + public int getDownPayment() { + return _downPayment; + } + + + + + + +} diff --git a/src/model/Player.java b/src/model/Player.java index c8972bd..33ae03f 100644 --- a/src/model/Player.java +++ b/src/model/Player.java @@ -2,7 +2,7 @@ public class Player { - public FinancialStatement _fs; //financial statement of user + private FinancialStatement _fs; //financial statement of user //idNumber? // public boolean _charity; private int _CharityCount; //charity counter @@ -10,6 +10,12 @@ public class Player private int _location; private boolean _winner = false; + public Player() { //constructor + // TODO: Pick profession + _location = 0; + } + + public boolean hasWon() { return _winner; } @@ -19,22 +25,25 @@ public void pickCard() { } + public FinancialStatement getFinancialStatement() + { + return _fs; + } + public boolean donateCharity() { // return false; } - public void setLocation() { - + public void setLocation(int i) { + _location = i; } public int getLocation() { return this._location; } - public Player() { //constructer - - } + } diff --git a/src/model/Stock.java b/src/model/Stock.java new file mode 100644 index 0000000..d224b57 --- /dev/null +++ b/src/model/Stock.java @@ -0,0 +1,38 @@ +package model; + +public class Stock +{ + private static int _sharePrice; + private int _numShares; + + public Stock(int sharePrice, int numShares) + { + _sharePrice = sharePrice; + _numShares = numShares; + } + + public void setSharePrice(int newPrice) + { + _sharePrice = newPrice; + } + + public int getSharePrice() + { + return _sharePrice; + } + + /** + * + * @return returns NEGATED version of the cash outlay for a stock + */ + public int getCashOut() + { + return -1 * _sharePrice * _numShares; + } + + public int getNumShares() + { + return _numShares; + } + +} \ No newline at end of file diff --git a/src/model/Tile.java b/src/model/Tile.java index acce69a..3e37e71 100644 --- a/src/model/Tile.java +++ b/src/model/Tile.java @@ -1,10 +1,12 @@ package model; +import java.util.ArrayList; + public class Tile { private String _name; private int _boardIndex; - private Player[] _players; + private ArrayList _players; public Tile(String name, int boardIndex) { @@ -22,5 +24,19 @@ public String getName() return _name; } + public void getLandedOn() + { + + } + + public void addPlayer(Player p) + { + _players.add(p); + } + + public void removePlayer(Player p) + { + _players.remove(p); + } } diff --git a/src/model/TileCircularLinkedList.java b/src/model/TileCircularLinkedList.java index 6935b42..5a15fd7 100644 --- a/src/model/TileCircularLinkedList.java +++ b/src/model/TileCircularLinkedList.java @@ -2,7 +2,7 @@ public class TileCircularLinkedList { - class Node { + public class Node { Tile t; Node next; public Node(Tile tile) {