FileDocCategorySizeDatePackage
BurritoInventoryProducer.javaAPI DocExample1406Tue Jan 25 10:45:14 GMT 2000None

BurritoInventoryProducer

public class BurritoInventoryProducer extends HttpServlet

Fields Summary
BurritoInventory
inventory
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)


       
                                  
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    out.println("<HTML>");
    out.println("<HEAD><TITLE>Burrito Inventory Producer</TITLE></HEAD>");

    // Produce random amounts of each item
    Random random = new Random();

    int cheese = Math.abs(random.nextInt() % 10);
    int rice = Math.abs(random.nextInt() % 10);
    int beans = Math.abs(random.nextInt() % 10);
    int chicken = Math.abs(random.nextInt() % 10);

    // Add the items to the inventory
    inventory.addCheese(cheese);
    inventory.addRice(rice);
    inventory.addBeans(beans);
    inventory.addChicken(chicken);

    // Print the production results
    out.println("<BODY>");
    out.println("<H1>Added ingredients:</H1>");
    out.println("<PRE>");
    out.println("cheese: " + cheese);
    out.println("rice: " + rice);
    out.println("beans: " + beans);
    out.println("chicken: " + chicken);
    out.println("</PRE>");
    out.println("</BODY></HTML>");