📄 yesnocounterimpl.java
字号:
/*
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -