All Questions
Tagged with polymorphism inheritance
22 questions
4
votes
4
answers
3k
views
Model animals using inheritance in Java, revised
Yesterday I posted my first solution to an interview problem here. I am now aware that I have many weak spots in Java and need to do extensive review before tackling any more interviews. Having said ...
4
votes
2
answers
385
views
Animal, Dog, and IDangerous - Using interfaces and inheritance with C#
I'm quite new to object-oriented C#. I wanted to test my knowledge by creating a Dog/Animal classes. I also tried to implement ...
1
vote
1
answer
213
views
Polymorphism and inheritance in C99
In the following code I have created the something like the behavior of inheritance and methods in C99 (without vtable). The code compiles without any warnings even with ...
3
votes
2
answers
394
views
Implementing different types of light sources in a Graphics project
Edit: I got asked a lot why I need to have the LightSource base class or why do I keep one vector of all the light sources, so here's my explanation:
In many ...
2
votes
1
answer
186
views
Managing different types of morphism and their compositions
Here's some code I wrote to manage the different types of morphism and their compositions in C++17.
Let me know if you had any suggestions for substantial simplifications or improvements, or if I ...
6
votes
1
answer
2k
views
Making TypeNameHandling in json.net more convenient
Handling abstract types in json.net can be sometimes challenging because it requires a very long and complex syntax like:
...
-2
votes
1
answer
260
views
Parsing various types of message strings
Similar question
MessageFormat: represents the various kinds of messages. (XML, JSON, ...
2
votes
2
answers
97
views
Represent a person who has different roles for different offices
People have different types of roles depending on the office they are working at. For example, a person has two roles (cashier,cleaner) at OfficeMax and five roles(manager,security,etc) at OfficeLess. ...
3
votes
3
answers
1k
views
Models an assembly line
The gist of the code is that there's an assembly line of products, in this case Toy and Book, that get inspected by workers who then add them to a box. The box is then sent to someone who knows what ...
2
votes
2
answers
2k
views
Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle - follow up
This is the new code after the changes suggested by @Cody Gray in the last question:
Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle
This is my project on ...
8
votes
1
answer
21k
views
Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle
This is my project on inheritance and polymorphism. I have the main file from my teacher and built the project base on it. My base class is Shape. ...
0
votes
2
answers
240
views
Very complicated Java HelloWorld app
This program attempts to shows the basic concepts of inheritance and polymorphism. In what ways could the code be modified to better demonstrate those concepts? The interface, abstract class and the ...
2
votes
3
answers
2k
views
Polymorphically processing 2 & 3 dimensional objects
It seems there are a lot of "empty containers" (I do not know the correct, technical term) with regards to multiple levels of abstract classes and functional interfaces with little or no code. Is ...
4
votes
2
answers
2k
views
Sorting polymorphic classes
I'm learning from "Jumping into C++" by Alex Allain (sample chapter and TOC) and solved the first problem in Chapter 26 "Inheritance and Polymorphism".
I'm especially concerned about my use of ...
8
votes
1
answer
437
views
Polymorphic animals speak their name and make a noise
I'm new to GNU Smalltalk. I'd like to port a script I've written in Ruby, Scala, CoffeeScript, and several others. It's the one I use to try to learn the classic OOP concepts of abstract classes, ...