用OO的思想封装dataclass dataDemo { private int prority = 0; // From 1 to 5, for example private Object data = null; public dataDemo(Object obj, int prority) { this.data = obj; this.prority = prority; } public Object getData(int prority) throws Exception { if (prority < this.prority) { throw new Exception(); } else return data; }
public void resetData(Object obj, int prority) throws Exception { if (prority < this.prority) { throw new Exception(); } else this.data = obj; } }
如果是管理员就显示一些他那看的,否则跳去else结构显示不能看的
管理员是用户的个内部类 数据是private 的
这样貌似可行
但是逻辑上有点别扭
private int prority = 0; // From 1 to 5, for example
private Object data = null; public dataDemo(Object obj, int prority) {
this.data = obj;
this.prority = prority;
} public Object getData(int prority) throws Exception {
if (prority < this.prority) {
throw new Exception();
}
else return data;
}
public void resetData(Object obj, int prority) throws Exception {
if (prority < this.prority) {
throw new Exception();
}
else this.data = obj;
}
}