diff --git a/bin/controller/Cashflow.class b/bin/controller/Cashflow.class index c10ba02..dee42c4 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 79090e1..4a98248 100644 --- a/src/controller/Cashflow.java +++ b/src/controller/Cashflow.java @@ -16,13 +16,14 @@ public static void main(String[] args) /* * Just testing stuff in here for now. Main method will call the go() method when game is built */ - - testCards(); - + testGamePlay(); } + + + public void go() { // Joe @@ -58,17 +59,24 @@ public void play() public boolean isWinner() { + boolean isWinner = false; for(Player p : _players) { if(p.hasWon()) { return true; } - else - return false; } + return isWinner; + } + + private static void testGamePlay() + { + GameBoard g = new GameBoard(); } + + public static void testCards() { BigDealStack ms = new BigDealStack(); @@ -76,11 +84,15 @@ public static void testCards() for(int i=0; i +public class CardStack extends LinkedList { private static final long serialVersionUID = 1L; private int _size; @@ -21,18 +21,18 @@ public CardStack() } @Override - public Card push(Card c) + public void push(Card c) { _size++; - return super.push(c); + super.addFirst(c); } @Override public Card pop() { - Card c = super.pop(); + Card c = super.removeFirst(); _size--; - super.add(c); + super.addLast(c); return c; } diff --git a/src/model/FinancialStatement.java b/src/model/FinancialStatement.java index 0d800dd..0508cb9 100644 --- a/src/model/FinancialStatement.java +++ b/src/model/FinancialStatement.java @@ -70,6 +70,7 @@ public FinancialStatement(Profession p) // Assets _assets = 0; _savings = p.getSavings(); + _stock = null; _realEstate = new ArrayList(); // Liabilities @@ -94,7 +95,7 @@ private void update() { _income = _salary + _REcashFlow; _expenses = _taxes + _homeMortgagePayment + _schoolLoanPayment + _carLoanPayment + _creditCardPayment + _otherExpenses + (_perChildExpense * _numChildren); - _assets = getOwnedREValue() + _savings; + _assets = getOwnedREValue() + getStockValue() + _savings; _liabilities = _homeMortgage + _schoolLoans + _carLoans + _creditCardDebt; _passiveIncome = getPassiveIncome(); @@ -113,6 +114,16 @@ private int getPassiveIncome() } return passiveInc; } + + public int getStockValue() + { + if(_stock == null) { + return 0; + } + else { + return _stock.getNumShares() * _stock.getSharePrice(); + } + } public int getOwnedREValue() { @@ -124,11 +135,20 @@ public int getOwnedREValue() return reValue; } + public boolean canBuy(int price) + { + return price < _cashBalance; + } + + public boolean hasStock() + { + return _stock != null; + } + public void buyProperty(OwnedRealEstate newProperty) { _cashBalance -= newProperty.getDownPayment(); _realEstate.add(newProperty); - update(); } @@ -144,11 +164,12 @@ public void sellStock() { _cashBalance += _stock.getSharePrice() * _stock.getNumShares(); _stock = null; + update(); } public void addChild() { - // People can only have 3 children + // People can only have a max of 3 children if(_numChildren < 3) { _numChildren++; @@ -156,8 +177,6 @@ public void addChild() update(); } - - public int getCashBalance() { return _cashBalance; @@ -166,6 +185,7 @@ public int getCashBalance() public void increaseCashBalance(int cashIncrease) { this._cashBalance =+ cashIncrease; + update(); } @@ -175,9 +195,3 @@ public void increaseCashBalance(int cashIncrease) - - - - - - diff --git a/src/model/GameBoard.java b/src/model/GameBoard.java index e0f48f9..672ae2c 100644 --- a/src/model/GameBoard.java +++ b/src/model/GameBoard.java @@ -22,7 +22,7 @@ public GameBoard() } - // TODO This method will move the player and returns the number of paydays they passed along the way. + // TODO This method will move the player and returns the number of pay days they passed 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 int movePlayer(Player p, int distance) diff --git a/src/model/TileCircularLinkedList.java b/src/model/TileCircularLinkedList.java index 5a15fd7..927eabc 100644 --- a/src/model/TileCircularLinkedList.java +++ b/src/model/TileCircularLinkedList.java @@ -23,11 +23,11 @@ public Tile getData() { //add a new node at the start of the linked list public void addNodeAtStart(Tile tile){ Node n = new Node(tile); - if(size==0){ + if(size==0) { head = n; tail = n; n.next = head; - }else{ + } else { Node temp = head; n.next = temp; head = n; @@ -37,7 +37,7 @@ public void addNodeAtStart(Tile tile){ } - public void addNodeAtEnd(Tile tile){ + public void addNodeAtEnd(Tile tile) { if(size==0){ addNodeAtStart(tile); }else{