0 evaluări0% au considerat acest document util (0 voturi)
55 vizualizări3 pagini
A person can have up to three companies as employer. The employer IDs are equal to the company IDs the person is working for. The car owner ID is equal to the ID of the person, the company or the bank owning the car. Each point object always belongs to exactly one polygon only. If there are polygons having one or several points in common, the same point object is associated with two or more polygons.
A person can have up to three companies as employer. The employer IDs are equal to the company IDs the person is working for. The car owner ID is equal to the ID of the person, the company or the bank owning the car. Each point object always belongs to exactly one polygon only. If there are polygons having one or several points in common, the same point object is associated with two or more polygons.
A person can have up to three companies as employer. The employer IDs are equal to the company IDs the person is working for. The car owner ID is equal to the ID of the person, the company or the bank owning the car. Each point object always belongs to exactly one polygon only. If there are polygons having one or several points in common, the same point object is associated with two or more polygons.
Institute of Industrial Automation and Software Engineering
Prof. Dr.-Ing. Dr. h. c. P. Ghner
WS 04/05 1 03 Nov 2004, Gt Exercise 2 Introduction to UML
Question 2.1 Associations between Objects a) Develop a class diagram from the object diagram in figure 1:
Polygon1 Point1 Point3 Point2 Point4 x = -10 y = 10 x = 10 y = 10 x = 10 y = -10 x = -10 y = -10
Figure 1: Object diagram for a polygon which is a square by accident
Dont add multiplicities yet. Consider that each point has an X and a Y coordinate. How can you express the fact that points are in an order?
b) Which number of points is at least necessary, in order to design a polygon? Add multiplicity information to the class diagram of a), so that 1. each point object always belongs to exactly one polygon only; i. e. if there are polygons having one or several points in common, two or more point objects are allocated to the same position (figure 2). 2. each point object always belongs to exactly one position; i. e. if there are polygons having one or several points in common, the same point object is associated with two or more polygons (figure 3).
Figure 2: Two point objects
Figure 3: One point object
Software Engineering for Real-Time Systems Exercise 2: Introduction to UML WS 04/05 2 03 Nov 2004, Gt c) Consider two triangles sharing a common side as depicted by figure 4. Draw an according object diagram for each of the cases of point object allocation named in b).
(0, 1) (-1, 0) (1, 1) (1, 0) (-1, 0) x y
Figure 4: Triangles
Question 2.2 Associations between Classes The class diagram in figure 5 expresses the following issue about a car management system: A person can have up to three companies as employer. The employer IDs are equal to the company IDs the person is working for. Cars can be owned by persons, companies or banks. The car owner ID is equal to the ID of the person, the company or the bank owning the car. The purchase of a car may be associated with a car credit granted by a bank. Unfortunately several classes contain attributes, which are actually pointers to other objects and could be replaced by associations. It would be inconvenient to keep an object model where pointers are hidden in class attributes.
Name Age Employer 1 ID Employer 2 ID Employer 3 ID Person ID Address Person Owner ID Car ID Type of owner Model Year Car Car ID Type of customer Account number Bank ID Interest rate Account balance CarCredit Name Company ID Company Name Bank ID Bank
Figure 5: Classes with several attributes, which are actually pointers
Draw a class diagram, in which the pointers are replaced by associations. Introduce generalizations where useful. Try to determine the multiplicities correctly.
Software Engineering for Real-Time Systems Exercise 2: Introduction to UML WS 04/05 3 03 Nov 2004, Gt Question 2.3 Class Diagram of a Graphic Editor Draw a class diagram for a graphic editor, which supports the concept of grouping. Assuming that a document has several pages every page contains the following graphic objects: text, geometrical objects and groups. Geometrical objects are e.g. circles, ellipses, rectangles, lines and squares. A group is simply a set of graphic objects, which can contain further groups for its part. A group has to contain at least two graphic objects. A graphic object can be a direct member of at most one group.
Question 2.4 Class Diagram of a Banking Software You are a software developer working in a company which develops bank software systems. A customer has sent the following short description of a new software system:
A person becomes a customer, if she or he opens an account. A customer can open an arbitrary number of additional accounts. For every new customer the name (which may be ambiguous), the address, the date, when she or he has opened the first account, are recorded. At the opening of an account the customer has to do a first deposit. We distinguish current accounts and savings accounts. Current accounts may be overdrawn up to a predetermined amount. For every account an individual rate of interest on credit is fixed and for current accounts an individual rate of interest charges, too. In addition, every account has an unambiguous account number. About every savings account the kind of saving, e.g. fixed- term deposit account, is stored. A customer can deposit and withdraw amounts. Furthermore the interest on credit is credited and in case of current accounts interest charges are debited. In order to calculate the amount of interest the date and the amount of every transaction has to be noted down. The credit advice/direct debiting of the interest takes place annually in case of savings accounts and quarterly for current accounts. A customer may liquidate each of his accounts if she or she wants to. When liquidating her or his last account the person ceases being a customer.
a) Identify the classes, attributes, operations, associations and inheritance structures in the description above and draw a class diagram. b) Create an object diagram assuming some data samples on your own.