
package database;

import java.util.*;

class BookstoreDB {

    private Hashtable database;
    private BookDetails[] dbByTitle;
    private final int numberOfBooks = 12;

    BookstoreDB () {
        BookDetails book;
        database = new Hashtable();
        dbByTitle = new BookDetails[numberOfBooks];

        book = new BookDetails("901", "Mervin", "Roberts",
                     "A Complete Introduction to Snakes;Completely Ilustrated in Full Color",
                     (float)3.95, 1987, "What a cool book");
        database.put(new Integer(901), book);
        dbByTitle[0] = book;

        book = new BookDetails("902", "Jack", "Harris",
                     "A Step-By-Step Book about Iguanas", (float)5.06,
                     1989,"Interesting!" );
        database.put(new Integer(902), book);
        dbByTitle[1] = book;

        book = new BookDetails("903", "Ray", "Staszko",
                     "A Step-By-Step Book about Pet Lizards", (float)5.96,
                      1991, "What a cool book");
        database.put(new Integer(903), book);
        dbByTitle[2] = book;

        book = new BookDetails("904", "Anderson", "",
                     "A Step-By-Step Book about Snakes", (float)4.96,
                      1990, "What a cool book");
        database.put(new Integer(904), book);
        dbByTitle[3] = book;

        book = new BookDetails("905", "Ulrich", "Antheny",
                     "Agamid Lizards",
                     (float)14.75, 1997, "What a cool book");
        database.put(new Integer(905), book);
        dbByTitle[4] = book;

        book = new BookDetails("906", "John", "Coborn",
                     "Amphibians Today", (float)10.75,
                     1998, "What a cool book");
        database.put(new Integer(906), book);
        dbByTitle[5] = book;

        book = new BookDetails("907", "Steve", "Grenard",
                     "Amphibians: Their Care and Keeping",
                     (float)17.75, 1998, "What a cool book");
        database.put(new Integer(907), book);
        dbByTitle[6] = book;

        book = new BookDetails("908", "Richard", "Bartlett",
                     "Anoles, Basilisks and Water Dragons",
                     (float)5.75, 1997, "What a cool book");
        database.put(new Integer(908), book);
        dbByTitle[7] = book;

        book = new BookDetails("909", "Chris", "Wood",
                     "Basic Care of Rough Green Snakes",
                     (float)5.75, 1997, "What a cool book");
        database.put(new Integer(909), book);
        dbByTitle[8] = book;

        book = new BookDetails("910", "David", "Zoffer",
                     "Bearded and Frilled Dragons",
                     (float)8.55, 1998, "What a cool book");
        database.put(new Integer(910), book);
        dbByTitle[9] = book;

        book = new BookDetails("911", "Richard", "Bartlett",
                     "Bearded Dragons: Facts & Advice on Care and Breeding",
                     (float)4.55, 1999, "What a cool book");
        database.put(new Integer(911), book);
        dbByTitle[10] = book;

        book = new BookDetails("912", "Doug", "Wagner",
                     "Boas: Everything about Acquisition, Care, Nutrition, Diseases, Breeding, and Behaviour",
                     (float)5.55, 1996, "What a cool book");
        database.put(new Integer(912), book);
        dbByTitle[11] = book;
    }

    BookDetails getBookDetails(String bookId) {
        Integer key = new Integer(bookId);

        return (BookDetails)database.get(key);
    }

    BookDetails[] getBooksSortedByTitle() {
        return dbByTitle;
    }

    int getNumberOfBooks() {
        return numberOfBooks;
    }
}



