diff --git a/bin/controller/Cashflow.class b/bin/controller/Cashflow.class index d85eb9e..48d4bb3 100644 Binary files a/bin/controller/Cashflow.class and b/bin/controller/Cashflow.class differ diff --git a/bin/model/CharityTile.class b/bin/model/CharityTile.class index 80cfd97..1a5fb76 100644 Binary files a/bin/model/CharityTile.class and b/bin/model/CharityTile.class differ diff --git a/bin/model/DealTile.class b/bin/model/DealTile.class index 7d9238f..a39568d 100644 Binary files a/bin/model/DealTile.class and b/bin/model/DealTile.class differ diff --git a/bin/view/CharityWindow$1.class b/bin/view/CharityWindow$1.class index e815cf8..106999e 100644 Binary files a/bin/view/CharityWindow$1.class and b/bin/view/CharityWindow$1.class differ diff --git a/bin/view/CharityWindow$2.class b/bin/view/CharityWindow$2.class index e7767b9..a2a84fe 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 ee0ab41..1b402f1 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 2000558..3803bbd 100644 Binary files a/bin/view/CharityWindow.class and b/bin/view/CharityWindow.class differ diff --git a/src/controller/Cashflow.java b/src/controller/Cashflow.java index 03731c7..b821796 100644 --- a/src/controller/Cashflow.java +++ b/src/controller/Cashflow.java @@ -40,7 +40,6 @@ public class Cashflow // Initialize game board _board = new GameBoard(_players); - // Initialize GUI @@ -96,7 +95,7 @@ public class Cashflow players.add(p2); GameBoard g = new GameBoard(players); System.out.println(p1.getLocation()); - g.movePlayer(p1, 5); + g.movePlayer(p1, 4); System.out.println(p1.getLocation()); @@ -104,14 +103,7 @@ public class Cashflow FSWindow.prepareGUI(p1); FSWindow.showButtonDemo(); - - // Delay to check how the financial statement updates - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + FSWindow.prepareGUI(p2); @@ -146,33 +138,31 @@ public class Cashflow } -// -// public void setUpScreen() -// { -// frame = new JFrame("Cashflow"); -// frame.setLayout(new FlowLayout()); -// window = new GameboardWindow(_board); -// -// sidewindow = new JWindow(); -// sidewindow.setLayout(new GridLayout(5, 5)); -// -// frame.add(window); -// -// -// frame.pack(); -// -// frame.setVisible(true); -// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -// } -// public static void main(String[] args) { -// new Cashflow(4); -// -// } -// public Cashflow(int numPlayers) -// { -// //this.setUpScreen(); // just did this to test the screen -// -// } + + public void setUpScreen() + { + frame = new JFrame("Cashflow"); + frame.setLayout(new FlowLayout()); + window = new GameboardWindow(_board); + + sidewindow = new JWindow(); + sidewindow.setLayout(new GridLayout(5, 5)); + + frame.add(window); + + + frame.pack(); + + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + + public Cashflow(int numPlayers) + { + //this.setUpScreen(); // just did this to test the screen + + } } diff --git a/src/model/CharityTile.java b/src/model/CharityTile.java index a732946..d23b593 100644 --- a/src/model/CharityTile.java +++ b/src/model/CharityTile.java @@ -1,5 +1,7 @@ package model; +import view.CharityWindow; + public class CharityTile extends Tile { @@ -15,6 +17,24 @@ public class CharityTile extends Tile FinancialStatement f = p.getFinancialStatement(); // call view method // TODO + CharityWindow charityWindow = new CharityWindow(); + charityWindow.showButtonDemo(); + + + while(!charityWindow.hasAnswered) + { + try { + Thread.sleep(200); + } catch(InterruptedException e) { + + } + } + System.out.println(charityWindow.doesDonate); + + // Pick card from big/small deal stack: + Card c; + if(charityWindow.doesDonate) + if (p.donateCharity()) { diff --git a/src/model/DealTile.java b/src/model/DealTile.java index c2edcd0..6e751f2 100644 --- a/src/model/DealTile.java +++ b/src/model/DealTile.java @@ -20,19 +20,30 @@ public class DealTile extends Tile public void getLandedOn(Player p) { // TODO - // For now, using a scanner to interact with user until GUI is ready: // Ask user to decide big/small deal: + CharityWindow charityWindow = new CharityWindow(); + charityWindow.showButtonDemo(); + + + while(!charityWindow.hasAnswered) + { + try { + Thread.sleep(200); + } catch(InterruptedException e) { + + } + } + System.out.println(charityWindow.doesDonate); - // Pick card from big/small deal stack: Card c; - if(input.equals("1")) + if(charityWindow.doesDonate) { c = _smallDealStack.pickCard(); } else { - c = _smallDealStack.pickCard(); + c = _bigDealStack.pickCard(); } // If stock, update price, then ask user if they want to buy and ask everyone if they want to sell: @@ -41,6 +52,8 @@ public class DealTile extends Tile // 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: + System.out.println(charityWindow.hasAnswered); + charityWindow = null; } public void buyIncomeProperty(Player p, DealCard d) diff --git a/src/view/CharityWindow.java b/src/view/CharityWindow.java index 39595e0..ebba336 100644 --- a/src/view/CharityWindow.java +++ b/src/view/CharityWindow.java @@ -9,13 +9,16 @@ public class CharityWindow { private JLabel headerLabel; private JLabel statusLabel; private JPanel controlPanel; + public boolean doesDonate; + public boolean hasAnswered = false; public CharityWindow(){ prepareGUI(); } public static void main(String[] args){ CharityWindow CharityWindow = new CharityWindow(); - CharityWindow.showButtonDemo(); + boolean b = CharityWindow.showButtonDemo(); + System.out.println(b); } private void prepareGUI(){ mainFrame = new JFrame("Charity"); @@ -46,7 +49,7 @@ public class CharityWindow { mainFrame.setVisible(true); } - private void showButtonDemo(){ + public boolean showButtonDemo(){ headerLabel.setText("Charity!"); statusLabel.setText("Charity description"); @@ -57,29 +60,81 @@ public class CharityWindow { JButton DontDonate = new JButton("Don't Donate"); DontDonate.setHorizontalTextPosition(SwingConstants.LEFT); - Donate.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - //update cashbalance for player - try { - Thread.sleep(1); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - System.exit(0); - } + + Donate.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + hasAnswered = true; + doesDonate = true; + mainFrame.dispose(); + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } }); - DontDonate.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - //put message that they are greedy. after 10 seconds, close window - System.exit(0); - } + DontDonate.addMouseListener(new MouseListener() { + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + hasAnswered = true; + doesDonate = false; + mainFrame.dispose(); + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } }); controlPanel.add(Donate); controlPanel.add(DontDonate); mainFrame.setVisible(true); + + return doesDonate; } } diff --git a/src/view/GameboardWindow.java b/src/view/GameboardWindow.java index ca5d379..adf2cd9 100644 --- a/src/view/GameboardWindow.java +++ b/src/view/GameboardWindow.java @@ -43,7 +43,7 @@ public class GameboardWindow extends JPanel { setMaximumSize(size); setSize(size); setLayout(null); - + setUpTiles(); Positioners = new ArrayList();