Java Reference
In-Depth Information
if (emp ## null ) throw
new Exception("Employee non existent");
Transaction t # new Transaction(transactions.size() ! 1,
emp,cust);
transactions.add(t);
return t.code;
}
public void buy( long item, long quantity,
long transaction)
throws Exception {
Transaction t;
try {
t # (Transaction)transactions.
elementAt(( int )transaction-1);
} catch (Exception e){
throw new Exception("Transaction non existent");
}
Item it # getItem(item);
if (it ## null ){ throw
new Exception("Non existent item");}
t.acquisitions.add( new Acquisition(it,quantity));
}
public void endTransaction( long code)
throws Exception {
Transaction t # (Transaction)transactions.
elementAt(( int )code-1);
if (t ## null ) throw
new Exception("Transaction non existent");
if (!t.open) throw
new Exception("Transaction already closed");
t.open # false ;
}
}
The main program instantiates all the components of the system in the
correct order. In addition it creates the bar code reader simulator.
import CounterUI.*;
import Market.BasicServer;
import Counter.LocalProxy;
import MarketDB.VolatileDB;
public class TestLocal {
public static void main(String [] args) {
BasicServer server # new BasicServer(
new VolatileDB());
LocalProxy proxy # new LocalProxy(server);
Search WWH ::




Custom Search