导航
您当前的位置:首页 > 计算机 > 软件水平
问题:

[问答题] 现欲开发一个软件系统,要求能够同时支持多种不同的数据库,为此采用抽象工厂模式设计该系统。以SQL Server和Access两种数据库以及系统中的数据库表Department为例,其类图如图6-1所示。中级软件设计师,历年真题,2012年下半年(下午)《软件设计师》真题图6-1类图【Java代码】import javA.util.*;class Department{/*代码省略*/}interface IDepartment{(1);(2);}class SqlserverDepartment(3){public voidInsert(Department department){System.out.println(”Insert a record into Department in SQL Server!");∥其余代码省略}public Department GetDepartment(int id){/*代码省略*/}}classAccessDepartment(4){public void Insert(Department department){System.out.println("Insert a record into Department in ACCESS!”);∥其余代码省略}public Department GetDepartment(int id){/*代码省略*/}}(5){(6);}class SqlServerFactory implements IFactory{public IDepartment CreateDepartment(  ){retum new SqlserverDepartment(  );}∥其余代码省略}class AccessFactory implements IFactory{public IDepartment CreateDepartment(  ){return new AccessDepartment(  );}∥其余代码省略}
答案解析:

相关问题
关于我们 | 用户指南 | 版权声明 | 给我留言 | 联系我们 | 积分商城 | 答案求助 | 网站地图
Copyright © 2024 www.daanwo.com All Rights Reserved