📄 sendratechange.java
字号:
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.
/* Any object that implements the RateChangeListener
* interface can be notified about interest rate
* changes. We notify investor and business objects
* which implement RateChangeListener to take action
* when the rate change occurs.
*/
interface RateChangeListener {
public void rateRaised(double amount);
public void rateLowered(double amount);
}
class Investor implements RateChangeListener {
public void rateRaised(double amount) {
System.out.println(" Investor sells stocks");
}
public void rateLowered(double amount) {
System.out.println(" Investor buys stocks");
}
public void countMoney() {
System.out.println("Counting money");
}
}
class Business implements RateChangeListener {
public void rateRaised(double amount) {
System.out.println(" Business reduces debt");
}
public void rateLowered(double amount) {
System.out.println(" Business takes a loan");
}
public void doPayroll() {
System.out.println("Doing payroll");
}
}
public class SendRateChange {
public static void main(String [] args) {
RateChangeListener investor = new Investor();
RateChangeListener business = new Business();
System.out.println("Raising interest rates");
investor.rateRaised(.50);
business.rateRaised(.50);
System.out.println("Lowering interest rates");
investor.rateLowered(.25);
business.rateLowered(.25);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -