Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
assigning player namessss
  • Loading branch information
afortuna2016 committed Apr 23, 2017
1 parent 558489d commit 36fd4f9
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 39 deletions.
Binary file modified bin/controller/Cashflow.class
Binary file not shown.
Binary file modified bin/model/FinancialStatement.class
Binary file not shown.
Binary file modified bin/model/Player.class
Binary file not shown.
7 changes: 5 additions & 2 deletions src/controller/Cashflow.java
Expand Up @@ -16,9 +16,12 @@ public class Cashflow






public static void go() public static void go(String [] playerNames)
{ {
System.out.println("Start game"); for(int i = 0; i<playerNames.length; i++)
{
System.out.println(playerNames[i]);
}
// Joe // Joe
// Initialize game board // Initialize game board
// Initialize GUI // Initialize GUI
Expand Down
3 changes: 0 additions & 3 deletions src/model/FinancialStatement.java
Expand Up @@ -204,10 +204,7 @@ public class FinancialStatement
{ {
return _totalIncome; return _totalIncome;
} }

<<<<<<< HEAD


=======
//income getters //income getters
public int getIncome() public int getIncome()
{ {
Expand Down
10 changes: 9 additions & 1 deletion src/model/Player.java
Expand Up @@ -8,6 +8,7 @@ public class Player
private int _downsizeCount; //down size counter private int _downsizeCount; //down size counter
private int _location;//refers to a tile number private int _location;//refers to a tile number
private boolean _hasWon; private boolean _hasWon;
private String _playerName;


public Player() public Player()
{ {
Expand Down Expand Up @@ -80,7 +81,14 @@ public class Player
_downsizeCount--; _downsizeCount--;
} }


public void setPlayerName(String playerName)
{
_playerName = playerName;
}



public String getPlayerName()
{
return _playerName;
}


} }
68 changes: 35 additions & 33 deletions src/view/MainMenu.java
Expand Up @@ -3,6 +3,8 @@ package view;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;


Expand All @@ -11,11 +13,14 @@ import javax.swing.*;


import controller.Cashflow; import controller.Cashflow;
import model.Instructions; import model.Instructions;
import model.Player;


public class MainMenu public class MainMenu
{ {
public static void main (String[] args) public static void main (String[] args)
{ {
final String[] playerNames = new String[4];

final JFrame frame = new JFrame("CashFlow"); final JFrame frame = new JFrame("CashFlow");


frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Expand Down Expand Up @@ -116,10 +121,10 @@ public class MainMenu
JButton four = new JButton ("Four"); JButton four = new JButton ("Four");
JButton five = new JButton ("Five"); JButton five = new JButton ("Five");
JButton six = new JButton ("Six"); JButton six = new JButton ("Six");
JTextField player1 = new JTextField("Player 1"); final JTextField player1 = new JTextField("Player 1");
JTextField player2 = new JTextField("Player 2"); final JTextField player2 = new JTextField("Player 2");
JTextField player3 = new JTextField("Player 3"); final JTextField player3 = new JTextField("Player 3");
JTextField player4 = new JTextField("Player 4"); final JTextField player4 = new JTextField("Player 4");
JButton start = new JButton("Start"); JButton start = new JButton("Start");


newGame.setPreferredSize(new Dimension(140,40)); newGame.setPreferredSize(new Dimension(140,40));
Expand Down Expand Up @@ -239,41 +244,38 @@ public class MainMenu
} }
}); });


player1.addActionListener(new ActionListener() { player1.addKeyListener(new KeyAdapter(){
public void actionPerformed(ActionEvent e) { public void keyTyped(KeyEvent evt){

String p1name = ((JTextField)evt.getSource()).getText() + String.valueOf(evt.getKeyChar());

playerNames[0] = p1name;
System.exit(0); }
} });
});


player2.addActionListener(new ActionListener() { player2.addKeyListener(new KeyAdapter(){
public void actionPerformed(ActionEvent e) { public void keyTyped(KeyEvent evt){

String p2name = ((JTextField)evt.getSource()).getText() + String.valueOf(evt.getKeyChar());

playerNames[1] = p2name;
System.exit(0); }
} });
});
player3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


System.exit(0);
}
});


player4.addActionListener(new ActionListener() { player3.addKeyListener(new KeyAdapter(){
public void actionPerformed(ActionEvent e) { public void keyTyped(KeyEvent evt){

String p3name = ((JTextField)evt.getSource()).getText() + String.valueOf(evt.getKeyChar());

playerNames[2] = p3name;
System.exit(0); }
} });
});
player4.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent evt){
String p4Name = ((JTextField)evt.getSource()).getText() + String.valueOf(evt.getKeyChar());
playerNames[3] = p4Name;
}
});


start.addActionListener(new ActionListener() { start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
frame.dispose(); frame.dispose();
Cashflow.go(); Cashflow.go(playerNames);
System.exit(0); System.exit(0);
} }
}); });
Expand Down

0 comments on commit 36fd4f9

Please sign in to comment.