Skip to content

Commit

Permalink
Alot of things are unfinished so don't hate me
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Hill committed Mar 25, 2017
1 parent cb3f002 commit 0e74032
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 19 deletions.
Binary file modified bin/controller/Cashflow.class
Binary file not shown.
9 changes: 4 additions & 5 deletions src/controller/Cashflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -42,7 +42,6 @@ public void go()
// Initialize game board
// Initialize GUI
// Initialize players (pick professions)
// Initialize cards


/*
Expand All @@ -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)
}
Expand All @@ -76,7 +76,6 @@ public boolean isWinner()
if(p.hasWon())
{
return true;
break;
}
else
return false;
Expand Down
41 changes: 41 additions & 0 deletions src/model/DealTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}



}
31 changes: 29 additions & 2 deletions src/model/FinancialStatement.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<OwnedRealEstate> _realEstate = new ArrayList<OwnedRealEstate>();

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();
Expand All @@ -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);

Expand Down Expand Up @@ -67,4 +86,12 @@ public void display()
{

}

public int getCashBalance() {
return _cashBalance;
}

public void increaseCashBalance(int cashIncrease) {
this._cashBalance =+ cashIncrease;
}
}
27 changes: 27 additions & 0 deletions src/model/GameBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.LinkedList;
import java.util.Queue;
import model.TileCircularLinkedList.Node;

public class GameBoard
{
Expand All @@ -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<distance; i++)
{
Node nextNode = currentNode.getNext();
if(nextNode.getData().getName().equals("Payday"))
{
passedPayday = true;
}
currentNode = nextNode;
}
currentNode.getData().addPlayer(p);
p.setLocation(currentNode.getData().getBoardIndex());
return passedPayday;
}


}
5 changes: 1 addition & 4 deletions src/model/MarketStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,9 @@ public MarketStack()
*
*
*/
<<<<<<< HEAD
/*
=======

private static MarketCard currentcard = new MarketCard(null, null, null, 1, null);

>>>>>>> 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
Expand Down
33 changes: 33 additions & 0 deletions src/model/OwnedRealEstate.java
Original file line number Diff line number Diff line change
@@ -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;
}






}
21 changes: 15 additions & 6 deletions src/model/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

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
private int _DownsizeCount; //downsize counter
private int _location;
private boolean _winner = false;

public Player() { //constructor
// TODO: Pick profession
_location = 0;
}


public boolean hasWon() {
return _winner;
}
Expand All @@ -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

}



}
38 changes: 38 additions & 0 deletions src/model/Stock.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
18 changes: 17 additions & 1 deletion src/model/Tile.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package model;

import java.util.ArrayList;

public class Tile
{
private String _name;
private int _boardIndex;
private Player[] _players;
private ArrayList<Player> _players;

public Tile(String name, int boardIndex)
{
Expand All @@ -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);
}

}
2 changes: 1 addition & 1 deletion src/model/TileCircularLinkedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class TileCircularLinkedList
{
class Node {
public class Node {
Tile t;
Node next;
public Node(Tile tile) {
Expand Down

0 comments on commit 0e74032

Please sign in to comment.