import javax.swing.*;
public class Library
{
								//Declare object arrays; they have class scope
	//ID[] id = new ID[50];
	//Book[] book = new Book[3];
	//CD[] cd = new CD[4];
	//Person[] person = new Person[10];
	Item[] item = new Item[7];
	Patron[] patron = new Patron[3];
	Author[] author;				//could be 2 or more authors in each book
	Artist[] artist;				//could be 2 or more artists in each CD


	public static void main (String[] args)						// MAIN
	{
		Library lib = new Library();

		lib.addItem();
		lib.showItem();

		lib.addPatron();
		lib.showPatron();
		lib.showItem();
		//lib.showBookAuthor();
		//lib.patron[0].checkBookIn();
		//lib.patron[2].checkBookIn();
		//lib.showPatron();
		//lib.showBookAuthor();
		System.exit(0);
	}

	private void addItem()
	{
		author = new Author[1];
		author[0] = new Author (001, "Harper Lee", "5/23/54");
		item[0] = new Book (101, "To kill a Mockingbird", author , 2);

		author = new Author[2];	//---- 2 authors in this book
		author[0] = new Author (003, "Jack London", "1/12/06");
		author[1] = new Author (002, "Amy Tan", "1/03/14");
		item[1] = new Book (102, "Hearts of the Three", author, 1);

		author = new Author[1];
		author[0] = new Author (004, "C.S.Lewis", "2/03/74");
		item[2] = new Book (103, "Perelandra", author, 2);

		artist = new Artist[1];
		artist[0] = new Artist (601, "combined", "nonclassical");
		item[3] = new CD (501, "Greatest Hits", artist, 61, 3);

		artist = new Artist[1];
		artist[0] = new Artist (602, "combined", "nonclassical");
		item[4] = new CD (502, "Hymns to the Silence", artist, 50, 1);

		artist = new Artist[1];
		artist[0] = new Artist (603, "Peter Tchaykovsky", "classical");
		item[5] = new CD (503, "First Concert", artist, 75, 1);

		artist = new Artist[1];
		artist[0] = new Artist (604, "The Beatles", "nonclassical");
		item[6] = new CD (504, "Yesterday", artist, 58, 3);

	}

	private void addPatron()
	{
		patron[0] = new Patron(1, "Fred Capestany");
		patron[0].checkItemOut( item[1]);
		patron[0].checkItemOut( item[5]);
		patron[0].checkItemOut( item[2]);


		patron[1] = new Patron(2, "Gurpreet Kaur");
		patron[1].checkItemOut( item[0]);
		patron[1].checkItemOut( item[6]);

		patron[2] = new Patron(3, "Vera Doroshenko");
		//patron[2].checkItemOut( item[2]);
	}

	private void showItem()				//Books Library Inventory
	{
		String output = "";
		for (int i=0; i<item.length; i++)
		{
			output+=item[i].printItem();
			output+="\n";
		}
		output+="\n\nThere are " +item.length+ " items in inventory.";
		JOptionPane.showMessageDialog(null, output,"Items Library Inventory",
									JOptionPane.PLAIN_MESSAGE);
	}

	private void showPatron()
	{
		String output = "";
		for (int i=0; i<patron.length; i++)
		{
			output+= patron[i].printPatron();
			output+="\n";
		}
		output+="\n\nThere are " +patron.length+ " Patrons.";
				JOptionPane.showMessageDialog(null, output,"Patrons Summary",
									JOptionPane.PLAIN_MESSAGE);
	}
}
