Last change
on this file since 257 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
|
Rev | Line | |
---|
[253] | 1 | package onetomany.etc;
|
---|
[207] | 2 |
|
---|
| 3 | import java.util.List;
|
---|
[219] | 4 | import java.util.Set;
|
---|
[211] | 5 | //import java.awt.Color;
|
---|
[207] | 6 | import java.util.ArrayList;
|
---|
| 7 |
|
---|
| 8 | /**
|
---|
[224] | 9 | * A portfolio is a list of products that is relevant to an agent.
|
---|
| 10 | * Every product in the portfolio is unique.
|
---|
[225] | 11 | *
|
---|
| 12 | *
|
---|
| 13 | * *
|
---|
| 14 | * @author Faria Nassiri-Mofakham
|
---|
[207] | 15 | */
|
---|
| 16 | public class Portfolio
|
---|
| 17 | {
|
---|
| 18 | private List<Product> portfolio;
|
---|
| 19 |
|
---|
| 20 | public Portfolio()
|
---|
| 21 | {
|
---|
| 22 | this.portfolio = new ArrayList<Product>();
|
---|
| 23 | }
|
---|
[219] | 24 |
|
---|
[207] | 25 | public List<Product> getPortfolio()
|
---|
| 26 | {
|
---|
| 27 | return portfolio;
|
---|
| 28 | }
|
---|
[219] | 29 |
|
---|
[207] | 30 | public void addProduct(Product p)
|
---|
| 31 | {
|
---|
| 32 | portfolio.add(p);
|
---|
| 33 | }
|
---|
[219] | 34 |
|
---|
[207] | 35 | @Override
|
---|
| 36 | public String toString()
|
---|
| 37 | {
|
---|
| 38 | return portfolio.toString();
|
---|
| 39 | }
|
---|
[211] | 40 |
|
---|
| 41 | public int size()
|
---|
| 42 | {
|
---|
| 43 | if (portfolio != null)
|
---|
| 44 | {
|
---|
| 45 | return getPortfolio().size();
|
---|
| 46 | }
|
---|
[212] | 47 | else return 0;
|
---|
[211] | 48 | }
|
---|
[219] | 49 |
|
---|
[211] | 50 | public Product getProduct(int i)
|
---|
| 51 | {
|
---|
| 52 | return getPortfolio().get(i);
|
---|
| 53 | }
|
---|
[219] | 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 | }
|
---|
[207] | 63 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.