Embed
Email

public class Author

Document Sample

Shared by: huanghengdong
Categories
Tags
Stats
views:
0
posted:
12/13/2011
language:
pages:
2
import javax.swing.*;

public class Library

{

Book[] books = new Book[3];

Patron[] patrons = new Patron[3];

Author[] authors;



public static void main (String[] args)

{

Library lib = new Library();

lib.addBookAuthor();

lib.showBookAuthor();

lib.addPatron();

lib.showPatron();

//lib.showBookAuthor();

//lib.patrons[0].checkBookIn();

//lib.patrons[2].checkBookIn();

//lib.showPatron();

//lib.showBookAuthor();

System.exit(0);

}



private void addBookAuthor()

{

authors = new Author[1];

authors[0] = new Author ("Harper Lee", "5/23/54");

books[0] = new Book (101, "To kill a Mockingbird", authors , 2);



authors = new Author[2]; // 2 authors in this book

authors[0] = new Author ("Amy Tan", "1/03/14");

authors[1] = new Author ("Jack London", "1/12/06");

books[1] = new Book (102, "The Joy Luck Club", authors, 1);



authors = new Author[1];

authors[0] = new Author ("C.S.Lewis", "2/03/74");

books[2] = new Book (103, "Perelandra", authors, 2);

}



private void addPatron()

{

patrons[0] = new Patron(1, "Fred Capestany", 0, books[2]);

patrons[1] = new Patron(2, "Gurpreet Kaur", 0, null);

patrons[2] = new Patron(3, "Vera Doroshenko", 0, books[2]);

}



private void showBookAuthor() //Library Inventory

{

String output = "";

for (int i=0; i1) //if more than 1 author in the book

{

output+=", "; //put comma between authors

numAuthors--;

}

}

output+=", ";

output+=books[i].getNum_copies()+", ";

output+=books[i].getCheckStatus();

output+="\n";

}



output+="\n\nThere are " + books.length + " books in inventory.";

JOptionPane.showMessageDialog(null, output,"Library Inventory",

JOptionPane.PLAIN_MESSAGE);

}



private void showPatron()

{

String output = "";

for (int i=0; i
{

output+=patrons[i].getPID()+", ";

output+=patrons[i].getPName()+", ";

if (patrons[i].getBook() == null)

{

output+= "no books";

}

else

{

output+=patrons[i].getBook().getTitle();

}

output+="\n";



}

output+="\n\nThere are " + patrons.length + " patrons in library.";

JOptionPane.showMessageDialog(null, output,"Patron Summary",



JOptionPane.PLAIN_MESSAGE);

}

}



Other docs by huanghengdong
2012_Vendor_Form_Wedding_Expo
Views: 0  |  Downloads: 0
SCOPE 1 GP letter v2.0 12Mar2007
Views: 0  |  Downloads: 0
Boston_immigration_records
Views: 2  |  Downloads: 0
PSC MATRIX of achievement 080709
Views: 0  |  Downloads: 0
Summary - CIRCA
Views: 0  |  Downloads: 0
ieee_wiley_ebooks_library_customer_title_list
Views: 0  |  Downloads: 0
2009-2010_ACC0044_fishers_772_07-dec-2009
Views: 1  |  Downloads: 0
FSP20111216-EN
Views: 0  |  Downloads: 0
Workshops
Views: 0  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!