Archives from S:\ Drive

Good to keep around methinks
This commit is contained in:
Amrit Panesar committed 2015-04-01 21:23:15 -07:00
1 parent eadaf70b9e
commit 6dd63cc439
606 files changed
+50212

No files matched your search

@@ -0,0 +1,50 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: CashCustomer *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Created On: Nov 21, 2012 *
* Hours: X.XX Hours *
* Purpose: TODO: Write purpose here. *
******************************************************************************/
package project2;
/**
*
* @author Amrit Panesar <apanesar@coleman.edu>
*/
public class CashCustomer extends Customer {
/**
*Overrides Customer.java 's Discount percent.
*/
private double CustomerModifierPercent = 0.02;
private Customer customer;
public CashCustomer(Customer customer) {
this.customer = customer;
System.out.println("You are a cash customer, you get a 2% discount!");
}
public double getCustomerModifierPercent() {
return CustomerModifierPercent;
}
public void setCustomerModifierPercent(double CustomerModifierPercent) {
this.CustomerModifierPercent = CustomerModifierPercent;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
@Override
public double doTotal(double dPrice)
{
return dPrice-(dPrice*(this.CustomerModifierPercent));
}
}
@@ -0,0 +1,50 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: CreditCustomer *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Created On: Nov 21, 2012 *
* Hours: X.XX Hours *
* Purpose: TODO: Write purpose here. *
******************************************************************************/
package project2;
/**
*
* @author Amrit Panesar <apanesar@coleman.edu>
*/
public class CreditCustomer extends Customer{
private Customer customer;
/**
*Overrides Customer.java 's Discount percent.
*/
private double CustomerModifierPercent = +1.02;
public CreditCustomer(Customer customer) {
this.customer = customer;
System.out.println("You are a credit customer, you are subject to a 2% markup");
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public double getCustomerModifierPercent() {
return CustomerModifierPercent;
}
public void setCustomerModifierPercent(double CustomerModifierPercent) {
this.CustomerModifierPercent = CustomerModifierPercent;
}
@Override
public double doTotal(double dPrice)
{
return dPrice*(this.CustomerModifierPercent);
}
}
@@ -0,0 +1,116 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: Customer *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Created On: Nov 21, 2012 *
* Hours: X.XX Hours *
* Purpose: TODO: Write purpose here. *
******************************************************************************/
package project2;
/**
*
* @author Amrit Panesar <apanesar@coleman.edu>
*/
public class Customer {
protected int CustomerID;
protected String CustomerName;
protected String CustomerAddress1;
protected String CustomerAddress2;
protected String CustomerCity;
protected String CustomerState;
protected String CustomerZip;
protected int CustomerPaymentType; // Customer.CASH, Customer.CREDIT
public static final int CASH = 0;
public static final int CREDIT = 1;
/**
* If extending this class, CustomerModifierPercent should be overridden.
*/
protected double CustomerModifierPercent = 0;
public Customer() {
}
public Customer(int CustomerID, String CustomerName, String CustomerAddress1, String CustomerAddress2, String CustomerCity, String CustomerState, String CustomerZip) {
this.CustomerID = CustomerID;
this.CustomerName = CustomerName;
this.CustomerAddress1 = CustomerAddress1;
this.CustomerAddress2 = CustomerAddress2;
this.CustomerCity = CustomerCity;
this.CustomerState = CustomerState;
this.CustomerZip = CustomerZip;
}
public int getCustomerID() {
return CustomerID;
}
public void setCustomerID(int CustomerID) {
this.CustomerID = CustomerID;
}
public String getCustomerName() {
return CustomerName;
}
public void setCustomerName(String CustomerName) {
this.CustomerName = CustomerName;
}
public String getCustomerAddress1() {
return CustomerAddress1;
}
public void setCustomerAddress1(String CustomerAddress1) {
this.CustomerAddress1 = CustomerAddress1;
}
public String getCustomerAddress2() {
return CustomerAddress2;
}
public void setCustomerAddress2(String CustomerAddress2) {
this.CustomerAddress2 = CustomerAddress2;
}
public String getCustomerCity() {
return CustomerCity;
}
public void setCustomerCity(String CustomerCity) {
this.CustomerCity = CustomerCity;
}
public String getCustomerState() {
return CustomerState;
}
public void setCustomerState(String CustomerState) {
this.CustomerState = CustomerState;
}
public String getCustomerZip() {
return CustomerZip;
}
public void setCustomerZip(String CustomerZip) {
this.CustomerZip = CustomerZip;
}
public int getCustomerPaymentType() {
return CustomerPaymentType;
}
public void setCustomerPaymentType(int CustomerPaymentType) {
this.CustomerPaymentType = CustomerPaymentType;
}
public double doTotal(double dPrice)
{
return -9.99;
}
}
@@ -0,0 +1,120 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: CustomerHandler *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 2.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
import java.util.Scanner;
/**
*
* @author 77260
*/
public class CustomerHandler {
public static void invoke()
{
while(true)
{
int iSelect = menu();
int iThing = doThing(iSelect);
if (iThing == -999) {
return;
}
}
}
public static int menu()
{
Scanner console = new Scanner(System.in);
System.out.println(Project2.md.get(MenuHandler.CUSTOMER_MENU_ID));
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = 0;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
if (iOut < 0 && iOut > 4)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
return iOut;
}
private static int doThing(int iSel) {
switch (iSel)
{
case 1:
AddCustomer();
break;
case 2:
DeleteCustomer();
break;
case 3:
ReportHandler.RunCustomerReport();
break;
case 4:
return -999;
}
return 0;
}
private static void AddCustomer() {
throw new UnsupportedOperationException("Not yet implemented");
}
private static void DeleteCustomer() {
throw new UnsupportedOperationException("Not yet implemented");
}
static Customer findCustomer() {
String sPrompt = "Please enter either the ID or the name of the customer you wish to query.";
Scanner console = new Scanner(System.in);
System.out.println(sPrompt);
System.out.print(MenuHandler.PROMPT);
String input = console.next();
boolean isID;
try
{
Integer.parseInt(input);
isID = true;
}
catch(Exception e)
{
isID = false;
}
if (isID)
{
for (int i=0;i<Project2.cu.size();i++)
{
Customer cust = Project2.cu.get(i);
if (cust.getCustomerID() == Integer.parseInt(input))
{
return cust;
}
}
return null;
}
else
{
for (int i=0;i<Project2.cu.size();i++)
{
Customer cust = Project2.cu.get(i);
if (cust.getCustomerName().equals(input))
{
return cust;
}
}
return null;
}
}
}
@@ -0,0 +1,80 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: Inventory *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 1.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
/**
*
* @author Amrit Panesar
*/
public class Inventory {
public int iItemID;
public String sItemName;
public int iInStore;
public double dManuPrice;
public double dSellPrice;
public Inventory() {
}
public Inventory(int iItemID, String sItemName, int iInStore, double dManuPrice, double dSellPrice) {
this.iItemID = iItemID;
this.sItemName = sItemName;
this.iInStore = iInStore;
this.dManuPrice = dManuPrice;
this.dSellPrice = dSellPrice;
}
public double getdManuPrice() {
return dManuPrice;
}
public void setdManuPrice(double dManuPrice) {
this.dManuPrice = dManuPrice;
}
public double getdSellPrice() {
return dSellPrice;
}
public void setdSellPrice(double dSellPrice) {
this.dSellPrice = dSellPrice;
}
public int getiInStore() {
return iInStore;
}
public void setiInStore(int iInStore) {
this.iInStore = iInStore;
}
public int getiItemID() {
return iItemID;
}
public void setiItemID(int iItemID) {
this.iItemID = iItemID;
}
public String getsItemName() {
return sItemName;
}
public void setsItemName(String sItemName) {
this.sItemName = sItemName;
}
@Override
public String toString()
{
return ""+this.getiInStore();
}
}
@@ -0,0 +1,156 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: InventoryHandler *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 2.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
import java.util.Scanner;
/**
*
* @author 77260
*/
public class InventoryHandler {
public static void invoke()
{
while(true)
{
int iSelect = menu();
int iThing = doThing(iSelect);
if (iThing == -999) {
return;
}
}
}
public static int menu()
{
Scanner console = new Scanner(System.in);
System.out.println(Project2.md.get(MenuHandler.INVENTORY_MENU_ID));
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = 0;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
if (iOut < 0 && iOut > 5)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
return iOut;
}
private static int doThing(int iSel)
{
switch (iSel)
{
case 1:
AddInventory();
break;
case 2:
DeleteInventory();
break;
case 3:
EditInventory();
break;
case 4:
ReportHandler.RunInventoryReport();
break;
case 5:
return -999;
}
return 0;
}
private static void AddInventory() {
throw new UnsupportedOperationException("Not yet implemented");
}
private static void DeleteInventory() {
throw new UnsupportedOperationException("Not yet implemented");
}
private static void EditInventory() {
throw new UnsupportedOperationException("Not yet implemented");
}
protected static int getItemID()
{
String sPrompt = "Please enter the ID of the item you wish to query.";
Scanner console = new Scanner(System.in);
System.out.println(sPrompt);
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = 0;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, try again?");
System.out.print("([Y]es/[N]o)"+MenuHandler.PROMPT);
input = console.next();
char cIn = input.toLowerCase().charAt(0);
if (cIn == 'y') {
iOut = -999;
}
else {
iOut = getItemID();
}
}
return iOut;
}
protected static int getStock(int iID)
{
for (int i=0;i<Project2.al.size();i++)
{
Inventory item = Project2.al.get(i);
if(item.getiItemID() == iID) {
return i;
}
}
return -999;
}
protected static int checkStock()
{
int iID = getItemID();
if (iID == -999) {
return -999;
}
int iArrayID = getStock(iID);
if(iArrayID == -999) {
System.out.println("Item not found.");
} else {
Inventory inv = Project2.al.get(iArrayID);
int iStock = inv.getiInStore();
String sDesc = inv.getsItemName();
System.out.println("Item ID - "+iID+" ("+sDesc+") Currently has "
+iStock+" items in stock.");
return iArrayID;
}
return -999;
}
protected static void removeStock(int iArrayID, int iOut)
{
Inventory inv = Project2.al.get(iArrayID);
int iStock = inv.getiInStore();
iStock -= iOut;
inv.setiInStore(iStock);
Project2.al.set(iArrayID, inv);
}
}
@@ -0,0 +1,60 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: MenuDialog *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Created On: Nov 21, 2012 *
* Hours: X.XX Hours *
* Purpose: TODO: Write purpose here. *
******************************************************************************/
package project2;
/**
*
* @author Amrit Panesar <apanesar@coleman.edu>
*/
public class MenuDialog {
private int index;
private String title;
private String menu;
public MenuDialog() {
}
public MenuDialog(int index, String title, String menu) {
this.index = index;
this.title = title;
this.menu = menu;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getMenu() {
return menu;
}
public void setMenu(String menu) {
this.menu = menu;
}
@Override
public String toString()
{
return this.menu;
}
}
@@ -0,0 +1,96 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: MenuHandler *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 2.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
import java.util.ArrayList;
/**
*
* @author 77260
*/
public class MenuHandler {
protected static ArrayList<MenuDialog> menu_dialog_init() {
ArrayList<MenuDialog> md = new ArrayList<MenuDialog>(1);
md.add(0, new MenuDialog(0, "Main Menu",
"---------------------------------Main Menu----------------------------------\n"+
"1) Customer Actions \n"+
"2) Order Actions \n"+
"3) Inventory Actions \n"+
"4) Report Actions \n"+
"5) Exit \n"+
" Please enter your selection. Numbers 1-5 are accepted."));
md.add(1, new MenuDialog(1, "Customer Manipulation Menu",
"-------------------------Customer Manipulation Menu-------------------------\n"+
"1) Add Customer \n"+
"2) Delete Customer \n"+
"3) Run Customer Report \n"+
"4) Back to Main Menu \n"+
" Please enter your selection. Numbers 1-4 are accepted."));
md.add(2, new MenuDialog(2, "Order Manipulation Menu",
"---------------------------Order Manipulation Menu--------------------------\n"+
"1) New Order \n"+
"2) Remove Order \n"+
"3) Run Order Report \n"+
"4) Back to Main Menu \n"+
" Please enter your selection. Numbers 1-4 are accepted."));
md.add(3, new MenuDialog(2, "Inventory Manipulation Menu",
"------------------------Inventory Manipulation Menu-------------------------\n"+
"1) Add Items to Inventory \n"+
"2) Delete Items From Inventory \n"+
"3) Edit Inventory Quantities \n"+
"4) Run Inventory Report \n"+
"5) Back to Main Menu \n"+
" Please enter your selection. Numbers 1-5 are accepted."));
md.add(4, new MenuDialog(2, "Report Display Menu",
"-----------------------------Report Display Menu----------------------------\n"+
"1) Run Customer Report \n"+
"2) Run Order Report \n"+
"3) Run Inventory Report \n"+
"4) Back to Main Menu \n"+
" Please enter your selection. Numbers 1-4 are accepted."));
return md;
}
/* ItemID itemName pInStore manufPrice sellingPrice
* 12 Circular saw 150 $ 45.00 $ 125.00
* 235 Cooking range 50 $ 450.00 $ 850.00
* 301 Table saw 100 $ 125.00 $ 300.00
* 302 Stapler 300 $ 18.00 $ 49.00
* 303 Lawn tractor 5 $ 300.00 $ 650.00
*/
protected static ArrayList<Inventory> inventory_init()
{
ArrayList<Inventory> al = new ArrayList<Inventory>(5);
al.add(0, new Inventory(12,"Circular saw", 150, 45.00, 125.00));
al.add(1, new Inventory(235,"Cooking range", 50, 450.00, 850.00));
al.add(2, new Inventory(301,"Table saw", 100, 125.00, 300.00));
al.add(3, new Inventory(302,"Stapler\t", 300, 18.00, 49.00));
al.add(4, new Inventory(303,"Lawn tractor", 5, 300.00, 650.00));
return al;
}
protected static ArrayList<Customer> customer_init() {
ArrayList<Customer> cu = new ArrayList<Customer>(5);
cu.add(0,new Customer(0, "Kermit Thefrog", "8888 Balboa Avenue", "", "San Diego", "CA", "92123"));
return cu;
}
static ArrayList<Order> order_init() {
ArrayList<Order> or = new ArrayList<Order>(5);
return or;
}
public final static int MAIN_MENU_ID = 0;
public final static int CUSTOMER_MENU_ID = 1;
public final static int ORDER_MENU_ID = 2;
public final static int INVENTORY_MENU_ID = 3;
public final static int REPORT_MENU_ID = 4;
public final static String PROMPT = ":";
}
@@ -0,0 +1,67 @@
/******************************************************************************
* Project: Project2 *
* Class Name: Order *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Created On: Nov 21, 2012 *
* Hours: X.XX Hours *
* Purpose: TODO: Write purpose here. *
******************************************************************************/
package project2;
/**
*
* @author Amrit Panesar <apanesar@coleman.edu>
*/
public class Order {
private Customer customer;
private Inventory item;
private int quantity;
private double total;
public Order() {
}
public double getTotal() {
return total;
}
public void setTotal(double total) {
this.total = total;
}
public Order(Customer customer, Inventory item, int quantity, double total) {
this.customer = customer;
this.item = item;
this.quantity = quantity;
this.total = total;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public Inventory getItem() {
return item;
}
public void setItem(Inventory item) {
this.item = item;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public double computePrice() {
return (this.quantity * this.item.getdManuPrice());
}
}
@@ -0,0 +1,203 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: OrderHandler *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 2.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
import java.util.Scanner;
/**
*
* @author 77260
*/
public class OrderHandler {
public static void invoke()
{
while(true)
{
int iSelect = menu();
int iThing = doThing(iSelect);
if (iThing == -999) {
return;
}
}
}
public static int menu()
{
Scanner console = new Scanner(System.in);
System.out.println(Project2.md.get(MenuHandler.ORDER_MENU_ID));
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = 0;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
if (iOut < 0 && iOut > 4)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
return iOut;
}
private static int doThing(int iSel) {
switch (iSel)
{
case 1:
AddOrder();
break;
case 2:
DeleteOrder();
break;
case 3:
ReportHandler.RunOrderReport();
break;
case 4:
return -999;
}
return 0;
}
private static void AddOrder() {
Order ord = new Order();
Customer cust = CustomerHandler.findCustomer();
if (cust == null)
{
Scanner console = new Scanner(System.in);
String input;
System.out.println("We're sorry. We were unable to find that customer, try again?");
System.out.print("([Y]es/[N]o)"+MenuHandler.PROMPT);
input = console.next();
char cIn = input.toLowerCase().charAt(0);
if (cIn == 'y') {
AddOrder();
}
else
{
System.out.println("Your order has been canceled.");
return;
}
}
else
{
System.out.println("Welcome back "+ cust.getCustomerName()+"!");
}
int iArrayID = InventoryHandler.checkStock();
if (iArrayID != -999) {
doPurchase(iArrayID, cust, ord);
}
}
private static void DeleteOrder() {
throw new UnsupportedOperationException("Not yet implemented");
}
private static void doPurchase(int iArrayID, Customer cust, Order ord) {
Inventory inv = Project2.al.get(iArrayID);
int iStock = inv.getiInStore();
String sDesc = inv.getsItemName();
System.out.println("The selling price is currently: $"+inv.getdSellPrice()+"\n"+
"How many would you like to purchase?");
Scanner console = new Scanner(System.in);
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = -999;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, try again?");
System.out.print("([Y]es/[N]o)"+MenuHandler.PROMPT);
input = console.next();
char cIn = input.toLowerCase().charAt(0);
if (cIn == 'y') {
doPurchase(iArrayID, cust, ord);
}
else
{
System.out.println("Your order has been canceled.");
return;
}
}
if (iOut <= 0)
{
System.out.println("We're sorry. That was an invalid ammount, try again?");
System.out.print("([Y]es/[N]o)"+MenuHandler.PROMPT);
input = console.next();
char cIn = input.toLowerCase().charAt(0);
if (cIn == 'y') {
doPurchase(iArrayID, cust, ord);
}
else
{
System.out.println("Your order has been canceled.");
return;
}
}
if (iOut > inv.getiInStore())
{
System.out.println("We're sorry. We don't have that many in stock, try again?");
System.out.print("([Y]es/[N]o)"+MenuHandler.PROMPT);
input = console.next();
char cIn = input.toLowerCase().charAt(0);
if (cIn == 'y') {
doPurchase(iArrayID, cust, ord);
}
} else {
System.out.printf("Input accepted. Your order for "+
iOut+" "+sDesc+" will be placed. Your Subtotal today is: %.2f"
+"\nWill that be Cash or Credit?\n", (inv.getdSellPrice()*iOut));
System.out.print("([C]ash/C[r]edit)"+MenuHandler.PROMPT);
input = console.next();
char cIn = input.toLowerCase().charAt(0);
switch (cIn)
{
case 'c':
cust.setCustomerPaymentType(Customer.CASH);
break;
case 'r':
cust.setCustomerPaymentType(Customer.CREDIT);
break;
}
Customer newcust = cashOrCredit(cust);
System.out.printf("Input accepted. Your order for "+
iOut+" "+sDesc+" will be placed. Your GrandTotal today is: %.2f"
+"\nPlace order?\n", newcust.doTotal(inv.getdSellPrice()*iOut));
System.out.print("([Y]es/[N]o)"+MenuHandler.PROMPT);
input = console.next();
cIn = input.toLowerCase().charAt(0);
if (cIn == 'y') {
System.out.printf("Thank you! Your order has been recieved.\n"
+ "You will be billed $%.2f\n",newcust.doTotal(inv.getdSellPrice()*iOut));
Project2.or.add(new Order(newcust,inv,iOut,newcust.doTotal(inv.getdSellPrice()*iOut)));
InventoryHandler.removeStock(iArrayID,iOut);
return;
}
}
System.out.println("Your order has been canceled.");
}
private static Customer cashOrCredit(Customer cu) {
switch(cu.getCustomerPaymentType())
{
case Customer.CASH:
return new CashCustomer(cu);
case Customer.CREDIT:
return new CreditCustomer(cu);
default:
return null;
}
}
}
@@ -0,0 +1,84 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: Project2 *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 2.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
import java.util.*;
/**
*
* @author Amrit Panesar
*/
public class Project2 {
/**
* @param args the command line arguments
*/
protected static ArrayList<MenuDialog> md = MenuHandler.menu_dialog_init();
protected static ArrayList<Inventory> al = MenuHandler.inventory_init();
protected static ArrayList<Customer> cu = MenuHandler.customer_init();
protected static ArrayList<Order> or = MenuHandler.order_init();
public static void main(String[] args) { // main()
while(true)
{
int iSelect = menu();
doThing(iSelect);
}
}
public static int menu()
{
Scanner console = new Scanner(System.in);
System.out.println(md.get(MenuHandler.MAIN_MENU_ID));
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = 0;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
if (iOut < 0 && iOut > 5)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
return iOut;
}
private static void doThing(int iSel) {
switch (iSel)
{
case 1:
CustomerHandler.invoke();
break;
case 2:
OrderHandler.invoke();
break;
case 3:
InventoryHandler.invoke();
break;
case 4:
ReportHandler.invoke();
break;
case 5:
exit();
break;
}
}
private static void exit() {
System.exit(0);
}
}
@@ -0,0 +1,103 @@
/******************************************************************************
* Project: Project 2 *
* Class Name: ReportHandler *
* Author: Amrit Panesar -ASP ,o/ *
* Last Edited: 10/17/2012 *
* Hours: 2.00 Hours *
* Purpose: To demonstrate the retention and knowledge of the previous *
* mods concepts. *
*****************************************************************************/
package project2;
import java.util.Scanner;
/**
*
* @author 77260
*/
public class ReportHandler {
public static void invoke()
{
while(true)
{
int iSelect = menu();
int iThing = doThing(iSelect);
if (iThing == -999) {
return;
}
}
}
public static int menu()
{
Scanner console = new Scanner(System.in);
System.out.println(Project2.md.get(MenuHandler.REPORT_MENU_ID));
System.out.print(MenuHandler.PROMPT);
String input = console.next();
int iOut = 0;
try
{
iOut = Integer.parseInt(input);
}
catch (Exception e)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
if (iOut < 0 && iOut > 4)
{
System.out.println("We're sorry. That was an invalid input, please try again.");
iOut = menu();
}
return iOut;
}
private static int doThing(int iSel) {
switch (iSel)
{
case 1:
RunCustomerReport();
break;
case 2:
RunOrderReport();
break;
case 3:
RunInventoryReport();
break;
case 4:
return -999;
}
return 0;
}
protected static void RunInventoryReport() {
int iItemCount = 0;
double dWorth = 0.00;
System.out.println("Item ID\tItem Name\tStock\tMFG Price\tSale Price");
for (int i=0;i<Project2.al.size();i++)
{
Inventory item = Project2.al.get(i);
System.out.println(item.getiItemID()+"\t"+item.getsItemName()+"\t"+
item.getiInStore()+"\t$"+item.getdManuPrice()+"\t\t$"+item.getdSellPrice());
iItemCount += item.getiInStore();
dWorth += (item.getiInStore()*item.getdManuPrice());
}
System.out.println("There are currently "+iItemCount+" items in store.");
System.out.println("The total worh of the store is: $"+dWorth);
}
protected static void RunOrderReport() {
throw new UnsupportedOperationException("Not yet implemented");
}
protected static void RunCustomerReport() {
System.out.println("ID\tName\t\tAddress1\tAddress2\tCity\tState\tZip");
for (int i=0;i<Project2.cu.size();i++)
{
Customer cust = Project2.cu.get(i);
System.out.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
cust.getCustomerID(), cust.getCustomerName(),
cust.getCustomerAddress1(), cust.getCustomerAddress2(),
cust.getCustomerCity(), cust.getCustomerState(),
cust.getCustomerZip());
}
}
}