Quote Originally Posted by Miffed22001
Posted: Sat, 20 Aug 2005, 8:11pm

--------------------------------------------------------------------------------

//import statements
//import.*

public class Game extends JFrame
{
private Container content;
private LayoutManager layout;
private JPanel center, south;
private JLabel array[][], label1;
private JTextField texts[];
private ActionListener listener;
private JButton button;
private int turn=1, top=3, mid=5, bot=7, amount=15;
private boolean win=false;


public Game()
{
listener = new Handler();
content=getContentPane();
layout=new BorderLayout();
content.setLayout(layout);

texts=new JTextField[3];
array=new JLabel[3][7];

for(int x=0;x<3;x++)
for(int y=0;y<8;y++)
{

if(y==7)
{
texts[x]=new JTextField(0);
center.add(texts[x]);
}
else
{
array[x][y]=new JLabel();
array[x][y].setText("I");
center.add(array[x][y]);
}
}

array[0][3].setText(" ");
array[0][4].setText(" ");
array[0][5].setText(" ");
array[0][6].setText(" ");
array[1][5].setText(" ");
array[1][6].setText(" ");

content.add(center,BorderLayout.CENTER);

south=new GridLayout(1,2);
label1=new JLabel();
label1.setText("Player 1's turn");
south.add(label1);

button=new JButton("End Turn");
button.addActionListener(listener);
south.add(button);

content.add(south,BorderLayout.SOUTH);
}

public class Handler implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(win==false)
{
if(try(int num=Integer.parseInt(texts[0].getText())));
{
if(num<top)
{
label1.setText("Not that many paperclips!");
return;
}
if(num>top)
{
label1.setText("Not that many paperclips!");
return;
}

for(int x=(num-1);x>=0;x--)
{
array[0][x].setText("");
top--;
amount--;
}
if(amount==1)
{
label1.setText("Player "+turn+" wins!");
win=true;
return;
}
if(turn==1)
{
label1.setText("Player 2's turn!");
turn=2;
}
if(turn==2)
{
label1.setText("Player 1's turn!");
turn=1;
}
return;
}

if(try(int num=Integer.parseInt(texts[1].getText())));
{
if(num<mid)
{
label1.setText("Not that many paperclips!");
return;
}
if(num>mid)
{
label1.setText("Not that many paperclips!");
return;
}

for(int x=(num-1);x>=0;x--)
{
array[1][x].setText("");
mid--;
amount--;
}
if(amount==1)
{
label1.setText("Player "+turn+" wins!");
win=true;
return;
}
if(turn==1)
{
label1.setText("Player 2's turn!");
turn=2;
}
if(turn==2)
{
label1.setText("Player 1's turn!");
turn=1;
}
return;
}

if(try(int num=Integer.parseInt(texts[2].getText())));
{
if(num<bot)
{
label1.setText("Not that many paperclips!");
return;
}
if(num>bot)
{
label1.setText("Not that many paperclips!");
return;
}

for(int x=(num-1);x>=0;x--)
{
array[2][x].setText("");
top--;
amount--;
}
if(amount==1)
{
label1.setText("Player "+turn+" wins!");
win=true;
return;
}
if(turn==1)
{
label1.setText("Player 2's turn!");
turn=2;
}
if(turn==2)
{
label1.setText("Player 1's turn!");
turn=1;
}
return;
}
}
}
}

public static void main(String[]args)
{
Game window = new Game();
//window stuff;

window.setVisible(true);
}
}
i didnt have anything to say about this just wanted to repost it

Oh.