Section 3.5. Building an Ajax-powered coffee maker


3.5. Building an Ajax-powered coffee maker

Two coffee makers... ...and a whole office of caffeine addicts.

As the official "coffee pot manager," it's your job to make sure that the caffeine needs of your officemates are met... and quickly, at that. All your mates are caffeine addicts, and they get a bit testy if there's no fresh coffee on hand. Good thing that there are two coffee makers; even if one order is being brewed, your co-workers can place another order, and have it filled by the second coffee maker.

You're going to build an Ajax application to allow your co-workers to order their coffee online.

You don't want anyone coming after you with empty coffee cups, so let's write an Ajax application for ordering coffee and keeping track of the status of both coffee makers. Here's what it will look like:

Here's the second coffee maker. If an order is brewing in coffee maker #1, this coffee maker will handle any additional orders. Just like coffee maker #1, it takes a little time to brew a cup.

This is the main coffee maker. Anytime an order is placed, and no coffee is brewing, this coffee maker handles the order. It takes a little time to brew a cup, though, and the coffee maker can only brew one cup at a time.

Here's where you place your order. You enter your name, the size of the cup you want, and what type of beverage you're interested in.

Once you've told the coffee maker what you want, you click "Order Coffee" to send the order to an open coffee maker.




Head Rush Ajax
Head Rush Ajax (Head First)
ISBN: 0596102259
EAN: 2147483647
Year: 2004
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net