how do i increment the category book? eventually i will display it in summary
***************
Summary
Books 3.

public class ProductDB
{
	public static String[] inventory = {"  java", "jsps", "mcb2", "txtp", "sgtp", "tgif", "tcby", "myob"};

    public static Product getProduct(String productCode)
    {
        Product p = null;

        if (productCode.equalsIgnoreCase("java") ||
           productCode.equalsIgnoreCase("jsps") ||
           productCode.equalsIgnoreCase("mcb2"))
        {
            Book b = new Book();
            //int bookCounter = 0;

            if (productCode.equalsIgnoreCase("java"))
            {
                b.setCode(productCode);
                b.setDescription("Murach's Beginning Java 2");
                b.setCategory("Book");
                b.setPrice(49.50);
                b.setAuthor("Andrea Steelman");
            }
            else if (productCode.equalsIgnoreCase("jsps"))
            {
                b.setCode(productCode);
                b.setDescription("Murach's Java Servlets and JSP");
                b.setPrice(49.50);
                b.setCategory("Book");
                b.setAuthor("Andrea Steelman");
            }

You would need a static class variable called 'numberOfBooks' declared as an int and you would simply do numberOfBooks++; every time you added a book to your collection (or whatever causes you to want to increment that category).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.