Last change
on this file since 256 was 253, checked in by Faria Nassiri Mofakham, 5 years ago |
Commit #1 of:
+ negotiator.onetomany package refactored into onetomany package.
+ info created for all contained the packages.
+ current work defined under onetomany.bargainingchipsgame.
+ in this package, onetomany.bargainingchipsgame.players package includes packages for utility function, coordinator, negotiatior, and buyer and seller.
+ negotiator.onetomany package now contains nothing, can be deleted.
+ Interaction thread
|
File size:
1.1 KB
|
Line | |
---|
1 | package onetomany.etc;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 | import java.util.Set;
|
---|
5 | //import java.awt.Color;
|
---|
6 | import 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 | */
|
---|
16 | public 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.