Download presentation
Presentation is loading. Please wait.
Published byProsper McKenzie Modified over 8 years ago
1
Class Diagram Associations Class Diagrams, Class Stereotypes, Class Associations Dr. Neal CIS 480
2
Class Diagram Provides definition of system components Contains important structural information for the new system Provides details describing database and object-oriented program Consists of problem domain classes and implementation classes Provides a static view of the system
3
UML Class Representation Rational
4
Class Stereotypes and Views Icon representation Label representation Same class different view
5
Bank Account Class Associations Navigable association Inheritance association
6
Unidirectional and Navigable Associations Unidirectional Customer knows about Order, but Order doesn’t know of customer Bidirectional or Navigable Customer knows about Order and Order knows about Customer
7
Class to Class Messages public class Order { // some attributes protected String customerName; protected Customer CustomerOwner; // some methods public setCustomerName(String name) { customerName = name; } public class Customer { // some attributes protected String name; protected Order[] OrderList; // some methods private void doName() { OrderList = new Order[2]; OrderList[0] = new Order(); OrderList[0].setCustomerName(name); } Array of Order objects Call or message to Order object
8
A Generalization/Specialization Hierarchy for Motor Vehicles
9
Class Specialization public class Consumer : Customer { // some attributes // some methods } public class Customer { // some attributes protected String name; // some methods private void doName() { // do something } public class Commercial : Customer { // some attributes // some methods } Colon key word for subclass Superclass Subclasses
10
Aggregation or Whole-Part Relationships
11
Class Aggregation public class Engine { // some attributes // some methods } public class Car { // some attributes protected Wheel[] WheelList; protected Engine ClassEngineOject; // some methods } public class Wheel { // some attributes // some methods } Object collection for wheels and single id for engine Aggregate class Parts classes
12
Enrollment Class Diagram with Association Class
13
Association Class public class Product { // some attributes protected Vendor[] VendorList; // some methods } public class Shipment { // some attributes public Vendor VendorObject; public Product ProductObject // some methods } public class Vendor { // some attributes protected Product[] ProductList; // some methods } Association class Other classes
14
Multiple Inheritance by Interfaces Sometimes a class needs to provide behavior matching more than one class If the class is already of subclass of another base class then inheritance can’t be used so how is this additional behavior guarantee We need a relationship that establishes a contract for one class to implement another's behavior The behavior can be defined with an Interface The “Realizes” relationship forces the interface to be implemented by the class In this way a class may “Realize” the behavior of multiple classes
15
Multiple Inheritance the Realizes Relationship public interface MessageInterface { // some method signatures Boolean receiveMessage(String msg); } public class Window { // some attributes // some methods } public class ListBoxControl : Window, MessageInterface { // some attributes // some methods Boolean receiveMessage(String msg) { // do something } ListBoxControl has a contract to implement methods Base class Sub class Contract or Interface class Multiple Inheritance using an Interface
16
Partial Domain (static) Class Diagram for RMO
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.