Java Reference
In-Depth Information
public
String getName(
long
item)
throws
Exception {
assertConnected();
return
server.getName(item);
}
public double
getPrice(
long
item)
throws
Exception {
assertConnected();
return
server.getPrice(item);
}
public
String getCustomer(
long
code)
throws
Exception{
assertConnected();
String customerName
#
server.getCustomer(code);
if
(customerName
##
null
)
return null
;
customer
#
code;
return
customerName;
}
public
void buy(
long
item,
long
quantity)
throws
Exception{
assertConnected();
// if no transaction has been started, start a new one
if
(transaction
##
0){
transaction
#
server.
startTransaction(customer,employee);
}
server.buy(item,quantity,transaction);
}
public void
endTransaction()
throws
Exception {
assertConnected();
server.endTransaction(transaction);
transaction
#
0;
}
}
The interface
Market
defines all the operations provided by the market
server. They are closely related to those available in the
MarketProxy
interface.
package
Market;
public interface
Market {
// authenticate an employee,
// return null in case of failure
public
String authenticate(
long
employee,
String password);
//
return
the name of a customer,
// null if it doesn't exist
public
String getCustomer(
long
customer);
//
return
the name of an item,
// null if it doesn't exist
public
String getName(
long
item);