diff --git a/bin/controller/Cashflow.class b/bin/controller/Cashflow.class index e2c2ff7..7ce900b 100644 Binary files a/bin/controller/Cashflow.class and b/bin/controller/Cashflow.class differ diff --git a/bin/model/DealTile.class b/bin/model/DealTile.class index 7d9238f..16e5fb8 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 f38a143..775ba0c 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 9816afb..bc1b15a 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 9da374b..2476f5b 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 d954bf3..788f787 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 675ca46..bcfaa1b 100644 --- a/src/controller/Cashflow.java +++ b/src/controller/Cashflow.java @@ -39,7 +39,6 @@ public class Cashflow // Initialize game board _board = new GameBoard(_players); - // Initialize GUI @@ -75,7 +74,7 @@ public class Cashflow public boolean isWinner() { boolean isWinner = false; - for(Player p : players) + for(Player p : _players) { if(p.hasWon()) { @@ -95,7 +94,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()); @@ -103,14 +102,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); @@ -145,33 +137,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/DealTile.java b/src/model/DealTile.java index c2edcd0..50617dc 100644 --- a/src/model/DealTile.java +++ b/src/model/DealTile.java @@ -20,13 +20,24 @@ 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(); } @@ -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..cd4d271 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,82 @@ 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); - } + boolean donate = false; + + 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 efec53c..62a8a00 100644 --- a/src/view/GameboardWindow.java +++ b/src/view/GameboardWindow.java @@ -42,7 +42,7 @@ public class GameboardWindow extends JPanel { setMaximumSize(size); setSize(size); setLayout(null); - + setUpTiles(); Positioners = new ArrayList();