Java Reference
In-Depth Information
boolean match(Map other){
Iterator it # coordinates.keySet().iterator();
while (it.hasNext()){
Object key # it.next();
Object otherValue # other.get(key);
Object value # coordinates.get(key);
if (otherValue! # null && !otherValue.equals(value))
return false ;
}
return true ;
}
// compare a single coordinates
boolean match(Object key, Object value){
Object coord # coordinates.get(key);
if (coord ## null ) return false ;
return value.equals(coord);
}
// book a resource, ensuring that the sum of
// available and booked is a constant
synchronized void book() {
available--;
booked !! ;
}
public String toString(){
StringBuffer buffer # new StringBuffer();
Iterator it # coordinates.keySet().iterator();
while (it.hasNext()){
Object key # it.next();
Object value # coordinates.get(key);
buffer.append(key).append(" # ").append(value).
append(" ");
}
return buffer.toString();
}
}
Class ResourceAllocation manages the resources. Method preference() com-
putes the preferences on the basis of the current resource availability. The
weights of the attributes are proportional to the variance of the availability
of the values. The ranking of the values of an attribute is proportional to the
availability of the values.
package booking;
import java.util.*;
import Negotiation.*;
public class ResourceAllocation {
// the collection of all the resources
Search WWH ::




Custom Search