tailieunhanh - Lecture An Introduction to Object-Oriented Programming with Java (4/e): Chapter 13 - C. Thomas Wu

Chapter 13 - Inheritance and polymorphism. After you have read and studied this chapter, you should be able to: Write programs that are easily extensible and modifiable by applying polymorphism in program design; define reusable classes based on inheritance and abstract classes and abstract methods; differentiate the abstract classes and Java interfaces; define methods, using the protected modifier; parse strings, using a String Tokenizer object. | Chapter 13 Inheritance and Polymorphism 4th Ed Chapter N - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 13 Objectives After you have read and studied this chapter, you should be able to Write programs that are easily extensible and modifiable by applying polymorphism in program design. Define reusable classes based on inheritance and abstract classes and abstract methods. Differentiate the abstract classes and Java interfaces. Define methods, using the protected modifier. Parse strings, using a String Tokenizer object. 4th Ed Chapter N - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance Case Study: Suppose we want implement a class roster that contains both undergraduate and graduate students. Each student’s record will contain his or her name, three test scores, and the final course grade. The formula for determining the course grade is different for graduate students than for undergraduate students. 4th Ed Chapter N - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Modeling Two Types of Students There are two ways to design the classes to model undergraduate and graduate students. We can define two unrelated classes, one for undergraduates and one for graduates. We can model the two kinds of students by using classes that are related in an inheritance hierarchy. Two classes are unrelated if they are not connected in an inheritance relationship. 4th Ed Chapter N - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Classes for the Class Roster For the Class Roster sample, we design three classes: Student UndergraduateStudent GraduateStudent The Student class will incorporate behavior and data common to both UndergraduateStudent and GraduateStudent objects. The UndergraduateStudent class and the GraduateStudent class will each contain behaviors and data specific to their . | Chapter 13 Inheritance and Polymorphism 4th Ed Chapter N - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 13 Objectives After you have read and studied this chapter, you should be able to Write programs that are easily extensible and modifiable by applying polymorphism in program design. Define reusable classes based on inheritance and abstract classes and abstract methods. Differentiate the abstract classes and Java interfaces. Define methods, using the protected modifier. Parse strings, using a String Tokenizer object. 4th Ed Chapter N - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Defining Classes with Inheritance Case Study: Suppose we want implement a class roster that contains both undergraduate and graduate students. Each student’s record will contain his or her name, three test scores, and the final course grade. The formula for determining the course grade is different for graduate .

crossorigin="anonymous">
Đã 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.