Last change
on this file since 263 was 254, checked in by Faria Nassiri Mofakham, 5 years ago |
Commit #2:
Fixed errors
|
File size:
763 bytes
|
Line | |
---|
1 | /**
|
---|
2 | * UtilityFunctionIWant3Red class
|
---|
3 | */
|
---|
4 | package onetomany.bargainingchipsgame.players.utilityfunction;
|
---|
5 |
|
---|
6 | import onetomany.bargainingchipsgame.Bundle;
|
---|
7 | import onetomany.bargainingchipsgame.Stack;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * This utility function simply implements a hardheaded behavior
|
---|
11 | * which evaluates as 1 any bundle which includes a stack with 3 Red chips,
|
---|
12 | * and 0, otherwise.
|
---|
13 | *
|
---|
14 | * @author Faria Nassiri-Mofakham
|
---|
15 | *
|
---|
16 | */
|
---|
17 | public class UF_IWant3Red implements Utility_Function
|
---|
18 | {
|
---|
19 |
|
---|
20 | @Override
|
---|
21 | public Double getUtility(Bundle b)
|
---|
22 | {
|
---|
23 | if (b!=null)
|
---|
24 | for (Stack s : b)
|
---|
25 | if (s.getColor()=="Red" && s.getQuantity()==3)
|
---|
26 | return 1.0;
|
---|
27 | return 0.0;
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public String toString()
|
---|
32 | {
|
---|
33 | return this.getClass().getSimpleName();
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.