package conditionalTest; import brmi.BatchUnicastRemoteObject; import java.io.Serializable; import java.rmi.RemoteException; import java.util.Random; import java.util.Calendar; /** * @author Yang */ public class RemoteConditionalTestImpl extends BatchUnicastRemoteObject implements RemoteConditionalTest, Serializable { private static final long serialVersionUID = -2520327534886769420L; Random random; int number; int loopCounter; protected RemoteConditionalTestImpl() throws RemoteException { super(); this.random = new Random(Calendar.SECOND); this.number = Math.abs(random.nextInt()); this.loopCounter = 0; } public boolean bar() throws RemoteException { System.out.println("I am bar"); return true; } public boolean foo() throws RemoteException { System.out.println("I am foo"); return true; } public boolean testCondition() throws RemoteException { System.out.println("Now the number is " + this.number); if (number % 2 == 0) { return true; } else { return false; } } public int getNumber() throws RemoteException { return this.number; } public boolean testCondition(boolean condition) throws RemoteException { return condition; } public boolean testCondition(int loopTimes) throws RemoteException { ++this.loopCounter; if (this.loopCounter == loopTimes) { return false; } else { return true; } } public int getCounter() throws RemoteException { return this.loopCounter; } public void setCounter(int num) throws RemoteException { this.loopCounter = num; } }