You are viewing our Forum Archives. To view or take place in current topics click here.
OOP what is polymorphism?
Posted:

OOP what is polymorphism?Posted:

MrAidanPlays
  • Junior Member
Status: Offline
Joined: Oct 05, 20158Year Member
Posts: 90
Reputation Power: 3
Status: Offline
Joined: Oct 05, 20158Year Member
Posts: 90
Reputation Power: 3
Im studying for a degree in computer science but I come from a hardware background and I have a question I have to answer,

I need to write a basic overview (100-200 words) on polymorphism. now I know roughly what it is (correct me if im wrong) but it is basically where a derived class can inherit from a base class. But I am struggling to pad this out to meet the word count on this question.

I also need to provide an example on polymorphism once i have given my description and I was thinking something along the lines of a video game character.

As in, you have your class for your standard enemy in a video game that has all of the functions such as attack, walk turn etc. but you also want a special enemy so you can use polymorphism and inherit all of the features I have just mentioned for the standard enemy and then tweak some code to make them a special enemy such as increased damage or movement speed

Am I on the right lines here?

As mentioned this is in regards to object oriented programming (OOP) not Java

Thanks alot
#2. Posted:
ProJimmyRustler
  • 2 Million
Status: Offline
Joined: Jul 14, 20149Year Member
Posts: 1,720
Reputation Power: 71
Status: Offline
Joined: Jul 14, 20149Year Member
Posts: 1,720
Reputation Power: 71
MrAidanPlays wrote Im studying for a degree in computer science but I come from a hardware background and I have a question I have to answer,

I need to write a basic overview (100-200 words) on polymorphism. now I know roughly what it is (correct me if im wrong) but it is basically where a derived class can inherit from a base class. But I am struggling to pad this out to meet the word count on this question.

I also need to provide an example on polymorphism once i have given my description and I was thinking something along the lines of a video game character.

As in, you have your class for your standard enemy in a video game that has all of the functions such as attack, walk turn etc. but you also want a special enemy so you can use polymorphism and inherit all of the features I have just mentioned for the standard enemy and then tweak some code to make them a special enemy such as increased damage or movement speed

Am I on the right lines here?

As mentioned this is in regards to object oriented programming (OOP) not Java

Thanks alot

You are exactly spot on with how polymorphism works, and your base character class concept is perfect.
If you are interested, you can PM me and I will send you an excerpt from a book that I have that explains polymorphism from the game design perspective and how to apply it to a few examples.
The book mostly deals with C++. Let me know if you are interested.
#3. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Your example is fine.

However, your last sentence is a bit concerning for someone doing computing science:
"As mentioned this is in regards to object oriented programming (OOP) not Java "
- I hope you mean "object orientated programming; not specifically on Java".
Since, Java is one of the few languages that can claim to only have a single OO paradigm.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.