source: src/main/java/onetomany/bargainingchipsgame/players/utilityfunction/UF_AllOrNothing.java@ 257

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.2 KB
Line 
1/**
2 * UtilityFunctionAllOrNothing class
3 */
4package onetomany.bargainingchipsgame.players.utilityfunction;
5
6import onetomany.bargainingchipsgame.Bundle;
7import onetomany.bargainingchipsgame.Stack;
8
9/**
10 * If all requested quantities at the total requested price (or less) would be satisfied,
11 * then the bundle is evaluated as 1.0, otherwise as 0.0;
12 *
13 * @author Faria Nassiri-Mofakham
14 *
15 */
16public class UF_AllOrNothing implements Utility_Function {
17
18 Bundle wishlist;
19
20
21 public UF_AllOrNothing(Bundle w)
22 {
23 this.wishlist=w;
24 }
25
26 /**
27 * @return the wishlist
28 */
29 public Bundle getWishlist() {
30 return wishlist;
31 }
32
33 /**
34 * @param wishlist the wishlist to set
35 */
36 public void setWishlist(Bundle w) {
37 this.wishlist = w;
38 }
39
40 @Override
41 public Double getUtility(Bundle b)
42 {
43 // TODO Auto-generated method stub
44 if (b!=null)
45 {
46 for (Stack s : b)
47 for (Stack t: wishlist)
48 if (s.getColor()==t.getColor())
49 if (s.getQuantity() !=t.getQuantity())
50 return 0.0;
51 if (b.getPrice() <=wishlist.getPrice())
52 return 1.0;
53 else
54 return 0.0;
55 }
56 return 0.0;
57 }
58
59 @Override
60 public String toString()
61 {
62 return this.getClass().getSimpleName();
63 }
64
65}
66
Note: See TracBrowser for help on using the repository browser.