package com.bestchoice.bo;

import java.util.*;

import com.bestchoice.model.PriceReview;
import com.bestchoice.model.Products;
import com.bestchoice.util.Loadlist;

public class MakeBestChoiceLogic {

	public void getBestChoiceList(List<String> desiredProducts, double budgetAmt) {
		Loadlist load = new Loadlist();
		List<Products> list = load.fetchProducts(desiredProducts);
		System.out.println(list);
		// MckpExactlyOne mckp = new MckpExactlyOne();
		// int n = list.size();

	}

	public void separateProducts(List<Products> list) {
		LinkedHashMap<String, ArrayList<PriceReview>> hm = new LinkedHashMap<>();
		for (Products prods : list) {
			String prodName = prods.getProductName();
			if (!hm.containsKey(prodName)) {
				ArrayList<PriceReview> ar = new ArrayList<>();
				ar.add(new PriceReview(prods.getPrice(), prods.getReviewValue()));
				hm.put(prodName, ar);
			} else {
				ArrayList<PriceReview> ar = new ArrayList<>(hm.get(prodName));
				ar.add(new PriceReview(prods.getPrice(), prods.getReviewValue()));
				hm.put(prodName, ar);
			}
		}
		int n = hm.size(), i = 0, m;
		double wt[][] = new double[n][];
		double val[][] = new double[n][];
		for (String s : hm.keySet()) {
			ArrayList<PriceReview> arr = new ArrayList<>(hm.get(s));
			m = arr.size();
			for (int j = 0; j < m; j++) {
				wt[i][j] = arr.get(j).getReview();
				val[i][j] = arr.get(j).getAmount();
			}
			i++;
		}

	}

}

@@ -384,16 +384,43 @@
 ucts);%0D%0A
+%09%09separateProducts(list);%0D%0A
 %09%09System
@@ -436,24 +436,24 @@
 tln(list);%0D%0A
-
 %09%09// MckpExa
@@ -579,16 +579,41 @@
 ist) %7B%0D%0A
+%09%09int sz = list.size();%0D%0A
 %09%09Linked
@@ -1139,16 +1139,18 @@
 %7D%0D%0A%09%09%7D%0D%0A
+%0D%0A
 %09%09int n 
@@ -1201,24 +1201,30 @@
 w double%5Bn%5D%5B
+sz - n
 %5D;%0D%0A%09%09double
@@ -1248,16 +1248,22 @@
 uble%5Bn%5D%5B
+sz - n
 %5D;%0D%0A%09%09fo
@@ -1508,16 +1508,43 @@
 ;%0D%0A%09%09%7D%0D%0A
+%09%09System.out.println(%22Hi%22);
 %0D%0A%09%7D%0D%0A%0D%0A

Work in progress.