import javax.swing.*;
public class Item extends ID
{
	private String title;
	private int copy;			//how many copies of book/cd do we have?
	private boolean have;		//do we have at least one copy?

	public Item ()
	{
	}

	public Item(int id, String title, int copy, boolean have)
	{
		setID(id);
		setTitle(title);
		setNum_copies(copy);
		setHave(have);
	}


	public void setTitle(String title)            {this.title = title;}
	public void setNum_copies(int copy) {this.copy = copy;}
	public void setHave(boolean have)    {this.have = have;}

	public String    getTitle()                 {return title;}
	public int           getNum_copies()  {return copy;}
	public boolean getHave()               {return have;}



	//--------------------check in/out
	public void checkIn()
	{
		have = true;
		setNum_copies(getNum_copies() + 1);		//copy++;
	}

	public void checkOut()
	{
		if (have == false)
		{
			JOptionPane.showMessageDialog(
			null,"There is no copy in stock", "error", JOptionPane.ERROR_MESSAGE);
		}
		else
		{
			setNum_copies(getNum_copies() - 1); 		//copy--
			if (getNum_copies() == 0)
				have = false;
		}
	}


    //-----------------------
	public String getCheckStatus()
	{
		if (have == true)
		{
			return "On shelf";
		}
		return "Checked out";
	}

	public String printItem()
	{
		return "";
	}

	public String ItemOut()
	{
		return getTitle();
	}
}
