zadanie 3?

This commit is contained in:
2023-01-22 00:00:45 +01:00
parent 3759567f18
commit 56787e2742

View File

@@ -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