Docsity

UML III - Object-Oriented Programming II - Notes | CMSC 132, Study notes of Computer Science

Partial preview of the text

Download UML III - Object-Oriented Programming II - Notes | CMSC 132 and more Study notes Computer Science in PDF only on Docsity!

CMSC 132:

Object-Oriented Programming II

UML III

Department of Computer Science

University of Maryland, College Park

UML Examples

Read UML class diagram Try to understand relationships Examples

Pets & owners Computer disk organization Banking system Home heating system

UML Example โ€“ Veterinary System Try to read & understand UML diagram โ€ข^

1 or more Pets associated with 1 PetOwner

UML Example โ€“ Computer System

Try to read & understand UML diagram

UML Example โ€“ Banking System

Try to read & understand UML diagram

UML Example โ€“ Banking System

-^

1 Bank associated with 0 or more Accounts

-^

Checking, Savings, MoneyMarket are Accounts

UML Example โ€“ Home Heating System

โ€ข^

Each Thermostat is associated with 1 Room

-^

Each Thermostat associated with 0 or more Heaters

-^

ElectricHeater is a specialized Heater

-^

AubeTH101D is a specialized Thermostat

UML Class Diagrams

โ†”โ†”โ†”โ†”

Java

Different representation of

same

information

Name, state, behavior of class Relationship(s) between classes

Practice deriving one from the other

Accurately depicting relationship between classes

UML

โ†’โ†’โ†’โ†’

Java : Veterinary System

UML Java^ class Pet {

PetOwner myOwner;

// 1 owner for each pet

} class PetOwner {

Pet [ ] myPets;

// multiple pets for each owner

Java

โ†’โ†’โ†’โ†’

UML : Veterinary System

Java^ class Pet {

PetOwner myOwner;

// 1 owner for each pet

} class PetOwner {

Pet [ ] myPets;

// multiple pets for each owner

} UML

UML Class Diagrams

โ†”โ†”โ†”โ†”

Java

UML Java^ class Pet {

PetOwner myOwner;

// 1 owner for each pet

} class PetOwner {

Pet [ ] myPets;

// multiple pets for each owner

UML

โ†’โ†’โ†’โ†’

Java : Computer System

UML Java

UML

โ†’โ†’โ†’โ†’

Java : Computer System

UML Java

Design code using all available information in UMLโ€ฆ

UML

โ†’โ†’โ†’โ†’

Java : Computer System

Java^ class CPU {

Controller [ ] myCtlrs; } class Controller {

CPU myCPU; } class SCSIController extends Controller {

DiskDrive [ ] myDrives = new DiskDrive[4]; } Class DiskDrive {

SCSIController mySCSI; }