import javax.swing.*;
public class Book extends Item
{
	private Author[] author;

	public Book()
	{
	}

	public Book(int bid, String title, Author[] author, int copy)
	{
		setID(bid);
		setTitle(title);
		setNum_copies(copy);
		setHave();
		setAuthor(author);
	}


	public void setAuthor(Author[] author)
	{
		this.author = new Author[author.length];
		for (int i=0; i<author.length; i++)
		{
			this.author[i] = author[i];
		}
	}

	public Author getAuthor(int i)
	{
		return author[i];
	}


	//------------------
	public Author getAuthor(String name)
	{
		for (int i=0; i<author.length; i++)
		{
			if (author[i].getName().equals (name))
			return author[i];
		}
		return null;
	}


	public String printItem()
	{


		String out = "";
		out+= " " + getID();
		out+= ", " + getTitle();

		for (int i = 0; i < author.length; i++)
		{
			out+=", " + author[i].getName();
		}

		if (getHave() == true)
		{
			out+=", On Shelf - ";
		}
		else
		{
			out+=", Checked Out - ";
		}

		out+= getNum_copies() + " in Stock";
		return out;
	}
}
