Link to home
Start Free TrialLog in
Avatar of BouncerLMCO
BouncerLMCO

asked on

How do I create a SALE object and save to the SALE object for the following method?

How do  I create a SALE object and save to the SALE object for the following method?
private void makeSale() {
		// menu item #6
		Scanner scan = new Scanner(System.in);
		displayCustomer();
		System.out.println("Are you a retail or wholsale customer?:  ");
		int cust = scan.nextInt();
 
		displayInventory();
		System.out.println("What item do you want to buy by number? ");
		int num = scan.nextInt();
 
		System.out.println("There are " + inventory.get(num).getNuminStock()
				+ " of these items for sale");
 
		System.out.println("How many of these items do you want to buy? ");
		int numSale = scan.nextInt();
 
		if (numSale > inventory.get(num).getNuminStock()) {
			System.out.println("There are only "
					+ inventory.get(num).getNuminStock()
					+ " of these items for sale");
			numSale = inventory.get(num).getNuminStock();
 
			if (customer.get(cust).getType().equalsIgnoreCase("retail")) {
				if (inventory.get(num).calculateInventoryValue() > 200) {
					System.out
							.println("\nBecause you ordered more then $200 worth of plants "
									+ "\nand are a retail customer "
									+ "\n You get a discount of:  "
									+ (inventory.get(num)
											.calculateInventoryValue() * .05)
									+ " dollars");
				}
			} else {
				double wholeValue = inventory.get(num)
						.calculateInventoryValue();
				System.out.println("\nBecause you are a wholesale customer "
						+ "\n You get a discount of:  " + wholeValue
						* customer.get(cust).getDiscountPercent() + " dollars");
 
			}
 
		}
 
		Inventory a = inventory.get(num);
		int temp = a.getNuminStock() - numSale;
		a.setNuminStock(temp);
	}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of __geof__
__geof__
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial