Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of
  • Loading branch information
afortuna2016 committed Apr 25, 2017
2 parents ac8faef + deaa729 commit d273363
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 60 deletions.
Binary file modified bin/controller/Cashflow.class
Binary file not shown.
Binary file modified bin/model/CharityTile.class
Binary file not shown.
Binary file modified bin/model/DealTile.class
Binary file not shown.
Binary file modified bin/view/CharityWindow$1.class
Binary file not shown.
Binary file modified bin/view/CharityWindow$2.class
Binary file not shown.
Binary file modified bin/view/CharityWindow$3.class
Binary file not shown.
Binary file modified bin/view/CharityWindow.class
Binary file not shown.
64 changes: 27 additions & 37 deletions src/controller/Cashflow.java
Expand Up @@ -40,7 +40,6 @@ public class Cashflow
// Initialize game board // Initialize game board
_board = new GameBoard(_players); _board = new GameBoard(_players);



// Initialize GUI // Initialize GUI




Expand Down Expand Up @@ -96,22 +95,15 @@ public class Cashflow
players.add(p2); players.add(p2);
GameBoard g = new GameBoard(players); GameBoard g = new GameBoard(players);
System.out.println(p1.getLocation()); System.out.println(p1.getLocation());
g.movePlayer(p1, 5); g.movePlayer(p1, 4);
System.out.println(p1.getLocation()); System.out.println(p1.getLocation());




FSWindow FSWindow = new FSWindow(); FSWindow FSWindow = new FSWindow();
FSWindow.prepareGUI(p1); FSWindow.prepareGUI(p1);
FSWindow.showButtonDemo(); 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); FSWindow.prepareGUI(p2);


Expand Down Expand Up @@ -146,33 +138,31 @@ public class Cashflow
} }




//
// public void setUpScreen() public void setUpScreen()
// { {
// frame = new JFrame("Cashflow"); frame = new JFrame("Cashflow");
// frame.setLayout(new FlowLayout()); frame.setLayout(new FlowLayout());
// window = new GameboardWindow(_board); window = new GameboardWindow(_board);
//
// sidewindow = new JWindow(); sidewindow = new JWindow();
// sidewindow.setLayout(new GridLayout(5, 5)); sidewindow.setLayout(new GridLayout(5, 5));
//
// frame.add(window); frame.add(window);
//
//
// frame.pack(); frame.pack();
//
// frame.setVisible(true); frame.setVisible(true);
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// } }
// public static void main(String[] args) {
// new Cashflow(4);
// public Cashflow(int numPlayers)
// } {
// public Cashflow(int numPlayers) //this.setUpScreen(); // just did this to test the screen
// {
// //this.setUpScreen(); // just did this to test the screen }
//
// }




} }
Expand Down
20 changes: 20 additions & 0 deletions src/model/CharityTile.java
@@ -1,5 +1,7 @@
package model; package model;


import view.CharityWindow;

public class CharityTile extends Tile public class CharityTile extends Tile
{ {


Expand All @@ -15,6 +17,24 @@ public class CharityTile extends Tile
FinancialStatement f = p.getFinancialStatement(); FinancialStatement f = p.getFinancialStatement();
// call view method // call view method
// TODO // 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()) if (p.donateCharity())
{ {
Expand Down
21 changes: 17 additions & 4 deletions src/model/DealTile.java
Expand Up @@ -20,19 +20,30 @@ public class DealTile extends Tile
public void getLandedOn(Player p) public void getLandedOn(Player p)
{ {
// TODO // TODO
// For now, using a scanner to interact with user until GUI is ready:
// Ask user to decide big/small deal: // 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: // Pick card from big/small deal stack:
Card c; Card c;
if(input.equals("1")) if(charityWindow.doesDonate)
{ {
c = _smallDealStack.pickCard(); c = _smallDealStack.pickCard();
} }
else 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: // If stock, update price, then ask user if they want to buy and ask everyone if they want to sell:
Expand All @@ -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 property, ask user if they want to do it (and check if they can afford the down payment):
// If yes, call ButIncomeProperty method: // If yes, call ButIncomeProperty method:
// Else, do nothing: // Else, do nothing:
System.out.println(charityWindow.hasAnswered);
charityWindow = null;
} }


public void buyIncomeProperty(Player p, DealCard d) public void buyIncomeProperty(Player p, DealCard d)
Expand Down
91 changes: 73 additions & 18 deletions src/view/CharityWindow.java
Expand Up @@ -9,13 +9,16 @@ public class CharityWindow {
private JLabel headerLabel; private JLabel headerLabel;
private JLabel statusLabel; private JLabel statusLabel;
private JPanel controlPanel; private JPanel controlPanel;
public boolean doesDonate;
public boolean hasAnswered = false;


public CharityWindow(){ public CharityWindow(){
prepareGUI(); prepareGUI();
} }
public static void main(String[] args){ public static void main(String[] args){
CharityWindow CharityWindow = new CharityWindow(); CharityWindow CharityWindow = new CharityWindow();
CharityWindow.showButtonDemo(); boolean b = CharityWindow.showButtonDemo();
System.out.println(b);
} }
private void prepareGUI(){ private void prepareGUI(){
mainFrame = new JFrame("Charity"); mainFrame = new JFrame("Charity");
Expand Down Expand Up @@ -46,7 +49,7 @@ public class CharityWindow {
mainFrame.setVisible(true); mainFrame.setVisible(true);
} }


private void showButtonDemo(){ public boolean showButtonDemo(){
headerLabel.setText("Charity!"); headerLabel.setText("Charity!");
statusLabel.setText("Charity description"); statusLabel.setText("Charity description");


Expand All @@ -57,29 +60,81 @@ public class CharityWindow {
JButton DontDonate = new JButton("Don't Donate"); JButton DontDonate = new JButton("Don't Donate");
DontDonate.setHorizontalTextPosition(SwingConstants.LEFT); DontDonate.setHorizontalTextPosition(SwingConstants.LEFT);


Donate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { Donate.addMouseListener(new MouseListener() {
//update cashbalance for player @Override
try { public void mouseClicked(MouseEvent e) {
Thread.sleep(1); // TODO Auto-generated method stub
} catch (InterruptedException e1) { hasAnswered = true;
// TODO Auto-generated catch block doesDonate = true;
e1.printStackTrace(); mainFrame.dispose();
} }
System.exit(0);
} @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() { DontDonate.addMouseListener(new MouseListener() {
public void actionPerformed(ActionEvent e) {
//put message that they are greedy. after 10 seconds, close window @Override
System.exit(0); 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(Donate);


controlPanel.add(DontDonate); controlPanel.add(DontDonate);


mainFrame.setVisible(true); mainFrame.setVisible(true);

return doesDonate;
} }
} }
2 changes: 1 addition & 1 deletion src/view/GameboardWindow.java
Expand Up @@ -43,7 +43,7 @@ public class GameboardWindow extends JPanel {
setMaximumSize(size); setMaximumSize(size);
setSize(size); setSize(size);
setLayout(null); setLayout(null);

setUpTiles(); setUpTiles();


Positioners = new ArrayList<Positioner>(); Positioners = new ArrayList<Positioner>();
Expand Down

0 comments on commit d273363

Please sign in to comment.