📄 spheremodel.java
字号:
/**
* @author 罗求忠 @edu.buaa.etei
* 2007-9-18 下午07:30:36
*/
package edu.buaa.basic.test.mvc.model;
/**
*
* Model类扩展自Observable类,在Observable类中,方法addObserver()将视图与模型相关联,
* 当模型发生改变时(当控制器改变模型的状态),模型就会方法notifyObservers()通知视图,
* 从而实现自动刷新与之相关的视图。
*
*/
public class SphereModel extends AbstractModel {
public SphereModel(double radius) {
this.radius = radius;
}
public void setRadius(double radius) {
this.radius = radius;
volume = (4 * pai * Math.pow(this.radius, 3)) / 3;
surfArea = 4 * pai * Math.pow(this.radius, 2);
// Indicates that the model has changed
setChanged();
// Notify all observers
notifyObservers();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -