import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class BurritoInventoryProducer extends HttpServlet { // Get (and keep!) a reference to the shared BurritoInventory instance BurritoInventory inventory = BurritoInventory.getInstance(); public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println(""); out.println("Burrito Inventory Producer"); // 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(""); out.println("

Added ingredients:

"); out.println("
");
    out.println("cheese: " + cheese);
    out.println("rice: " + rice);
    out.println("beans: " + beans);
    out.println("chicken: " + chicken);
    out.println("
"); out.println(""); } }