Compulsory Task 2 Create a file named method_override.py and follow the instructions below: ● Take user inputs that ask for the name, age, hair colour, and eye colour of a person. Create an adult class with the following attributes and method: O name, age, eye_colour, and hair_colour O Method called can_drive() that prints the name of the person and that they are old enough to drive. Create a subclass of the adult class named "Child" that has the same attributes, but overrides the can_drive method to print the persons name and that they are too young to drive. Create some logic that determines if the person is 18 or older and create an instance of the Adult class if this is true. Otherwise, create an instance of the Child class. Once the object has been created, call the can_drive () method to print out whether the person is old enough to drive or not. SE L1T29 - Introduction to OOP II - Inheritance.pdf 1 of 2

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
Compulsory Task 2
Create a file named method_override.py and follow the instructions below:
Take user inputs that ask for the name, age, hair colour, and eye colour of a
person.
Create an adult class with the following attributes and method:
name, age, eye_colour, and hair_colour
Method called can_drive() that prints the name of the person and
that they are old enough to drive.
Create a subclass of the adult class named “Child" that has the same
attributes, but overrides the can_drive method to print the persons name
and that they are too young to drive.
Create some logic that determines if the person is 18 or older and create an
instance of the Adult class if this is true. Otherwise, create an instance of the
Child class. Once the object has been created, call the can_drive() method
to print out whether the person is old enough to drive or not.
O
Ask a
SE L1T29 - Introduction to OOP II - Inheritance.pdf
212%
8 of 9
C
1 of 2
work!
>
x
Transcribed Image Text:Compulsory Task 2 Create a file named method_override.py and follow the instructions below: Take user inputs that ask for the name, age, hair colour, and eye colour of a person. Create an adult class with the following attributes and method: name, age, eye_colour, and hair_colour Method called can_drive() that prints the name of the person and that they are old enough to drive. Create a subclass of the adult class named “Child" that has the same attributes, but overrides the can_drive method to print the persons name and that they are too young to drive. Create some logic that determines if the person is 18 or older and create an instance of the Adult class if this is true. Otherwise, create an instance of the Child class. Once the object has been created, call the can_drive() method to print out whether the person is old enough to drive or not. O Ask a SE L1T29 - Introduction to OOP II - Inheritance.pdf 212% 8 of 9 C 1 of 2 work! > x
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT