Skip to content
Permalink
Browse files

assigning player namessss

  • Loading branch information
afortuna2016
afortuna2016 committed Apr 23, 2017
1 parent 558489d commit 36fd4f9db66b75518d76672ea455d78b528ada94
BIN +101 Bytes (100%) bin/controller/Cashflow.class
Binary file not shown.
Binary file not shown.
BIN +282 Bytes (120%) bin/model/Player.class
Binary file not shown.
@@ -16,9 +16,12 @@



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
// Initialize game board
// Initialize GUI
@@ -204,10 +204,7 @@ public int getTotalIncome()
{
return _totalIncome;
}

<<<<<<< HEAD

=======
//income getters
public int getIncome()
{
@@ -8,6 +8,7 @@
private int _downsizeCount; //down size counter
private int _location;//refers to a tile number
private boolean _hasWon;
private String _playerName;

public Player()
{
@@ -80,7 +81,14 @@ public void decrememntDownsizeCount()
_downsizeCount--;
}

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


public String getPlayerName()
{
return _playerName;
}

}
@@ -3,6 +3,8 @@
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.*;

@@ -11,11 +13,14 @@

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

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

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

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@@ -116,10 +121,10 @@ public static void main (String[] args)
JButton four = new JButton ("Four");
JButton five = new JButton ("Five");
JButton six = new JButton ("Six");
JTextField player1 = new JTextField("Player 1");
JTextField player2 = new JTextField("Player 2");
JTextField player3 = new JTextField("Player 3");
JTextField player4 = new JTextField("Player 4");
final JTextField player1 = new JTextField("Player 1");
final JTextField player2 = new JTextField("Player 2");
final JTextField player3 = new JTextField("Player 3");
final JTextField player4 = new JTextField("Player 4");
JButton start = new JButton("Start");

newGame.setPreferredSize(new Dimension(140,40));
@@ -239,41 +244,38 @@ public void actionPerformed(ActionEvent e) {
}
});

player1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


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

player2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


System.exit(0);
}
});
player3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


System.exit(0);
}
});
player2.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent evt){
String p2name = ((JTextField)evt.getSource()).getText() + String.valueOf(evt.getKeyChar());
playerNames[1] = p2name;
}
});

player4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {


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

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() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
Cashflow.go();
Cashflow.go(playerNames);
System.exit(0);
}
});

0 comments on commit 36fd4f9

Please sign in to comment.
You can’t perform that action at this time.