Lab 6 - Combination Chooser

JAVA 8 API

Overview

The 'ultimate' purpose of this lab is to create a program that allows for a user (the SELLER) to submit different products he/she would like to sell. Your program should allow for the products to be submitted by providing a NAME and PRICE for each item. Once all the products are loaded into the system, your system should generate an ArrayList that tracks every possible combination of products and their associated total price.

The program should then ask a BUYER what products he/she would like to purchase.
For this interaction, you will want to continue looping until the purchaser chooses CHECKOUT. Otherwise, assume the purchaser will select any specific product ONCE and that only ONE of each item can be chosen. Your program should then output the total cost solely by doing a lookup in the ArrayList of that exact combination and its associated price.

You are NOT to simply loop through the ArrayList of items available for sale and tally the price for those that are selected.

NOTE

I have broken this assignment into a few parts to guide you through the process. Please complete it in the order outlined below.

Due Date: TBD
You will have nearly all of the class time between now and then to work on this.

Lab Setup

Part 1: Figure out all the Combinations

Create the class CombinationBuilder and an application program called Lab6Part1
In the CombinationBuilder class, program the constructor and add helper functions as necessary to make this application program work:
public static void main(String[] args)
{        
	ArrayList<String> options = new ArrayList<String>();
	
	options.add("a");        
	options.add("b");
	options.add("c");
	options.add("d");
	//options.add("e");        
	System.out.println("The options: " + options);
	CombinationBuilder cbs = new CombinationBuilder(options);
	System.out.print("All the different combinations");
	System.out.println(" of 1 or more of these appear below.");
	cbs.displayCombinations();       
}//=====================================
The output:
The options: [a, b, c, d]
All the different combinations of 1 or more of these appear below.
1: [d]
2: [c]
3: [c, d]
4: [b]
5: [b, d]
6: [b, c]
7: [b, c, d]
8: [a]
9: [a, d]
10: [a, c]
11: [a, c, d]
12: [a, b]
13: [a, b, d]
14: [a, b, c]
15: [a, b, c, d]
Your code does NOT need to produce the combinations in the same order as mine. Your code DOES need to work for ANY SIZE list of options.

Part 2: Products instead of Strings

Create the class Product and an application program called Lab6Part2
For this next part, rather using an ArrayList of String objects (ie. 'a','b','c', etc.), you will use your Product class to generate the options.
Do NOT take user input yet. For now, simply create your own Product objects. Use these 6 lines for adding Products (feel free to comment some out while building the program.)
options.add(new Product("Apples",4));
options.add(new Product("Bananas",3));
options.add(new Product("Carrots",2));
options.add(new Product("Dates",5));
options.add(new Product("Eggplant",8));
options.add(new Product("Figs",1));	
		
Your program should then output all the combinations and also show the total price for each combination.

Part 3: Build the Store

Create an application program called Lab6Part3 that includes a call to a method that asks the user to build his/her store of products.
The user is to enter a one word product name (ie. 'apples') put a space, and then enter a price (can be type double)
Allow the user to continuously add products until he/she types the word 'COMPLETE'
Save the product listing in a text file that can be loaded later.
Now load those products in the same fashion as Part 2 works (instead of using the vegetable examples).
Next, have a customer request items until the purchaser writes CHECKOUT.
Display to the screen the total price of the items by finding that unique COMBINATION (and not simply using a loop to tally the pricing.)

Grading

It is worth 70 points. It will be graded as follows: If you are unable to figure out Part 1 (which you need to do the rest of it), Mr. Merlis is offering help but it will cost you points. Exact amount based upon amount of help needed.