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:
1 parent
2a3d6fc042
commit
8683384387
480 files changed
+7
No files matched your search
@@ -0,0 +1,80 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 1 *
|
||||
* 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 project1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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,256 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 1 *
|
||||
* Class Name: Project1 *
|
||||
* 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 project1;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Amrit Panesar
|
||||
*/
|
||||
public class Project1 {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
/* 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
|
||||
|
||||
*/
|
||||
public static ArrayList<Inventory> al = init();
|
||||
public static void main(String[] args) {
|
||||
// initalize - lets prime the pump.
|
||||
while(true)
|
||||
{
|
||||
int iSelect = menu();
|
||||
doThing(iSelect);
|
||||
}
|
||||
}
|
||||
public static ArrayList<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;
|
||||
}
|
||||
public static int menu()
|
||||
{
|
||||
String menu =
|
||||
"-------------------------------Inventory Menu-------------------------------\n"+
|
||||
"1) Check Item Inventory \n"+
|
||||
"2) Sell Item \n"+
|
||||
"3) Item Stock Report \n"+
|
||||
"4) Exit \n"+
|
||||
" Please enter your selection. Numbers 1-4 are accepted.";
|
||||
Scanner console = new Scanner(System.in);
|
||||
System.out.println(menu);
|
||||
System.out.print(":");
|
||||
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;
|
||||
}
|
||||
public static void doThing(int iSel) {
|
||||
switch (iSel)
|
||||
{
|
||||
case 1:
|
||||
checkStock();
|
||||
break;
|
||||
case 2:
|
||||
sellItem();
|
||||
break;
|
||||
case 3:
|
||||
generateReport();
|
||||
break;
|
||||
case 4:
|
||||
exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
public 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(":");
|
||||
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):");
|
||||
input = console.next();
|
||||
char cIn = input.toLowerCase().charAt(0);
|
||||
if (cIn == 'y') {
|
||||
iOut = -999;
|
||||
}
|
||||
else {
|
||||
iOut = getItemID();
|
||||
}
|
||||
}
|
||||
return iOut;
|
||||
|
||||
}
|
||||
public static int getStock(int iID) {
|
||||
for (int i=0;i<al.size();i++)
|
||||
{
|
||||
Inventory item = al.get(i);
|
||||
if(item.getiItemID() == iID) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -999;
|
||||
}
|
||||
public 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 = 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;
|
||||
}
|
||||
|
||||
private static void sellItem() {
|
||||
int iArrayID = checkStock();
|
||||
if (iArrayID != -999) {
|
||||
doPurchase(iArrayID);
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateReport() {
|
||||
int iItemCount = 0;
|
||||
double dWorth = 0.00;
|
||||
System.out.println("Item ID\tItem Name\tStock\tMFG Price\tSale Price");
|
||||
for (int i=0;i<al.size();i++)
|
||||
{
|
||||
Inventory item = 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);
|
||||
}
|
||||
|
||||
private static void exit() {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static void doPurchase(int iArrayID) {
|
||||
Inventory inv = 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(":");
|
||||
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):");
|
||||
input = console.next();
|
||||
char cIn = input.toLowerCase().charAt(0);
|
||||
if (cIn == 'y') {
|
||||
doPurchase(iArrayID);
|
||||
}
|
||||
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):");
|
||||
input = console.next();
|
||||
char cIn = input.toLowerCase().charAt(0);
|
||||
if (cIn == 'y') {
|
||||
doPurchase(iArrayID);
|
||||
}
|
||||
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):");
|
||||
input = console.next();
|
||||
char cIn = input.toLowerCase().charAt(0);
|
||||
if (cIn == 'y') {
|
||||
doPurchase(iArrayID);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Input accepted. Your order for "+
|
||||
iOut+" "+sDesc+" will be placed. Confirm your order?");
|
||||
System.out.print("([Y]es/[N]o):");
|
||||
input = console.next();
|
||||
char cIn = input.toLowerCase().charAt(0);
|
||||
if (cIn == 'y') {
|
||||
System.out.println("Thank you! Your order has been recieved.\n"
|
||||
+ "You will be billed $"+(inv.getdSellPrice()*iOut));
|
||||
removeStock(iArrayID,iOut);
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("Your order has been canceled.");
|
||||
}
|
||||
|
||||
private static void removeStock(int iArrayID, int iOut) {
|
||||
Inventory inv = al.get(iArrayID);
|
||||
int iStock = inv.getiInStore();
|
||||
iStock -= iOut;
|
||||
inv.setiInStore(iStock);
|
||||
al.set(iArrayID, inv);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user