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

public class ScoringPanel extends JPanel implements ActionListener
{

	private JLabel lblWin,lblLose,lblWinScore,lblLoseScore;
	private JButton	   cmdWin,cmdLose;
	private int myWinCount;
	private int myLoseCount;
	private String s;
	   
	public ScoringPanel()
	{
		super();
		setBackground(Color.cyan);	
	    myWinCount = 0;
	    myLoseCount = 0;
	    
		lblWin = new JLabel("Number of wins: ");
		lblWinScore = new JLabel( s.valueOf(myWinCount)+"  " );
		lblLose  = new JLabel("  Number of losses: ");
		lblLoseScore = new JLabel(s.valueOf(myLoseCount)+"  " );
		
		lblWin.setFont(new Font("Times New Roman",0,14));
		lblLose.setFont(new Font("Times New Roman",0,14));
		lblWinScore.setFont(new Font("Courier",1,26));
		lblLoseScore.setFont(new Font("Courier",1,26));
		
		cmdWin   = new JButton("Win");
	    cmdLose  = new JButton("Lose");
		cmdWin.addActionListener(this);
		cmdLose.addActionListener(this);
		
		//add(cmdWin);
		add(lblWin);
		add(lblWinScore);
		add(lblLose);
		add(lblLoseScore);
		//add(cmdLose);
    
				
	}
	public ScoringPanel(int currentWins, int currentLoses)
	{
		super();
		setBackground(Color.cyan);	
	    myWinCount = currentWins;
	    myLoseCount = currentLoses;
	    
		lblWin = new JLabel("Number of wins: ");
		lblWinScore = new JLabel( s.valueOf(myWinCount)+"  " );
		lblLose  = new JLabel("  Number of losses: ");
		lblLoseScore = new JLabel(s.valueOf(myLoseCount)+"  " );
		
		lblWin.setFont(new Font("Times New Roman",0,14));
		lblLose.setFont(new Font("Times New Roman",0,14));
		lblWinScore.setFont(new Font("Courier",1,26));
		lblLoseScore.setFont(new Font("Courier",1,26));
		
		cmdWin   = new JButton("Win");
	    cmdLose  = new JButton("Lose");
		cmdWin.addActionListener(this);
		cmdLose.addActionListener(this);
		
		//add(cmdWin);
		add(lblWin);
		add(lblWinScore);
		add(lblLose);
		add(lblLoseScore);
		//add(cmdLose);
    
	}
	public int getWin()
	{
		return myWinCount;
	}
	public void setWin(int x)
	{
		myWinCount = x;
		lblWinScore.setText(s.valueOf(myWinCount));
	}
	public int getLose()
	{
		return myLoseCount;
	}
	public void setLose(int x)
	{
		myLoseCount = x;
		lblLoseScore.setText(s.valueOf(myLoseCount));
	}
	
	public void actionPerformed(ActionEvent ae)
	{
		int button;
		String command = ae.getActionCommand();
		System.out.println("Scoring: "+command);
		if (command.equals("Win"))
		{
			myWinCount++;
			lblWinScore.setText(s.valueOf(myWinCount));
		} 
		else
		{
			myLoseCount++;
			lblLoseScore.setText(s.valueOf(myLoseCount));
		}
    }
}