Last change
on this file was 1, checked in by Wouter Pasman, 7 years ago |
Initial import : Genius 9.0.0
|
File size:
1.3 KB
|
Line | |
---|
1 | package genius.core.actions;
|
---|
2 |
|
---|
3 | import genius.core.AgentID;
|
---|
4 | import genius.core.Bid;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * @author Tim Baarslag and Dmytro Tykhonov
|
---|
8 | *
|
---|
9 | */
|
---|
10 | public abstract class DefaultAction implements Action {
|
---|
11 | protected AgentID agentID;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Constructor which sets the agentID of an agent.
|
---|
15 | *
|
---|
16 | * @param agentID
|
---|
17 | * of the agent which created the action.
|
---|
18 | */
|
---|
19 | public DefaultAction(AgentID agentID) {
|
---|
20 | this.agentID = agentID;
|
---|
21 | if (agentID == null) {
|
---|
22 | throw new IllegalArgumentException("AgentID =null");
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public AgentID getAgent() {
|
---|
28 | return agentID;
|
---|
29 | }
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Enforces that actions implements a string-representation.
|
---|
33 | */
|
---|
34 | public abstract String toString();
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Method which returns the bid of the current action if it is of the type
|
---|
38 | * Offer or else Null.
|
---|
39 | *
|
---|
40 | * @param currentAction
|
---|
41 | * of which we want the offer.
|
---|
42 | * @return bid specifies by this action or null if there is none.
|
---|
43 | */
|
---|
44 | public static Bid getBidFromAction(Action currentAction) {
|
---|
45 |
|
---|
46 | Bid currentBid = null;
|
---|
47 | if (currentAction instanceof EndNegotiationWithAnOffer) // RA
|
---|
48 | currentBid = ((EndNegotiationWithAnOffer) currentAction).getBid();
|
---|
49 | else if (currentAction instanceof Offer)
|
---|
50 | currentBid = ((Offer) currentAction).getBid();
|
---|
51 |
|
---|
52 | return currentBid;
|
---|
53 | }
|
---|
54 |
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.