类的关系2 转帖
摘要:
共四种:(1)关联(Association)两个独立实例存在对应关系,如客户和订单,公司和员工。 具体表现:使用实例变量来实现。 代码: publicclassCompany{ privateEmployeeemployee; publicEmployeegetEmployee(){ returnemployee; } publicvoidsetEmployee(Employeeemployee){ this.employee=employee; } //公司运作 publicvoidrun(){ employee.startWorking(); }}(2)聚合(Aggr... 阅读全文
posted @ 2011-10-04 11:46 oldsnow 阅读(100) 评论(0) 推荐(0) 编辑