yesnocounterimpl.java
来自「Java the UML Way 书中所有源码」· Java 代码 · 共 43 行
JAVA
43 行
/*
* YesNoCounterImpl.java E.L. 2001-08-25
*
*/
import java.rmi.*;
import java.rmi.server.*;
class YesNoCounterImpl extends UnicastRemoteObject implements YesNoCounter {
private int numberOfYes = 0;
private int numberOfNo = 0;
public YesNoCounterImpl() throws RemoteException {
}
public synchronized void increaseNumberOfYes() throws RemoteException {
System.out.println("The number of yes votes was increased by 1");
numberOfYes++;
}
public synchronized void increaseNumberOfNo() throws RemoteException {
System.out.println("The number of no votes was increased by 1");
numberOfNo++;
}
public synchronized void increaseNumberOfYes(int increase) throws RemoteException {
System.out.println("The number of yes votes was increased by " + increase);
numberOfYes += increase;
}
public synchronized void increaseNumberOfNo(int increase) throws RemoteException {
System.out.println("The number of no votes was increased by " + increase);
numberOfNo += increase;
}
public synchronized int getNumberOfYes() throws RemoteException {
return numberOfYes;
}
public synchronized int getNumberOfNo() throws RemoteException {
return numberOfNo;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?