Skip to content

Commit

Permalink
Make sure to check what financial statement covers before you guys work
Browse files Browse the repository at this point in the history
on the player class
  • Loading branch information
Joe Hill committed Mar 30, 2017
1 parent f7c3fce commit cefe245
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 62 deletions.
13 changes: 3 additions & 10 deletions src/model/DealTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ public void getLandedOn()
// 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 property, ask user if they want to do it (and check if they can afford the down payment):
// If yes, call ButIncomeProperty method:
// Else, do nothing:
}

public void buyIncomeProperty(Player p, DealCard d)
{
FinancialStatement f = p.getFinancialStatement();

OwnedRealEstate newProperty = new OwnedRealEstate(d.getTitle(), d.getCost(), d.getDownPayment());
f.addProperty(newProperty);

// Add functionality in this ^^ to do this:

//f.increaseCashBalance(-d.getDownPayment()); // Watch out for negatives
//f.increasePassiveIncome(d.getCashFlowChange());

OwnedRealEstate newProperty = new OwnedRealEstate(d.getTitle(), d.getCost(), d.getDownPayment(), d.getCashFlowChange());
f.buyProperty(newProperty);

}

Expand Down
186 changes: 136 additions & 50 deletions src/model/FinancialStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,142 @@

import java.util.ArrayList;


public class FinancialStatement
{
private Profession _profession;

private int _cashBalance;
private double salary;
private double interest;
private double[] realEstate;
private String career;
private double expenses;
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;

// Income
private int _income; // needs getter and incrementer
private int _salary;
private int _REcashFlow; // needs getter and incrementer

// Expenses
private int _expenses; // needs getter and incrementer
private int _taxes;
private int _homeMortgagePayment;
private int _schoolLoanPayment;
private int _carLoanPayment;
private int _creditCardPayment;
private int _otherExpenses;
private int _perChildExpense;
private int _numChildren; // needs getter and incrementer

// Assets
private int _assets;
private int _savings;
private Stock _stock;
private ArrayList<OwnedRealEstate> _realEstate = new ArrayList<OwnedRealEstate>();
private ArrayList<OwnedRealEstate> _realEstate;

// Liabilities
private int _liabilities;
private int _homeMortgage;
private int _schoolLoans;
private int _carLoans;
private int _creditCardDebt;

// Cash flows (top right of actual financial statement)
private int _monthlySalary;
private int _passiveIncome;
private int _totalIncome;
private int _totalExpenses;
private int _monthlyCashFlow;
private boolean _hasWon;



public FinancialStatement(Profession p)
{
// TODO Set each major line item to the sum of the smaller ones
salary = p.getSalary();
_profession = p;

// Income
_income = 0;
_salary = p.getSalary();
_REcashFlow = 0;

// Expenses
_expenses = 0;
_taxes = p.getTaxes();
_homeMortgagePayment = p.getMortgagePay();
_schoolLoanPayment = p.getSchoolLoanPay();
_carLoanPayment = p.getCarLoanPay();
_creditCardPayment = p.getCreditCardPay();
_otherExpenses = p.getOtherExp();
_perChildExpense = p.getChildExpPer();
_numChildren = 0;

// Assets
_assets = 0;
_savings = p.getSavings();
_realEstate = new ArrayList<OwnedRealEstate>();

// Liabilities
_liabilities = 0;
_homeMortgage = p.getMortgage();
_schoolLoans = p.getSchoolLoans();
_carLoans = p.getCarLoans();
_creditCardDebt = p.getCreditCardDebt();

// Cash flows
_monthlySalary = _salary;
_passiveIncome = 0;
_totalIncome = 0;
_totalExpenses = 0;
_monthlyCashFlow = 0;
_hasWon = false;

update();
}

public void setChildExp(int i) // One of these for each of the little line items that actually change
private void update()
{
//childExp = i;
update();
_income = _salary + _REcashFlow;
_expenses = _taxes + _homeMortgagePayment + _schoolLoanPayment + _carLoanPayment + _creditCardPayment + _otherExpenses + (_perChildExpense * _numChildren);
_assets = getOwnedREValue() + _savings;
_liabilities = _homeMortgage + _schoolLoans + _carLoans + _creditCardDebt;

_passiveIncome = getPassiveIncome();
_totalIncome = _monthlySalary + _passiveIncome;
_totalExpenses = _expenses;
_monthlyCashFlow = _totalIncome - _totalExpenses;
_hasWon = _passiveIncome > _totalExpenses;
}

private int getPassiveIncome()
{
int passiveInc = 0;
for(OwnedRealEstate re : _realEstate)
{
passiveInc += re.getCashFlow();
}
return passiveInc;
}

public int getOwnedREValue()
{
int reValue = 0;
for(OwnedRealEstate re : _realEstate)
{
reValue += re.getPrice();
}
return reValue;
}

private void update()
public void buyProperty(OwnedRealEstate newProperty)
{
//expenses = asdf +asdf_A+sdf+ASDf
//income = blah+ blah
//cashflow = bluh + bluh

_cashBalance -= newProperty.getDownPayment();
_realEstate.add(newProperty);

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
update();
}

public void sellStock()
Expand All @@ -53,45 +146,38 @@ public void sellStock()
_stock = null;
}

Profession p = new Profession("Teacher", 3300, 500, 500, 100, 100, 200, 700, 0, 0,
200, 400, 50000, 12000, 5000, 4000);

public double expenses()
public void addChild()
{
expenses = p.getTaxes() + p.getMortgagePay() + p.getSchoolLoanPay() + p.getCarLoanPay()
+ p.getCreditCardPay() + p.getOtherExp() + p.getBankLoanPay() + p.getChildExp();
return expenses;
// People can only have 3 children
if(_numChildren < 3)
{
_numChildren++;
}
update();
}

public double assets()
{
assets = p.getSavings();

return assets;
}

public double liabilities()
{
liabilities = p.getMortgage() + p.getSchoolLoans() + p.getCarLoans() + p.getCreditCardDebt();
return liabilities;
}

public double income()
public int getCashBalance()
{
income = p.getSalary();
return income;
return _cashBalance;
}

public void display()
public void increaseCashBalance(int cashIncrease)
{

this._cashBalance =+ cashIncrease;
}

public int getCashBalance() {
return _cashBalance;
}

public void increaseCashBalance(int cashIncrease) {
this._cashBalance =+ cashIncrease;
}
}











13 changes: 12 additions & 1 deletion src/model/OwnedRealEstate.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ public class OwnedRealEstate
private String _name;
private int _price;
private int _downPayment;
private int _cashFlow;

public OwnedRealEstate(String name, int price, int downPayment)
public OwnedRealEstate(String name, int price, int downPayment, int cashFlow)
{
_name = name;
_price = price;
_downPayment = downPayment;
set_cashFlow(cashFlow);
}

public String getName() {
Expand All @@ -21,10 +23,19 @@ public int getPrice() {
return _price;
}

/**
*
* @return Returns a positive value for down payment!!
*/
public int getDownPayment() {
return _downPayment;
}

public int getCashFlow() {
return _cashFlow;
}





Expand Down
2 changes: 1 addition & 1 deletion src/model/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public FinancialStatement getFinancialStatement()
return _fs;
}

public boolean donateCharity() {
public boolean donateCharity() {
//
return false;
}
Expand Down

0 comments on commit cefe245

Please sign in to comment.