1 / 13

Class Diagrams

Class Diagrams. TariffSchedule. Trip. Class diagrams represent the structure of the system. Class diagrams are used during requirements analysis to model problem domain concepts during system design to model subsystems and interfaces during object design to model classes.

lahela
Download Presentation

Class Diagrams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class Diagrams TariffSchedule Trip • Class diagrams represent the structure of the system. • Class diagrams are used • during requirements analysis to model problem domain concepts • during system design to model subsystems and interfaces • during object design to model classes. Enumeration getZones() Price getPrice(Zone) zone:Zone price:Price * *

  2. Classes TariffSchedule Table zone2price Enumeration getZones() Price getPrice(Zone) Name TariffSchedule Attributes Signature zone2price getZones() getPrice() Operations TariffSchedule • A class represent a concept. • A class encapsulates state (attributes) and behavior (operations). • Each attribute has a type. • Each operation has a signature. • The class name is the only mandatory information.

  3. Instances tariff_1974:TarifSchedule zone2price = { {‘1’, .20},{‘2’, .40}, {‘3’, .60}} • An instance represents a phenomenon. • An object is an instance of a class. • The name of an instance is underlined and can contain the class of the instance. • The attributes are represented with their values.

  4. UML: Class and Instance Diagrams Inspector Class Diagram anonymous: Inspector joe: Inspector mary: Inspector Instance Diagram

  5. Attributes and Values Inspector name:string age: integer joe:Inspector mary: Inspector name = “Joe” name = “Mary” age = 24 age = 18

  6. TripLeg pricezone Associations TarifSchedule Enumeration getZones() Price getPrice(Zone) * * • Associations denote relationships between classes. • The multiplicity of an association end denotes how many objects the source object can legitimately reference.

  7. Has-capital 1-to-1 and 1-to-Many Associations Country City 1 1 name:String name:String 1-to-1 association Polygon Point 1 * x:Integer y:Integer draw() 1-to-many association

  8. Exhaust System Tailpipe Muffler Aggregation • An aggregation is a special case of association denoting a “consists of” hierarchy. • The aggregate is the class that contains the components (embedded objects) 1 0..2

  9. Automobile serial number Engine year manufacturer horsepower volume model on color off weight drive purchase Battery Wheel amps volts Brakelight diameter Door charge discharge number of bolts open on close off Aggregation 2,4 3,4,5 *

  10. TicketMachine ZoneButton Composition • A solid diamond denote composition, a strong form of aggregation where components cannot exist without the aggregate. • This is the “has-a” relationship in OOP 3

  11. Button CancelButton ZoneButton Generalization • Generalization relationships denote inheritance between classes. • The children classes inherit the attributes and operations of the parent class. • Generalization simplifies the model by eliminating redundancy. • Names of abstract classes are usually italicized.

  12. Red White Smooth Cortical Striate Inheritance • Models "kind of" hierarchy • Powerful notation for sharing similarities among classes while preserving their differences • UML Notation: An arrow with a triangle Cell BloodCell MuscleCell NerveCell Pyramidal

  13. From Problem Statement to Code Problem Statement A stock exchange lists many companies. Each company is identified by a ticker symbol Class Diagram lists StockExchange Company * * tickerSymbol Java Code public class StockExchange { public Vector m_Company = new Vector(); }; public class Company { public int m_tickerSymbol; public Vector m_StockExchange = new Vector(); };

More Related