diff --git a/bin/.gitignore b/bin/.gitignore index 66905d0..1f65b37 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,4 +1 @@ -/.DS_Store -/controller/ -/model/ /view/ diff --git a/bin/controller/Cashflow.class b/bin/controller/Cashflow.class index 00469c6..1704d34 100644 Binary files a/bin/controller/Cashflow.class and b/bin/controller/Cashflow.class differ diff --git a/bin/model/DoodadTile.class b/bin/model/DoodadTile.class index 2129309..e466c65 100644 Binary files a/bin/model/DoodadTile.class and b/bin/model/DoodadTile.class differ diff --git a/bin/model/DownsizeTile.class b/bin/model/DownsizeTile.class index 60b4d98..0bed4b5 100644 Binary files a/bin/model/DownsizeTile.class and b/bin/model/DownsizeTile.class differ diff --git a/bin/model/FinancialStatement.class b/bin/model/FinancialStatement.class index fdcff01..19aae0e 100644 Binary files a/bin/model/FinancialStatement.class and b/bin/model/FinancialStatement.class differ diff --git a/bin/model/GameBoard.class b/bin/model/GameBoard.class index 6fed275..252282b 100644 Binary files a/bin/model/GameBoard.class and b/bin/model/GameBoard.class differ diff --git a/bin/model/Tile.class b/bin/model/Tile.class index 655ebd0..7763963 100644 Binary files a/bin/model/Tile.class and b/bin/model/Tile.class differ diff --git a/bin/model/TileCircularLinkedList.class b/bin/model/TileCircularLinkedList.class index 36c46be..51b60d5 100644 Binary files a/bin/model/TileCircularLinkedList.class and b/bin/model/TileCircularLinkedList.class differ diff --git a/bin/view/CharityWindow$2.class b/bin/view/CharityWindow$2.class index d41d311..9816afb 100644 Binary files a/bin/view/CharityWindow$2.class and b/bin/view/CharityWindow$2.class differ diff --git a/bin/view/CharityWindow$3.class b/bin/view/CharityWindow$3.class index 6e12f73..9da374b 100644 Binary files a/bin/view/CharityWindow$3.class and b/bin/view/CharityWindow$3.class differ diff --git a/bin/view/CharityWindow.class b/bin/view/CharityWindow.class index 3415f45..d954bf3 100644 Binary files a/bin/view/CharityWindow.class and b/bin/view/CharityWindow.class differ diff --git a/bin/view/DoodadCardWindow$1.class b/bin/view/DoodadCardWindow$1.class index 155e8d5..8817738 100644 Binary files a/bin/view/DoodadCardWindow$1.class and b/bin/view/DoodadCardWindow$1.class differ diff --git a/bin/view/DoodadCardWindow$2.class b/bin/view/DoodadCardWindow$2.class index 4c4c3be..848faa7 100644 Binary files a/bin/view/DoodadCardWindow$2.class and b/bin/view/DoodadCardWindow$2.class differ diff --git a/bin/view/DoodadCardWindow.class b/bin/view/DoodadCardWindow.class index 6d44673..4339f2b 100644 Binary files a/bin/view/DoodadCardWindow.class and b/bin/view/DoodadCardWindow.class differ diff --git a/bin/view/DownSizeWindow.class b/bin/view/DownSizeWindow.class index dcded3f..241aa27 100644 Binary files a/bin/view/DownSizeWindow.class and b/bin/view/DownSizeWindow.class differ diff --git a/bin/view/FSWindow.class b/bin/view/FSWindow.class index 86276a9..c7b6db6 100644 Binary files a/bin/view/FSWindow.class and b/bin/view/FSWindow.class differ diff --git a/bin/view/MainWindow$1.class b/bin/view/MainWindow$1.class index 1c26d21..419bfb4 100644 Binary files a/bin/view/MainWindow$1.class and b/bin/view/MainWindow$1.class differ diff --git a/bin/view/MainWindow.class b/bin/view/MainWindow.class index 55b39c8..6f8e8c7 100644 Binary files a/bin/view/MainWindow.class and b/bin/view/MainWindow.class differ diff --git a/gameboard.png b/gameboard.png new file mode 100644 index 0000000..50aaab3 Binary files /dev/null and b/gameboard.png differ diff --git a/src/controller/Cashflow.java b/src/controller/Cashflow.java index 867a104..fde4514 100644 --- a/src/controller/Cashflow.java +++ b/src/controller/Cashflow.java @@ -69,9 +69,12 @@ public class Cashflow private static void testGamePlay() { - Player p = new Player(); - System.out.println(p.getFinancialStatement().getProfession().getName()); - GameBoard g = new GameBoard(); + Player p1 = new Player(); + Player p2 = new Player(); + GameBoard g = new GameBoard(p1, p2); + System.out.println(p1.getLocation()); + g.movePlayer(p1, 5); + System.out.println(p1.getLocation()); } diff --git a/src/model/DoodadTile.java b/src/model/DoodadTile.java index 97bc6b5..f0bee71 100644 --- a/src/model/DoodadTile.java +++ b/src/model/DoodadTile.java @@ -1,5 +1,7 @@ package model; +import view.*; + public class DoodadTile extends Tile { private static DoodadStack _doodadStack; @@ -15,6 +17,10 @@ public class DoodadTile extends Tile { FinancialStatement f = p.getFinancialStatement(); DoodadCard dc = _doodadStack.pickCard(); + + DoodadCardWindow DoodadCardWindow = new DoodadCardWindow(); + DoodadCardWindow.showButtonDemo(); + int amount = dc.getValue(); if (f.getCashBalance() > amount) { diff --git a/src/model/DownsizeTile.java b/src/model/DownsizeTile.java index 87a49e8..96f4dc3 100644 --- a/src/model/DownsizeTile.java +++ b/src/model/DownsizeTile.java @@ -1,5 +1,7 @@ package model; +import view.DownSizeWindow; + public class DownsizeTile extends Tile{ public DownsizeTile(String type, int boardIndex) { @@ -10,5 +12,11 @@ public class DownsizeTile extends Tile{ public void getLandedOn(Player p) { p.increaseDownsizeCount(); + + DownSizeWindow DownSizeWindow = new DownSizeWindow(); + DownSizeWindow.showButtonDemo(); + + // TODO + System.out.println("Player landed on downsized"); } } diff --git a/src/model/FinancialStatement.java b/src/model/FinancialStatement.java index b09e122..c3f2d1d 100644 --- a/src/model/FinancialStatement.java +++ b/src/model/FinancialStatement.java @@ -205,27 +205,117 @@ public class FinancialStatement return _totalIncome; } - public int getSalary() +<<<<<<< HEAD + +======= + //income getters + public int getIncome() + { + return _income; + } + public int getSalary() { return _salary; } + public int getREcashFlow() + { + return _REcashFlow; + } - public int getSalary() + //expense getters + public int getExpenses() { - return _salary; + return _expenses; + } + public int getTaxes() + { + return _taxes; + } + public int getHomeMortgagePayment() + { + return _homeMortgagePayment; + } + public int getSchoolLoanPayment() + { + return _schoolLoanPayment; + } + public int getCarLoanPayment() + { + return _carLoanPayment; + } + public int getCreditCardPayment() + { + return _creditCardPayment; + } + public int getOtherExpenses() + { + return _otherExpenses; + } + public int getPerChildExpense() + { + return _perChildExpense; + } + public int getNumChildren() + { + return _numChildren; } - public int getSalary() + //assets getters + public int getAssets() { - return _salary; - } - public int getSalary() + return _assets; + } + public int getSavings() { - return _salary; + return _savings; } - public int getSalary() + + public int getStock() { - return _salary; + return _stock.getNumShares() * _stock.getSharePrice(); + } + //for realestate,maybe +// public int get() +// { +// return _; +// } + + //liabilities getters + public int getLiabilities() + { + return _liabilities; + } + public int getHomeMortgage() + { + return _homeMortgage; + } + public int getSchoolLoans() + { + return _schoolLoans; + } + public int getCarLoans() + { + return _carLoans; + } + public int getCreditCardDebt() + { + return _creditCardDebt; + } + + //additonal cash flow getters + public int getMonthlySalary() + { + return _monthlySalary; + } + + public int getTotalExpenses() + { + return _totalExpenses; + } + + public int getMonthlyCashflow() { + // TODO Auto-generated method stub + return _monthlyCashFlow; } } diff --git a/src/model/GameBoard.java b/src/model/GameBoard.java index fcb451c..91f967d 100644 --- a/src/model/GameBoard.java +++ b/src/model/GameBoard.java @@ -41,16 +41,13 @@ public class GameBoard { _profs = new Professions(); _tiles = new TileCircularLinkedList(); - _tiles.addTiles(t1, t2, t3, t4); + _tiles.addTiles(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24); t1.addPlayers(players); } - public Tile getTile(int num) { - ArrayList tileList = new ArrayList(); - Tile[] tileList1 = { - t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24 - }; - tileList.addAll(Arrays.asList(tileList1)); - return tileList.get(num); + + + public Tile getTile(int index) { + return _tiles.get(index).getData(); } // TODO This method will move the player and returns the number of pay days they passed along the way. @@ -70,6 +67,10 @@ public class GameBoard { passedPaydays++; } + + // TODO update player location on board each iteration and maybe add delay + System.out.println("Player is at tile number: " + currentNode.getData().getBoardIndex()); + currentNode = nextNode; } currentNode.getData().addPlayers(p); diff --git a/src/model/Stock.java b/src/model/Stock.java index d224b57..c821ab1 100644 --- a/src/model/Stock.java +++ b/src/model/Stock.java @@ -35,4 +35,5 @@ public class Stock return _numShares; } + } \ No newline at end of file diff --git a/src/model/Tile.java b/src/model/Tile.java index 3342262..dac1f40 100644 --- a/src/model/Tile.java +++ b/src/model/Tile.java @@ -10,6 +10,7 @@ public class Tile public Tile(String name, int boardIndex) { + _players = new ArrayList(); _name = name; _boardIndex = boardIndex; } diff --git a/src/model/TileCircularLinkedList.java b/src/model/TileCircularLinkedList.java index 927eabc..b7834cb 100644 --- a/src/model/TileCircularLinkedList.java +++ b/src/model/TileCircularLinkedList.java @@ -64,7 +64,7 @@ public class TileCircularLinkedList return null; } Node n = head; - while(index-1!=0){ + while(index!=0){ n=n.next; index--; } @@ -76,7 +76,7 @@ public class TileCircularLinkedList return null; } Node n = head; - while(index-1!=0){ + while(index!=0){ n=n.next; index--; } diff --git a/src/view/.DS_Store b/src/view/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/src/view/.DS_Store differ diff --git a/src/view/CharityWindow.java b/src/view/CharityWindow.java index 99f61e2..39595e0 100644 --- a/src/view/CharityWindow.java +++ b/src/view/CharityWindow.java @@ -59,17 +59,13 @@ public class CharityWindow { Donate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - //put message that they donated xx dollars after 10 seconds, close window + //update cashbalance for player try { - Thread.sleep(1000); + Thread.sleep(1); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } - - statusLabel.setText("Good Job! You donated all your savings!"); - - System.exit(0); } }); @@ -77,7 +73,7 @@ public class CharityWindow { DontDonate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //put message that they are greedy. after 10 seconds, close window - System.exit(0); + System.exit(0); } }); controlPanel.add(Donate); diff --git a/src/view/DoodadCardWindow.java b/src/view/DoodadCardWindow.java index 8a34247..a27ce9c 100644 --- a/src/view/DoodadCardWindow.java +++ b/src/view/DoodadCardWindow.java @@ -16,6 +16,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; +import model.DoodadCard; + public class DoodadCardWindow { private JFrame mainFrame; private JLabel headerLabel; @@ -23,13 +25,13 @@ public class DoodadCardWindow { private JPanel controlPanel; public DoodadCardWindow(){ - prepareGUI(); + prepareGUI(null); } public static void main(String[] args){ DoodadCardWindow DoodadCardWindow = new DoodadCardWindow(); DoodadCardWindow.showButtonDemo(); } - private void prepareGUI(){ + private void prepareGUI(DoodadCard dc){ mainFrame = new JFrame("Doodad"); mainFrame.getContentPane().setBackground(new Color(250, 51, 51)); mainFrame.setSize(350,250); @@ -56,7 +58,7 @@ public class DoodadCardWindow { mainFrame.setVisible(true); } - private void showButtonDemo(){ + public void showButtonDemo(){ headerLabel.setText("Call Doodad Title here"); statusLabel.setText("Call Doodad Description here"); //resources folder should be inside SWING folder. diff --git a/src/view/DownSizeWindow.java b/src/view/DownSizeWindow.java index f032ed6..8f9265a 100644 --- a/src/view/DownSizeWindow.java +++ b/src/view/DownSizeWindow.java @@ -54,7 +54,7 @@ public class DownSizeWindow { mainFrame.setVisible(true); } - private void showButtonDemo(){ + public void showButtonDemo(){ headerLabel.setText("Downsize"); statusLabel.setText("You lose 3 turns."); //resources folder should be inside SWING folder. diff --git a/src/view/FSWindow.java b/src/view/FSWindow.java index fb49517..66a5cfd 100644 --- a/src/view/FSWindow.java +++ b/src/view/FSWindow.java @@ -3,7 +3,6 @@ import java.awt.*; import java.awt.Window; import java.awt.event.*; import javax.swing.*; - import model.*; import controller.*; @@ -18,14 +17,23 @@ public class FSWindow { public FSWindow(){ } +/* public static void main(String[] args){ FSWindow FSWindow = new FSWindow(); FSWindow.prepareGUI(); FSWindow.showButtonDemo(); - } - private void prepareGUI() + }*/ + //private void prepareGUI() + +// public static void main(String[] args){ +// FSWindow FSWindow = new FSWindow(); +// FSWindow.prepareGUI(); +// FSWindow.showButtonDemo(); +// } + private void prepareGUI(Player p) + { -// FinancialStatement currentFS = p.getFinancialStatement(); + FinancialStatement currentFS = p.getFinancialStatement(); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); @@ -38,7 +46,8 @@ public class FSWindow { mainTab.setLayout(new BoxLayout(mainTab, BoxLayout.Y_AXIS)); JLabel salary = new JLabel(); - //set salary to salary variable here + JTextField salarynum = new JTextField(currentFS.getSalary()); + salary.add(salarynum); mainTab.add(salary); JLabel plusSymbol = new JLabel("+"); @@ -47,7 +56,8 @@ public class FSWindow { mainTab.add(plusSymbol); JLabel passiveincome = new JLabel(); - //set passiveincome to passiveincome variable here + JTextField pIncome = new JTextField(currentFS.getREcashFlow()); + passiveincome.add(pIncome); JLabel passiveMes = new JLabel("Cash Flow from Interest/Dividends and Real Estate/Business"); passiveincome.setFont(new Font("Verdana",1,35)); passiveincome.setAlignmentX(Component.CENTER_ALIGNMENT); @@ -62,7 +72,8 @@ public class FSWindow { mainTab.add(equalSymbol); JLabel totalincome = new JLabel(); - //set totalincome to totalincome variable here + JTextField tincomenum = new JTextField(currentFS.getTotalIncome()); + totalincome.add(tincomenum); totalincome.setFont(new Font("Verdana",1,35)); totalincome.setAlignmentX(Component.CENTER_ALIGNMENT); mainTab.add(totalincome); @@ -73,7 +84,8 @@ public class FSWindow { mainTab.add(minusSymbol); JLabel totalexpense = new JLabel(); - //set totalexpense to totalexpense variable here + JTextField texpensenum = new JTextField(currentFS.getTotalExpenses()); + totalincome.add(texpensenum); totalincome.setFont(new Font("Verdana",1,35)); totalincome.setAlignmentX(Component.CENTER_ALIGNMENT); mainTab.add(totalexpense); @@ -84,7 +96,8 @@ public class FSWindow { mainTab.add(equalSymbol2); JLabel cashflow = new JLabel(); - //set cashflow to cashflow variable here + JTextField cashflownum = new JTextField(currentFS.getMonthlyCashflow()); + cashflow.add(cashflownum); totalincome.setFont(new Font("Verdana",1,35)); totalincome.setAlignmentX(Component.CENTER_ALIGNMENT); mainTab.add(cashflow); @@ -95,12 +108,23 @@ public class FSWindow { String[] incomeColumns = {"Description", "CashFlow"}; Object[][] income = { {"Description", "CashFlow"}, + //{"Salary","" currentFS.getSalary()}, {"Interest/dividends", ""/**call interest of user*/}, {"Real Estate/Business",""/**business of user*/}, {"Real Estate/Business",""/**business of user*/}, {"Real Estate/Business",""/**business of user*/}, {"Real Estate/Business",""/**business of user*/}, + + {"Salary",currentFS.getMonthlySalary()}, + {"Interest/dividends", "0"}, + + //another table for real estate + {"Real Estate/Business",/**business of user*/}, + {"Real Estate/Business",/**business of user*/}, + {"Real Estate/Business",/**business of user*/}, + {"Real Estate/Business",/**business of user*/}, + }; JTable incomeTable = new JTable(income, incomeColumns); @@ -111,15 +135,13 @@ public class FSWindow { String[] expenseColumns = {"Description", "CashFlow"}; Object[][] expense = { {"Description", "CashFlow"}, - {"Taxes",""/**user variable*/}, - {"Home Mortgage Payment", ""/**user variable**/}, - {"School Loan Payment",""/**user variable**/}, - {"Car Loan Payment",""/**user variable**/}, - {"Credit Card Payment",""/**user variable**/}, - {"Other Expenses",""/**user variable**/}, - {"Bank Loan Payment",""/**user variable**/}, - {"Per Child Expense",""/**user variable**/}, - + {"Taxes", currentFS.getTaxes()}, + {"Home Mortgage Payment", currentFS.getHomeMortgagePayment()}, + {"School Loan Payment",currentFS.getSchoolLoanPayment()}, + {"Car Loan Payment",currentFS.getCarLoanPayment()}, + {"Credit Card Payment",currentFS.getCreditCardPayment()}, + {"Other Expenses", currentFS.getOtherExpenses()}, + {"Per Child Expense",currentFS.getPerChildExpense()*currentFS.getNumChildren()}, }; JTable expenseTable = new JTable(expense, expenseColumns); @@ -127,12 +149,14 @@ public class FSWindow { tabbedPane.addTab("Expenses", expenseTable); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); +// private ArrayList _realEstate; + //find how to keep adding rows from array String[] assetColumns = {"Description", "CashFlow"}; Object[][] asset = { {"Description", "CashFlow"}, - {"Savings",""/**user variable*/}, - {"Precious Metals", ""/**user variable**/}, - {"Stocks",""/**user variable**/}, //total stocks number and total money + {"Savings",currentFS.getSavings()}, + {"Precious Metals", "0"}, + {"Stocks",currentFS.getStockValue()}, //total stocks number and total money }; JTable assetTable = new JTable(asset, assetColumns ); @@ -158,11 +182,10 @@ public class FSWindow { String[] liabiltiesColumns = {"Description", "Liabilities"}; Object[][] liabilties = { {"Description", "Liabilities"}, - {"Home Mortgage",""/**user variable*/}, - {"School Loans", ""/**user variable**/}, - {"Car Loans",""/**user variable**/, ""/**user variable**/}, - {"Credit Card Debt", ""/**user variable**/}, - {"Bank Loans", ""/**user variable**/}, + {"Home Mortgage",currentFS.getHomeMortgage()}, + {"School Loans", currentFS.getSchoolLoans()}, + {"Car Loans",currentFS.getCarLoans()}, + {"Credit Card Debt", currentFS.getCreditCardDebt()}, }; JTable liabiltiesTable = new JTable(liabilties, liabiltiesColumns ); diff --git a/src/view/MainMenu.java b/src/view/MainMenu.java new file mode 100644 index 0000000..a9b25e3 --- /dev/null +++ b/src/view/MainMenu.java @@ -0,0 +1,102 @@ +package view; + +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +public class MainMenu +{ + public static void main (String[] args) + { + JFrame frame = new JFrame("CashFlow"); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(650,530); + Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); + int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2); + int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2) -100; + frame.setLocation(x, y); + + JPanel panel1 = new JPanel(); + panel1.setSize(140, 45); + panel1.setLocation(255, 125); + panel1.setOpaque(false); + //Font font = new Font ("Times New Roman", Font.BOLD, 30); + //panel1.setFont(font); + + JPanel panel2 = new JPanel(); + panel2.setSize(140, 45); + panel2.setLocation(255, 160); + panel2.setOpaque(false); + + JPanel panel3 = new JPanel(); + panel3.setSize(140, 45); + panel3.setLocation(255, 260); + panel3.setOpaque(false); + + JPanel panel4 = new JPanel(); + panel4.setSize(140, 45); + panel4.setLocation(255, 295); + panel4.setOpaque(false); + + JPanel panel5 = new JPanel(); + panel5.setSize(140, 45); + panel5.setLocation(255, 330); + panel5.setOpaque(false); + + + JButton newGame = new JButton("New Game"); + JButton savedGame = new JButton("Saved Game"); + JButton rules = new JButton("Rules"); + JButton settings = new JButton("Settings"); + JButton exit = new JButton("Exit"); + + newGame.setPreferredSize(new Dimension(140,40)); + newGame.setForeground(Color.MAGENTA); + + savedGame.setPreferredSize(new Dimension(130,40)); + savedGame.setForeground(Color.MAGENTA); + + + rules.setPreferredSize(new Dimension(80,40)); + rules.setForeground(Color.MAGENTA); + + + settings.setPreferredSize(new Dimension(120,40)); + settings.setForeground(Color.MAGENTA); + + + exit.setPreferredSize(new Dimension(100,40)); + exit.setForeground(Color.MAGENTA); + + + BufferedImage img = null; + try { + img = ImageIO.read(new File("gameboard.png")); + } catch (IOException e) { + e.printStackTrace(); + } + Image dimg = img.getScaledInstance(800, 508, Image.SCALE_SMOOTH); + ImageIcon imageIcon = new ImageIcon(dimg); + frame.setContentPane(new JLabel(imageIcon)); + frame.getContentPane().add(new JLabel(imageIcon)); + + + panel1.add(newGame); + panel2.add(savedGame); + panel3.add(rules); + panel4.add(settings); + panel5.add(exit); + + frame.add(panel1); + frame.add(panel2); + frame.add(panel3); + frame.add(panel4); + frame.add(panel5); + frame.setVisible(true); + + } +} diff --git a/src/view/MainWindow.java b/src/view/MainWindow.java index ea95c70..156df7d 100644 --- a/src/view/MainWindow.java +++ b/src/view/MainWindow.java @@ -2,6 +2,7 @@ package view; import java.awt.*; + import javax.swing.JFrame; import javax.swing.JPanel;