Professional Documents
Culture Documents
Learning Outcomes:
Design a program that apply an Inheritance and polymorphism in programming to test and debug
the program
REVIEW:
Polymorphism
Example 1:
• In a computer game that simulates the movement of animals we can send ‘move’
commands to different types of animal
• We send the commands via an animal reference which is the base class for the different
animal types
• But each type behaves differently once it receives the command
• Such an approach leads to a readily extendable application
OBJECT ORIENTED PROGRAMMING
WEEK 13: Inheritance and Polymorphism
EXAMPLE 2:
Make one statement about how a hospital manager may interact with all doctors employed at
their hospital irrespective of what type of doctor they are.
FEEDBACK 2:
You may have considered that a hospital manager could pay all the doctors (presumably this
will be done automatically at the end of every month) and could discipline any doctor guilty of
misconduct – of course this would be true for other staff as well. More specifically a manager
could check that a doctor’s medical registration is still current. This would be something that
management would need to do for all doctors irrespective of what their specialism is.
Using the same idea of polymorphism allows computer systems to be extended, with new
specialized objects being created, while allowing current parts of the system to interact with
new object without concern for the specific properties of the new object.