directory structure change, organize by class number as opposed to mod number

Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
Amrit Panesar committed 2015-04-12 23:49:33 -07:00
1 parent 2a3d6fc042
commit 8683384387
480 files changed
+7

No files matched your search

Binary file not shown.
+74
View File
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Project2" default="default" basedir=".">
<description>Builds, tests, and runs the project Project2.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="Project2-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
+3
View File
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,8 @@
build.xml.data.CRC32=30a5c9f2
build.xml.script.CRC32=e6a77667
build.xml.stylesheet.CRC32=28e38971@1.53.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=30a5c9f2
nbproject/build-impl.xml.script.CRC32=d29c886b
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
@@ -0,0 +1,2 @@
compile.on.save=true
user.properties.file=C:\\Documents and Settings\\77260\\Application Data\\NetBeans\\7.2\\build.properties
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
</project-private>
@@ -0,0 +1,71 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Project2.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=project2.Project2
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>Project2</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>
@@ -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);
}
}
+116
View File
@@ -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 = ":";
}
+67
View File
@@ -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());
}
}
}