Page 288 -
P. 288
chaPter 10 • object-oriented systems analysis and design Using Uml 255
An attribute describes some property that is possessed by all objects of the class. Notice that
the RentalCar class possesses the attributes size, color, make, and model. All cars possess these
attributes, but each car will have different values for its attributes. For example, a car can be blue,
white, or some other color. Later on we will demonstrate that you can be more specific about the
range of values for these properties. When specifying attributes, the first letter is usually lowercase.
A method is an action that can be requested from any object of the class. Methods are
the processes that a class knows to carry out. Methods are also called operations. For the class
RentalCar, rentOut(), checkIn(), and service() are examples of methods. When specifying
methods, the first letter is usually lowercase.
Inheritance
A key concept of object-oriented systems is inheritance. Classes can have children; that is, one
class can be created out of another class. In UML, the original—or parent—class is known as a
base class. The child class is called a derived class. A derived class can be created in such a way
that it will inherit all the attributes and behaviors of the base class. A derived class, however,
may have additional attributes and behaviors. For example, there might be a Vehicle class for a
car rental company that contains attributes such as size, color, and make.
Inheritance reduces programming labor by using common objects easily. The programmer only
needs to declare that the Car class inherits from the Vehicle class and then provide any additional
details about new attributes or behaviors that are unique to a car. All the attributes and behaviors
of the Vehicle class are automatically and implicitly part of the Car class and require no additional
programming. An analyst can therefore define once but use many times, and this is similar to data
that is in the third normal form, defined only once in one database table (as discussed in Chapter 13).
The derived classes shown in Figure 10.2 are Car or Truck. Here the attributes are preceded
by minus signs and methods are preceded by plus signs. We will discuss this in more detail later in
the chapter, but for now note that the minus signs mean that these attributes are private (not shared
with other classes) and these methods are public (may be invoked by other classes).
Vehicle Figure 10.2
–size A class diagram showing
–color inheritance. Car and Truck are
–make specific examples of vehicles and
–model inherit the characteristics of the
–available more general class Vehicle.
–ratePerDay
–ratePerWeek
–ratePerMile
+rentOut( )
+checkIn( )
+service( )
+addNew( )
is a is a
Car Truck
–size –size
–color –color
–make –make
–model –model
–available –available
–ratePerDay –ratePerDay
–ratePerWeek –ratePerWeek
–ratePerMile –ratePerMile
–style –length
+rentOut( ) –4WheelDrive
+checkIn( ) –manualShift
+service( ) +rentOut( )
+addNew( ) +checkIn( )
+service( )
+addNew( )