Imagine you have two classes: Employee (which represents being an employee) and Ninja (which represents being a Ninja). An Employee has both state and behaviour; a Ninja has only behaviour. You need to represent an employee who is also a ninja (a common problem in the real world). By creating only one interface and only one class (NinjaEmployee), show how you can do this without having to copy method implementation code from either of the original classes.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question

Imagine you have two classes: Employee (which represents being an employee) and Ninja (which represents
being a Ninja). An Employee has both state and behaviour; a Ninja has only behaviour. You need to represent an
employee who is also a ninja (a common problem in the real world). By creating only one interface and only one
class (NinjaEmployee), show how you can do this without having to copy method implementation code from either
of the original classes.

8:17
we should try to use these key
int.
rovide a class diagram below:
lass System
sinterface
Ninja_Interface
Employee
ID: int
Name: String
+ moveNinja10: void
moveNinja20: void
Salary: int
startWorkingl): void
NinjaEmployee
Ninja
• moveNinja10: void
moveNinja20): void
startWorking): void
• moveNinja1() void
+ moveNinja2(): void
1
st of all: We have Employee class
d implement it like other simple
sses. It has some implemented
ributes and classes.
condly: We have an Interface name
nia Interface that have some
vacy
a “Accept all cookies
you agree
Transcribed Image Text:8:17 we should try to use these key int. rovide a class diagram below: lass System sinterface Ninja_Interface Employee ID: int Name: String + moveNinja10: void moveNinja20: void Salary: int startWorkingl): void NinjaEmployee Ninja • moveNinja10: void moveNinja20): void startWorking): void • moveNinja1() void + moveNinja2(): void 1 st of all: We have Employee class d implement it like other simple sses. It has some implemented ributes and classes. condly: We have an Interface name nia Interface that have some vacy a “Accept all cookies you agree
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Development strategies
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning