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

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

'Line' problem (and in GUI) fixed. (There also have been several updates in other files before this commit!!)

File size: 1.0 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 */
11public class Portfolio
12{
13 private List<Product> portfolio;
14
15 public Portfolio()
16 {
17 this.portfolio = new ArrayList<Product>();
18 }
19
20 public List<Product> getPortfolio()
21 {
22 return portfolio;
23 }
24
25 public void addProduct(Product p)
26 {
27 portfolio.add(p);
28 }
29
30 @Override
31 public String toString()
32 {
33 return portfolio.toString();
34 }
35
36 public int size()
37 {
38 if (portfolio != null)
39 {
40 return getPortfolio().size();
41 }
42 else return 0;
43 }
44
45 public Product getProduct(int i)
46 {
47 return getPortfolio().get(i);
48 }
49
50 public Product iterator() // product or List<product> or Portfolio
51 {
52 Product s=null;
53 if (this!=null)
54 for (int i=0; i<this.size();i++)
55 s = portfolio.get(i);
56 return s; // this just returns the last one, a product, not a list!
57 }
58}
Note: See TracBrowser for help on using the repository browser.