Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sup again again
  • Loading branch information
Joe Hill committed Mar 30, 2017
1 parent cefe245 commit 69d148c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 29 deletions.
Binary file modified bin/controller/Cashflow.class
Binary file not shown.
26 changes: 19 additions & 7 deletions src/controller/Cashflow.java
Expand Up @@ -16,13 +16,14 @@ public class Cashflow
/*
* Just testing stuff in here for now. Main method will call the go() method when game is built
*/

testCards();

testGamePlay();

}





public void go()
{
// Joe
Expand Down Expand Up @@ -58,29 +59,40 @@ public class Cashflow

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();
int initialSize = ms.getSize();
for(int i=0; i<initialSize; i++)
{
int num = i+1;
System.out.println(num + ": " + (ms.get(i).getTitle())); //Always going to need this cast when getting description unfortunately
System.out.println(num + ": " + ms.get(i).getTitle()); //Always going to need this cast when getting description unfortunately
}

Card c1 = ms.pop();
Card c2 = ms.pop();


System.out.println("Just popped: " + ms.pop().getTitle());
System.out.println("Just popped: " + c1.getTitle());
System.out.println("Just popped: " + c2.getTitle());

for(int i=0; i<initialSize; i++)
{
Expand Down
14 changes: 7 additions & 7 deletions src/model/CardStack.java
@@ -1,15 +1,15 @@
package model;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Random;
import java.util.Stack;

/**
* Made this class just to add functionality to a general stack to keep track of its size
* This class extends Java's linked list but had added methods to make interacting with the card stack much easier
* @author Joe
*
*/
public class CardStack extends Stack<Card>
public class CardStack extends LinkedList<Card>
{
private static final long serialVersionUID = 1L;
private int _size;
Expand All @@ -21,18 +21,18 @@ public class CardStack extends Stack<Card>
}

@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;
}

Expand Down
36 changes: 25 additions & 11 deletions src/model/FinancialStatement.java
Expand Up @@ -70,6 +70,7 @@ public class FinancialStatement
// Assets
_assets = 0;
_savings = p.getSavings();
_stock = null;
_realEstate = new ArrayList<OwnedRealEstate>();

// Liabilities
Expand All @@ -94,7 +95,7 @@ public class FinancialStatement
{
_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();
Expand All @@ -113,6 +114,16 @@ public class FinancialStatement
}
return passiveInc;
}

public int getStockValue()
{
if(_stock == null) {
return 0;
}
else {
return _stock.getNumShares() * _stock.getSharePrice();
}
}

public int getOwnedREValue()
{
Expand All @@ -124,11 +135,20 @@ public class FinancialStatement
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();
}

Expand All @@ -144,20 +164,19 @@ public class FinancialStatement
{
_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++;
}
update();
}



public int getCashBalance()
{
return _cashBalance;
Expand All @@ -166,6 +185,7 @@ public class FinancialStatement
public void increaseCashBalance(int cashIncrease)
{
this._cashBalance =+ cashIncrease;
update();
}


Expand All @@ -175,9 +195,3 @@ public class FinancialStatement









2 changes: 1 addition & 1 deletion src/model/GameBoard.java
Expand Up @@ -22,7 +22,7 @@ public class 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)
Expand Down
6 changes: 3 additions & 3 deletions src/model/TileCircularLinkedList.java
Expand Up @@ -23,11 +23,11 @@ public class TileCircularLinkedList
//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;
Expand All @@ -37,7 +37,7 @@ public class TileCircularLinkedList
}


public void addNodeAtEnd(Tile tile){
public void addNodeAtEnd(Tile tile) {
if(size==0){
addNodeAtStart(tile);
}else{
Expand Down

0 comments on commit 69d148c

Please sign in to comment.