/**********************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * $Id: Order.java,v 1.1 2006/07/07 23:08:07 nmehrega Exp $
 * 
 * Contributors: 
 * IBM - Initial API and implementation
 **********************************************************************/

/**
 * Used to simulate the process flow of an order
 * 
 * @author Navid Mehregani
 */
public class Order { 	
	
	/**
	 * Main point of entry.  Used to place the order
	 */
	public static void main(String[] args) {
		 
		System.out.println("Start");
		Order myOrder = new Order();
		myOrder.placeOrder("Tools", 20); 
		System.out.println("Finish");
	}   
	
	/**
	 * Place an order by specifying the product name and its quantity
	 */
	public void placeOrder(String product, int quantity)
	{		 
		getSupplierList();
		String supplier = connectWithSupplier();
		sendOrder(supplier, product, quantity);
	}
	
	/**
	 * Send the order to the supplier
	 */
	public void sendOrder(String supplier, String product, int quantity)
	{
		try
		{
			constructOrderForm(product, quantity);
		} catch (Exception e)
		{
			
		}
		
	}
	
	/**
	 * Construct an order form using the product name and its quantity
	 */
	public void constructOrderForm(String product, int quantity) throws Exception
	{
		checkProductAvailability(product);
		if (quantity > 10)
			throw new Exception("Too many items requested.");
	}
	
	public String connectWithSupplier()
	{
		return "ACME Supplier";
	}
	
	public void getSupplierList()
	{
		// Do Nothing
	}
		
	public void checkProductAvailability(String product)
	{
		// Do Nothing
	}
   
}
