やはりオブジェクト指向は幻想でした。 【2】
■ このスレッドは過去ログ倉庫に格納されています
0690デフォルトの名無しさん
NGNGclass 営業成績{
public 営業成績(){???}
public void 加算(営業成績 成績){???}
}
interface 組織{
組織 親組織取得();
void 子組織登録(組織 子組織)throws 登録不可例外;
Iterator 子組織リスト取得();
営業成績 営業成績取得();
}
class 部 implements 組織{/*省略*/}
class 課 implements 組織{
private 部 所属部;
private List 子組織リスト = new ArrayList();
public 課(部 所属部){this.所属部=所属部;}
public 組織 親組織取得(){return 所属部;}
public void 子組織登録(組織 子組織)throws 登録不可例外{
if(!(子組織 instanceof 社員))throw new 登録不可例外();
子組織リスト.add(子組織);
}
public Iterator 子組織リスト取得(){return 子組織リスト.iterator();}
public 営業成績 営業成績取得(){
営業成績 課_成績 =new 営業成績();
(Iterator イテレータ=子組織リスト取得();イテレータ.hasNext();)
課_成績.加算((組織)イテレータ.next()).営業成績取得());
return 課_成績;
}
}
class 社員 implements 組織{
private 課 所属課;
private 営業成績 個人営業成績;
public 社員(課 所属課,営業成績 個人営業成績){
this.所属課=所属課;
this.個人営業成績=個人営業成績;
}
public 組織 親組織取得(){return 所属課;}
public void 子組織登録(組織 子組織)throws 登録不可例外{
throw new 登録不可例外();
}
public Iterator 子組織リスト取得(){return null;}
public 営業成績 営業成績取得(){
return 個人営業成績;
}
}
■ このスレッドは過去ログ倉庫に格納されています