Lecture Introduction to programming with Java - Chapter 12: Aggregation, composition, and inheritance

This chapter presents the following content: Composition, aggregation, UML class diagram for composition and aggregation, car dealership program, inheritance overview, inheritance example - people in a department store, inheritance terminology, uml class diagrams for inheritance hierarchies,.and other contents. | Chapter 12 – Aggregation, Composition, and Inheritance Composition Aggregation UML Class Diagram for Composition and Aggregation Car Dealership Program Inheritance Overview Inheritance Example - People in a Department Store Inheritance Terminology UML Class Diagrams for Inheritance Hierarchies Benefits of Inheritance Inheritance For a Superclass's private Instance Variables Using super to Call Superclass Constructor Calling a Superclass's Method from Within a Subclass Default Call to Superclass Constructor Method Overriding The final Access Modifier Aggregation , Composition, and Inheritance Compared Aggregation, Composition, and Inheritance Combined Card Game Program 1 Composition Prior to this chapter, all of our objects have been relatively simple, so we've been able to describe each object with just a single class. But for an object that's more complex, you should consider breaking up the object into its constituent parts and defining one class as the whole and other classes as parts of the whole. When the whole class is the exclusive owner of the parts classes, then that class organization is called a composition. 2 Composition The concept of composition is not new; that's what we do to describe complex objects in the real world: Every living creature and most manufactured products are made up of parts. Often, each part is a subsystem that is itself made up of its own set of subparts. Together, the whole system forms a composition hierarchy. Note the human body composition hierarchy on the next slide. Remember that with a composition relationship, a component part is limited to just one owner at a time. For example, a heart can be in only one body at a time. 3 Composition A partial composition hierarchy for the human body: 4 Aggregation In a composition hierarchy, the relationship between a containing class and one of its part classes is known as a has-a relationship. For example, each human body has a brain and has a heart. There's another . | Chapter 12 – Aggregation, Composition, and Inheritance Composition Aggregation UML Class Diagram for Composition and Aggregation Car Dealership Program Inheritance Overview Inheritance Example - People in a Department Store Inheritance Terminology UML Class Diagrams for Inheritance Hierarchies Benefits of Inheritance Inheritance For a Superclass's private Instance Variables Using super to Call Superclass Constructor Calling a Superclass's Method from Within a Subclass Default Call to Superclass Constructor Method Overriding The final Access Modifier Aggregation , Composition, and Inheritance Compared Aggregation, Composition, and Inheritance Combined Card Game Program 1 Composition Prior to this chapter, all of our objects have been relatively simple, so we've been able to describe each object with just a single class. But for an object that's more complex, you should consider breaking up the object into its constituent parts and defining one class as the whole and other classes .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.