source: src/main/java/negotiator/onetomany/Portfolio.java@ 224

Last change on this file since 224 was 224, checked in by Faria Nassiri Mofakham, 6 years ago

PortfolioDrawing, DemandPlanDrawing, GUI, and Main updated. DemandPlanDrwaing lists products in multiple rows. Drwaing1, Drawing2, Circle are deleted. Bob name changed to PutImage.

File size: 1.1 KB
Line 
1package negotiator.onetomany;
2
3import java.util.List;
4import java.util.Set;
5//import java.awt.Color;
6import java.util.ArrayList;
7
8/**
9 * A portfolio is a list of products that is relevant to an agent.
10 * Every product in the portfolio is unique.
11 */
12public class Portfolio
13{
14 private List<Product> portfolio;
15
16 public Portfolio()
17 {
18 this.portfolio = new ArrayList<Product>();
19 }
20
21 public List<Product> getPortfolio()
22 {
23 return portfolio;
24 }
25
26 public void addProduct(Product p)
27 {
28 portfolio.add(p);
29 }
30
31 @Override
32 public String toString()
33 {
34 return portfolio.toString();
35 }
36
37 public int size()
38 {
39 if (portfolio != null)
40 {
41 return getPortfolio().size();
42 }
43 else return 0;
44 }
45
46 public Product getProduct(int i)
47 {
48 return getPortfolio().get(i);
49 }
50
51 public Product iterator() // product or List<product> or Portfolio
52 {
53 Product s=null;
54 if (this!=null)
55 for (int i=0; i<this.size();i++)
56 s = portfolio.get(i);
57 return s; // this just returns the last one, a product, not a list!
58 }
59}
Note: See TracBrowser for help on using the repository browser.