import java.util.Random;


public class SlotMachine 
{
	private Random rand;
	private String item1, item2, item3;

	private final String[] ITEMS = {"Cherries", "Oranges", "Plums", "Bells", "Melons", "Bars"};
	
	public SlotMachine(Random rand)
	{
		this.rand = rand;
		item1 = ITEMS[0];
		item2 = ITEMS[1];
		item3 = ITEMS[2];
	}
	
	public SlotMachine()
	{
		this(new Random());
	}
	
	public int matches()
	{
		int numMatch;
		numMatch = 0;
		
		if (item1.equals(item2) && item1.equals(item3))
		{
			numMatch = 3;
		}
		else if (item1.equals(item2) || item1.equals(item3) || item2.equals(item3))
		{
			numMatch = 2;
		}
		return numMatch;
	}
	
	public String pullHandle()
	{
		// get three values
		item1 = ITEMS[rand.nextInt(6)];
		item2 = ITEMS[rand.nextInt(6)];
		item3 = ITEMS[rand.nextInt(6)];
		return this.toString();
	}
	
	public String toString()
	{
		return item1 + "\t" + item2 + "\t" + item3;
	}
}
