source: src/main/java/bargainingchips/etc/Portfolio.java@ 343

Last change on this file since 343 was 316, checked in by Tim Baarslag, 5 years ago

new packages complete

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