//Control Panel for Scoring
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ScoringPanel extends JPanel implements ActionListener
{
	JLabel win,lose,winScore,loseScore;
	JButton	   cmdWin,cmdLose;
	private int myWin;
	private int myLose;
	String s; 
	public ScoringPanel()
	{
		super();
		setBackground(Color.cyan);	
	    	myWin = 0;
	    	myLose = 0;
	    
		win = new JLabel("Number of wins: ");
		winScore = new JLabel( s.valueOf(myWin)+"  " );
		lose  = new JLabel("  Number of losses: ");
		loseScore = new JLabel(s.valueOf(myLose)+"  " );
		
		win.setFont(new Font("Times New Roman",0,14));
		lose.setFont(new Font("Times New Roman",0,14));
		winScore.setFont(new Font("Courier",1,26));
		loseScore.setFont(new Font("Courier",1,26));
		
		cmdWin   = new JButton("Win");
	    	cmdLose  = new JButton("Lose");
		cmdWin.addActionListener(this);
		cmdLose.addActionListener(this);
		
		add(cmdWin);
		add(win);
		add(winScore);
		add(lose);
		add(loseScore);
		add(cmdLose);
    
				
	}
	public int getWin()
	{
		return myWin;
	}
	public void setWin(int x)
	{
		myWin = x;
		winScore.setText(s.valueOf(myWin));
	}
	public int getLose()
	{
		return myLose;
	}
 

	public void setLose(int x)
	{
		myLose = x;
		loseScore.setText(s.valueOf(myLose));
	}
	
	public void actionPerformed(ActionEvent ae)
	{
		int button;
		String command = ae.getActionCommand();
		System.out.println("Scoring: "+command);
		if (command.equals("Win"))
		{
			myWin++;
			winScore.setText(s.valueOf(myWin));
		} 
		else
		{
			myLose++;
			loseScore.setText(s.valueOf(myLose));
		}
    }
}
