What's in an object?

Classes and Methods Abstract classes cannot exist as concrete objects(instances). Usually they have one or multiple abstract methods which are implemented only in subclasses. Concrete classes, on the other hand, can exist as concrete objects.classes cannot exist as concrete objects(instances). Usually they have one or multiple abstract methods which are implemented only in subclasses. Concrete classes, on the other hand, can exist as concrete objects. Example: Abstract Classes "Digital playback device" is an abstract concept of its concrete implementations – e.g. CD-player or MP3-player. Italicized class/method name indicates abstract class/method. +playback() +stop() +forward() +reverse() +next() +previous() +preview_all() -output_power: int -noise_level: int Digital_Playback_Device +playback() +stop() +forward() +reverse() +next() +previous() CD_Player +playback() +stop() +forward() +reverse() +next() +previous() MP3_Player Default Values and Constraints The attributes of an object can be provided with default values. These will be used by default if nothing is specified upon construction. Also, constraints can be used to specify requirements on attributes. This allows us to express invariants: object properties that always hold. Example: Constraints These constraints ensure that circles always have a positive radius, and rectangles positive side lengths. +area(): double +draw() +set_position(position:Point) +get_position(): Point -position: Point = (10, 10) Shape +area(): double +draw() +set_radius(radius:double) +get_radius(): double -radius: double = 1 {radius > 0} Circle +area(): double +draw() +set_a(length:double) +set_b(length:double) get_a():double get_b(): double -a: double = 10 {a > 0} -b: double = 10 {b > 0} Rectangle default value