Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Did some GUI
  • Loading branch information
Joe Hill committed Apr 25, 2017
1 parent 32004f1 commit af04e34
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 60 deletions.
Binary file modified bin/controller/Cashflow.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.
66 changes: 28 additions & 38 deletions src/controller/Cashflow.java
Expand Up @@ -39,7 +39,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 @@ -75,7 +74,7 @@ public class Cashflow
public boolean isWinner() public boolean isWinner()
{ {
boolean isWinner = false; boolean isWinner = false;
for(Player p : players) for(Player p : _players)
{ {
if(p.hasWon()) if(p.hasWon())
{ {
Expand All @@ -95,22 +94,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 @@ -145,33 +137,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
19 changes: 16 additions & 3 deletions src/model/DealTile.java
Expand Up @@ -20,13 +20,24 @@ 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();
} }
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
92 changes: 74 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,82 @@ 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() { boolean donate = false;
public void actionPerformed(ActionEvent e) {
//update cashbalance for player Donate.addMouseListener(new MouseListener() {
try { @Override
Thread.sleep(1); public void mouseClicked(MouseEvent e) {
} catch (InterruptedException e1) { // TODO Auto-generated method stub
// TODO Auto-generated catch block hasAnswered = true;
e1.printStackTrace(); doesDonate = true;
} 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 @@ -42,7 +42,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 af04e34

Please sign in to comment.