0

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");
            }
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

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).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.