Java Reference
In-Depth Information
public void stop() throws YachtException {
if(currentVelocity > 2) {
throw new YachtException("Too fast to stop. Decelerate first!");
}
yachtRunning = false;
}
public int accelerate(int amount) throws RemoteException{
if(yachtRunning) {
currentVelocity = (currentVelocity + amount <
yacht.getMaxVelocity()) ?
(currentVelocity + amount) :
yacht.getMaxVelocity();
}
return currentVelocity;
}
public int decelerate(int amount) {
if(yachtRunning) {
currentVelocity = (currentVelocity - amount > 0) ?
(currentVelocity - amount) : 0;
}
return currentVelocity;
}
public void addPassenger(Member member) throws RemoteException,
YachtException {
if(passengers.size() == yacht.getCapacity()) {
throw new YachtException("Yacht is full (" + Yacht.getCapacity() +
")");
}
passengers.addElement(member);
}
public boolean removePassenger(Member member) {
return passengers.remove(member);
}
public YachtStatus getCurrentStatus() throws RemoteException {
YachtStatus status = new YachtStatus();
status.setCurrentVelocity(currentVelocity);
status.setYachtRunning(yachtRunning);
status.setMaxVelocity(yacht.getMaxVelocity());
Search WWH ::




Custom Search