diff --git a/bin/controller/Cashflow.class b/bin/controller/Cashflow.class index ea7ca53..c29e2cf 100644 Binary files a/bin/controller/Cashflow.class and b/bin/controller/Cashflow.class differ diff --git a/bin/model/BigDealStack.class b/bin/model/BigDealStack.class index 5a27ad0..a820dd7 100644 Binary files a/bin/model/BigDealStack.class and b/bin/model/BigDealStack.class differ diff --git a/bin/model/CharityTile.class b/bin/model/CharityTile.class index 11fcf8d..8d5917c 100644 Binary files a/bin/model/CharityTile.class and b/bin/model/CharityTile.class differ diff --git a/bin/model/ChildTile.class b/bin/model/ChildTile.class index 54da5e4..af89722 100644 Binary files a/bin/model/ChildTile.class and b/bin/model/ChildTile.class differ diff --git a/bin/model/DealCard.class b/bin/model/DealCard.class index 9a51abb..adc8ef1 100644 Binary files a/bin/model/DealCard.class and b/bin/model/DealCard.class differ diff --git a/bin/model/DoodadCard.class b/bin/model/DoodadCard.class index 538f415..8e23482 100644 Binary files a/bin/model/DoodadCard.class and b/bin/model/DoodadCard.class differ diff --git a/bin/model/DoodadStack.class b/bin/model/DoodadStack.class index f8c4af9..ddbe44a 100644 Binary files a/bin/model/DoodadStack.class and b/bin/model/DoodadStack.class differ diff --git a/bin/model/DoodadTile.class b/bin/model/DoodadTile.class index 9cc6238..80d2911 100644 Binary files a/bin/model/DoodadTile.class and b/bin/model/DoodadTile.class differ diff --git a/bin/model/FinancialStatement.class b/bin/model/FinancialStatement.class index cfb7622..ee05e29 100644 Binary files a/bin/model/FinancialStatement.class and b/bin/model/FinancialStatement.class differ diff --git a/bin/model/SmallDealStack.class b/bin/model/SmallDealStack.class index 8b79e20..143fd12 100644 Binary files a/bin/model/SmallDealStack.class and b/bin/model/SmallDealStack.class differ diff --git a/src/model/CharityTile.java b/src/model/CharityTile.java index 35d4f34..0b92dd8 100644 --- a/src/model/CharityTile.java +++ b/src/model/CharityTile.java @@ -12,15 +12,13 @@ public class CharityTile extends Tile @Override public void getLandedOn(Player p) { - + //call view method // TODO - // Ask players if they want to donate to charity (returns boolean) if (p.donateCharity()) { p.setCharityCount(p.getCharityCount() + 3); - p.getFinancialStatement().setCashBalance(p.getFinancialStatement().getCashBalance() - - (p.getFinancialStatement().getPassiveIncome()*.10)); + p.getFinancialStatement().increaseCashBalance((int) -((p.getFinancialStatement().getTotalIncome()*.1))); } else { diff --git a/src/model/ChildTile.java b/src/model/ChildTile.java index bdc42fa..c9bdbf5 100644 --- a/src/model/ChildTile.java +++ b/src/model/ChildTile.java @@ -12,6 +12,7 @@ public class ChildTile extends Tile public void getLandedOn(Player p) { p.getFinancialStatement().addChild(); + p.getFinancialStatement().update(); } diff --git a/src/model/DoodadTile.java b/src/model/DoodadTile.java index 89ac791..5190806 100644 --- a/src/model/DoodadTile.java +++ b/src/model/DoodadTile.java @@ -20,10 +20,12 @@ public class DoodadTile extends Tile if (p.getFinancialStatement().getCashBalance() > amount) { p.getFinancialStatement().setCashBalance(p.getFinancialStatement().getCashBalance() - amount); + p.getFinancialStatement().update(); } else if(p.getFinancialStatement().getCashBalance() < amount) { p.getFinancialStatement().setCashBalance(0); + p.getFinancialStatement().update(); } // Pop next card // Get cash out from card diff --git a/src/model/FinancialStatement.java b/src/model/FinancialStatement.java index 0b8ece4..cbd79a0 100644 --- a/src/model/FinancialStatement.java +++ b/src/model/FinancialStatement.java @@ -91,7 +91,7 @@ public class FinancialStatement update(); } - private void update() + public void update() { _income = _salary + _REcashFlow; _expenses = _taxes + _homeMortgagePayment + _schoolLoanPayment + _carLoanPayment + _creditCardPayment + _otherExpenses + (_perChildExpense * _numChildren); @@ -199,6 +199,10 @@ public class FinancialStatement { return _profession; } + public int getTotalIncome() + { + return _totalIncome; + } } diff --git a/src/view/CharityCard.java b/src/view/CharityCard.java new file mode 100644 index 0000000..75f5bfd --- /dev/null +++ b/src/view/CharityCard.java @@ -0,0 +1,94 @@ +package view; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class CharityCard { + private JFrame mainFrame; + private JLabel headerLabel; + private JLabel statusLabel; + private JPanel controlPanel; + + public CharityCard(){ + prepareGUI(); + } + public static void main(String[] args){ + CharityCard CharityCard = new CharityCard(); + CharityCard.showButtonDemo(); + } + private void prepareGUI(){ + mainFrame = new JFrame("Charity"); + mainFrame.setSize(400,250); + //need to set this to null and position everything manually + mainFrame.setLayout(new GridLayout(3, 1)); + + mainFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent windowEvent){ + System.exit(0); + } + }); + headerLabel = new JLabel("", JLabel.CENTER); + statusLabel = new JLabel("",JLabel.CENTER); + //new statuslabel of "10% of your whatever is XX dollars" + statusLabel.setSize(350,100); + + controlPanel = new JPanel(); + controlPanel.setLayout(new FlowLayout()); + + mainFrame.add(headerLabel); + mainFrame.add(controlPanel); + mainFrame.add(statusLabel); + mainFrame.setVisible(true); + } + private static ImageIcon createImageIcon(String path, String description) { + java.net.URL imgURL = CharityCard.class.getResource(path); + if (imgURL != null) { + return new ImageIcon(imgURL, description); + } else { + System.err.println("Couldn't find file: " + path); + return null; + } + } + private void showButtonDemo(){ + headerLabel.setText("Charity!"); + statusLabel.setText("Charity description"); + + //resources folder should be inside SWING folder. + ImageIcon icon = createImageIcon("/resources/java_icon.png","Java"); + + JButton Donate = new JButton("Donate"); + + JButton DontDonate = new JButton("Don't Donate", icon); + DontDonate.setHorizontalTextPosition(SwingConstants.LEFT); + + Donate.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //put message that they donated xx dollars after 10 seconds, close window + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + statusLabel.setText("Good Job! You donated all your savings!"); + + + System.exit(0); + } + }); + + DontDonate.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //put message that they are greedy. after 10 seconds, close window + System.exit(0); + } + }); + controlPanel.add(Donate); + + controlPanel.add(DontDonate); + + mainFrame.setVisible(true); + } +} diff --git a/src/view/ChildCard.java b/src/view/ChildCard.java new file mode 100644 index 0000000..19eec34 --- /dev/null +++ b/src/view/ChildCard.java @@ -0,0 +1,71 @@ +package view; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class ChildCard { + + private JFrame mainFrame; + private JLabel headerLabel; + private JLabel statusLabel; + private JPanel controlPanel; + + public ChildCard(){ + prepareGUI(); + } + public static void main(String[] args){ + ChildCard ChildCard = new ChildCard(); + ChildCard.showButtonDemo(); + } + private void prepareGUI(){ + mainFrame = new JFrame("Child"); + mainFrame.setSize(400,250); + //need to set this to null and position everything manually + mainFrame.setLayout(new GridLayout(3, 1)); + + mainFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent windowEvent){ + System.exit(0); + } + }); + headerLabel = new JLabel("", JLabel.CENTER); + statusLabel = new JLabel("",JLabel.CENTER); + statusLabel.setSize(350,100); + + controlPanel = new JPanel(); + controlPanel.setLayout(new FlowLayout()); + + mainFrame.add(headerLabel); + mainFrame.add(controlPanel); + mainFrame.add(statusLabel); + mainFrame.setVisible(true); + } + + private void showButtonDemo(){ + headerLabel.setText("Child"); + statusLabel.setText("You have a child!"); + + //resources folder should be inside SWING folder. + + JButton Child = new JButton("Exit"); + + Child.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + statusLabel.setText(""); + + System.exit(0); + } + }); + + controlPanel.add(Child); + mainFrame.setVisible(true); + } +} diff --git a/src/view/DealCard.java b/src/view/DealCard.java new file mode 100644 index 0000000..6a0d78c --- /dev/null +++ b/src/view/DealCard.java @@ -0,0 +1,103 @@ +package view; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import model.*; + +public class DealCard { + private JFrame mainFrame; + private JLabel headerLabel; + private JLabel statusLabel; + private JPanel controlPanel; + private JFrame mainFrame2; + private JLabel headerLabel2; + private JLabel statusLabel2; + private JPanel controlPanel2; + public int response; + + public DealCard(){ + prepareGUI(); + } + public static void main(String[] args){ + DealCard DealCard = new DealCard(); + DealCard.showButtonDemo(); + } + private void prepareGUI(){ + mainFrame = new JFrame("Deal"); + mainFrame.setSize(400,250); + //need to set this to null and position everything manually + mainFrame.setLayout(new GridLayout(3, 1)); + + mainFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent windowEvent){ + System.exit(0); + } + }); + headerLabel = new JLabel("", JLabel.CENTER); + statusLabel = new JLabel("",JLabel.CENTER); + //new statuslabel of "10% of your whatever is XX dollars" + statusLabel.setSize(350,100); + + controlPanel = new JPanel(); + controlPanel.setLayout(new FlowLayout()); + + mainFrame.add(headerLabel); + mainFrame.add(controlPanel); + mainFrame.add(statusLabel); + mainFrame.setVisible(true); + + mainFrame2 = new JFrame("Deal"); + mainFrame2.setSize(400,250); + //need to set this to null and position everything manually + mainFrame2.setLayout(new GridLayout(3, 1)); + + mainFrame2.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent windowEvent){ + System.exit(0); + } + }); + headerLabel2 = new JLabel("", JLabel.CENTER); + statusLabel2 = new JLabel("",JLabel.CENTER); + //new statusLabel2 of "10% of your whatever is XX dollars" + statusLabel2.setSize(350,100); + + controlPanel2 = new JPanel(); + controlPanel2.setLayout(new FlowLayout()); + + mainFrame2.add(headerLabel2); + mainFrame2.add(controlPanel2); + mainFrame2.add(statusLabel2); + mainFrame2.setVisible(true); + } + + private int showButtonDemo(){ + + headerLabel.setText("Deal"); + statusLabel.setText("What type of deal would you like?"); + + //resources folder should be inside SWING folder. + + JButton BigDeal = new JButton("BigDeal"); + JButton SmallDeal = new JButton("SmallDeal"); + SmallDeal.setHorizontalTextPosition(SwingConstants.LEFT); + + BigDeal.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //open big deal stuffs + response = 1; + } + + }); + + SmallDeal.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + response = 0; + } + }); + controlPanel.add(BigDeal); + controlPanel.add(SmallDeal); + mainFrame.setVisible(true); + return response; + } +} diff --git a/src/view/DoodadCard.java b/src/view/DoodadCard.java new file mode 100644 index 0000000..cec2a5e --- /dev/null +++ b/src/view/DoodadCard.java @@ -0,0 +1,79 @@ +package view; + +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; + +public class DoodadCard { + private JFrame mainFrame; + private JLabel headerLabel; + private JLabel statusLabel; + private JPanel controlPanel; + + public DoodadCard(){ + prepareGUI(); + } + public static void main(String[] args){ + DoodadCard DoodadCard = new DoodadCard(); + DoodadCard.showButtonDemo(); + } + private void prepareGUI(){ + mainFrame = new JFrame("Doodad"); + mainFrame.setSize(400,250); + //need to set this to null and position everything manually + mainFrame.setLayout(new GridLayout(3, 1)); + + mainFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent windowEvent){ + System.exit(0); + } + }); + headerLabel = new JLabel("", JLabel.CENTER); + statusLabel = new JLabel("",JLabel.CENTER); + statusLabel.setSize(350,100); + + controlPanel = new JPanel(); + controlPanel.setLayout(new FlowLayout()); + + mainFrame.add(headerLabel); + mainFrame.add(controlPanel); + mainFrame.add(statusLabel); + mainFrame.setVisible(true); + } + + private void showButtonDemo(){ + headerLabel.setText("Call Doodad Title here"); + statusLabel.setText("Call Doodad Description here"); + //resources folder should be inside SWING folder. + + JButton payDoodad = new JButton("Pay"); + // payDoodad.setLayout(null); + // payDoodad.setLocation(10,220); + payDoodad.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //put message that they payDoodad xx dollars after 10 seconds, close window + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // statusLabel.setText("whatever now equals xx dollars"); + System.exit(0); + } + }); + + controlPanel.add(payDoodad); + mainFrame.setVisible(true); + } +} diff --git a/src/view/SDStockCard.java b/src/view/SDStockCard.java new file mode 100644 index 0000000..4f0e3f7 --- /dev/null +++ b/src/view/SDStockCard.java @@ -0,0 +1,84 @@ +package view; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class SDStockCard { + private JFrame mainFrame; + private JLabel headerLabel; + private JLabel statusLabel; + private JPanel controlPanel; + + public SDStockCard(){ + prepareGUI(); + } + public static void main(String[] args){ + SDStockCard SDStockCard = new SDStockCard(); + SDStockCard.showButtonDemo(); + } + private void prepareGUI(){ + mainFrame = new JFrame("Small Deal"); + mainFrame.setSize(400,250); + //need to set this to null and position everything manually + mainFrame.setLayout(new GridLayout(3, 1)); + + mainFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent windowEvent){ + System.exit(0); + } + }); + headerLabel = new JLabel("", JLabel.CENTER); + statusLabel = new JLabel("",JLabel.CENTER); + statusLabel.setSize(350,100); + + controlPanel = new JPanel(); + controlPanel.setLayout(new FlowLayout()); + + mainFrame.add(headerLabel); + mainFrame.add(controlPanel); + mainFrame.add(statusLabel); + mainFrame.setVisible(true); + } + + private void showButtonDemo(){ + headerLabel.setText("Small Deal Stock Title"); + statusLabel.setText("Small Deal Stock Description"); + + //resources folder should be inside SWING folder. + + JTextField BuyStock = new JTextField(); + BuyStock.setPreferredSize(new Dimension(25, 25)); + + JButton NoStocks = new JButton("Don't Buy Stocks"); + NoStocks.setHorizontalTextPosition(SwingConstants.LEFT); + + BuyStock.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //put message that they BuyStockd xx dollars after 10 seconds, close window + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + statusLabel.setText("You bought xx stocks"); + + + System.exit(0); + } + }); + + NoStocks.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //put message that they are greedy. after 10 seconds, close window + System.exit(0); + } + }); + + controlPanel.add(BuyStock); + controlPanel.add(NoStocks); + mainFrame.setVisible(true); + } +}