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

Posted on 2009-04-27
Medium Priority
Last Modified: 2013-11-23
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);
		System.out.println("Are you a retail or wholsale customer?:  ");
		int cust = scan.nextInt();
		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) {
							.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)
				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;

Open in new window

Question by:BouncerLMCO
1 Comment

Accepted Solution

__geof__ earned 1000 total points
ID: 24245698
What you need is to create a class called Sale with variables you need to "save" (cust, num, numscale). You need to create an instance of that Sale and put your data in the variable. The instance needs to be the same for this method and the next one.
How to do this depends on where the methods are located.

I also noticed that it seems you are doing this already with the inventory in your code: inventory.get(num).getNuminStock()
It is created somewhere and you get the data in this method now.

Hope this helps.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question