记录一下做这个头疼作业的过程,整理整理思路
题目
Description
The customer information system maintains information about two different kinds of customers:
Individual customers: For these customers, the system stores an ID and the information about a person (name, home telephone number, and email).
Institutional customers: For these customers, the system stores an ID and provides the capability of defining one or more contact people for the institution. The system stores the following information for each contact person: name, home telephone number, email, work telephone number, and the job position of the contact in the institution.
Assume that each customer has a unique ID and that IDs cannot be modified. Assume each contact for an institution has a unique name.
The system provides the following functions:
Add a customer into the system
Look up a customer given an ID
Remove a customer from the system given an ID
Add a new contact for an institutional customer
Look up a contact given the ID of the institution and the name of the contact
Remove a contact given the ID of the institution and the name of the contact
Tasks
The following steps will guide you for completing this assignment:
Follow the technique described in page 1.2.5 Modeling Classes to model the customer information system. Use Eclipse, Violet, PowerPoint, or another tool of your choosing to draw a UML class diagram.
Your UML class diagram should include:
The classes to model the customer information system and the different kinds of customers
The association relationships (including the direction, multiplicity, and association attribute)
The specialization/generalization relationships
The attributes and methods, including accessors and mutators (only for the attributes that can be modified)
The class that models institutional customers should include the following methods that handle the collection of contacts (in addition to these, you may need more methods):
Method to add a new contact
Method to look up a contact given the name
Method to remove a contact given the name
The class that models the customers information system should include the following methods that handle the collection of customers (in addition to these, you may need more methods):
Method to add a new customer
Method to look up a customer given an ID
Method to remove a customer given an ID
Use Sun’s coding conventions when naming classes, methods, and attributes.
Save the UML class diagram in a GIF or JPG format in a file named uml-customer-system. The extension of this file will depend on the format of the image.
就不排版嘤嘤嘤
首先先大概读题。。。然后梳理一下题目关系(其实没卵用,说白了就是翻译,辣鸡大学,搞什么英语嘛)
然后试着去分析一下基础的类关系
很明显,首先最基础的类应该是customer类,然后往下继承出Individual customers和Institutional customers
最基本的类,提供了所有customer都有的方法和属性,
感觉说白了就是在下面这一段里面找名词和动词,名词就是属性,动词后跟方法
Individual customers: For these customers, the system stores an ID and the information about a person (name, home telephone number, and email).
Institutional customers: For these customers, the system stores an ID and provides the capability of defining one or more contact people for the institution. The system stores the following information for each contact person: name, home telephone number, email, work telephone number, and the job position of the contact in the institution.
Assume that each customer has a unique ID and that IDs cannot be modified. Assume each contact for an institution has a unique name.
(个人客户:对于这些客户,系统存储一个ID和关于一个人的信息(姓名、家庭电话号码和电子邮件)。
机构客户:对于这些客户,系统存储一个ID,并提供为机构定义一个或多个联系人的功能。系统为每个联系人存储以下信息:姓名、家庭电话号码、电子邮件、工作电话号码以及联系人在机构中的工作职位。
假设每个客户都有一个惟一的ID,并且不能修改ID。假设每个机构都有联系人)
然后分析属性的权限,这里肯定是private,感觉这种个人信息啥的想都不用想上来就private完事儿。既然是private,自然就要提供对外的接口,题目上也明确写了,***The attributes and methods, including accessors and mutators (only for the attributes that can be modified)***属性和方法,包括访问器和修改器(仅针对可修改的属性)自然就要添上set和get方法。具体就是set+属性名和get+属性名。
接着从这个customer类里面分别继承出IndividualCustomer和InstitutealCustomer,每一个又关联着自己特殊的类,如instituteCustomer就还有contact 那一大家子。(addContact方法写的时候预留了一个后面要写的Contact类)
这就完成了每一个操作对象的类的设计了
之后我们再建立起每个操作对象的数据库(就是很多个被操作的类合在一起)
最后再写一个输出的类界面的。大致上应该就是这样吧: