zadanie 3?
This commit is contained in:
@@ -11,6 +11,9 @@ import jade.domain.FIPAAgentManagement.ServiceDescription;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
public class BookSellerAgent extends Agent
|
public class BookSellerAgent extends Agent
|
||||||
{
|
{
|
||||||
private Hashtable catalogue;
|
private Hashtable catalogue;
|
||||||
@@ -86,6 +89,14 @@ public class BookSellerAgent extends Agent
|
|||||||
String title = msg.getContent();
|
String title = msg.getContent();
|
||||||
ACLMessage reply = msg.createReply();
|
ACLMessage reply = msg.createReply();
|
||||||
Integer price = (Integer) catalogue.get(title);
|
Integer price = (Integer) catalogue.get(title);
|
||||||
|
|
||||||
|
// Make home sometimes do not respond
|
||||||
|
if(new Random().nextBoolean() == true)
|
||||||
|
{
|
||||||
|
System.out.println(getAID().getLocalName() + " Skipped response.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (price != null)
|
if (price != null)
|
||||||
{
|
{
|
||||||
//title found in the catalogue, respond with its price as a proposal
|
//title found in the catalogue, respond with its price as a proposal
|
||||||
|
|||||||
Reference in New Issue
Block a user