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, true);

		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, true);

		author = new Author[1];
		author[0] = new Author (004, "C.S.Lewis", "2/03/74");
		item[2] = new Book (103, "Perelandra", author, 2, true);

		artist = new Artist[1];
		artist[0] = new Artist (601, "combined", "nonclassical");
		item[3] = new CD (501, "Greatest Hits", artist, 61, 3, true);

		artist = new Artist[1];
		artist[0] = new Artist (602, "combined", "nonclassical");
		item[4] = new CD (502, "Hymns to the Silence", artist, 50, 1, true);

		artist = new Artist[1];
		artist[0] = new Artist (603, "Peter Tchaykovsky", "classical");
		item[5] = new CD (503, "First Concert", artist, 75, 1, true);

		artist = new Artist[1];
		artist[0] = new Artist (604, "The Beatles", "nonclassical");
		item[6] = new CD (504, "Yesterday", artist, 58, 3, true);

	}

	private void addPatron()
	{
		Item[] tempItem = new Item[3];		//tempItem - checked out items

		tempItem[0] = item[1];
		tempItem[1] = item[4];
		tempItem[2] = item[5];
		patron[0] = new Patron(1, "Fred Capestany", tempItem);

		tempItem = new Item[2];
		tempItem[0] = item[0];
		tempItem[1] = item[6];
		patron[1] = new Patron(2, "Gurpreet Kaur", tempItem);

		tempItem = new Item[1];
		tempItem[0] = item[2];
		patron[2] = new Patron(3, "Vera Doroshenko",  tempItem);
	}

	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);
	}
}
