One of the four pillars of object-oriented programming (OOP), inheritance establishes a "is-a" relationship between objects. For example, a "Cat" object can be treated in code as any other "Animal" object because a "Cat" is-a "Animal".

learn more… | top users | synonyms

3
votes
1answer
28 views
6
votes
2answers
102 views

“Simple” generic inheritance

I'm sure that my intentions are highly erroneous, and I really just want to see what you guys would suggest I do instead. I have a class I made for my game which helps store various values regarding ...
3
votes
3answers
217 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 ...
13
votes
4answers
2k views

Mini RPG equipment code

what do you think about this code? It's upgraded version of: Classes representing items in an RPG game ...
4
votes
1answer
222 views

Classes representing items in an RPG game

I wrote a little program in C# that contains classes representing Items in RPG game. I wanted to have access to all inherited classes parameters from list contains parent Item class instances, so this ...
2
votes
2answers
89 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 ...
6
votes
1answer
243 views

Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle

This is my project on inheritance and polymorphism , I got the main file from my teacher and built the project base on it .My base class is Shape .Polygon and Circle Inheritance from shape . Triangle ...
3
votes
2answers
67 views

Loading items from XML document

I'm making a game in Unity and I need to have a inventory/item system, I decided to store my items in simple XML document which I later read from. I'm planning to have different varieties of items and ...
3
votes
1answer
109 views

Try again, and again, and again… but not too often because the potatoes won't grow

The delay sequence has been fixed so I can move to the next step which are the Retry and Breaker. (Just ignore the console ...
1
vote
1answer
105 views

Growing potatoes in delayed sequences

In order to grow potatoes I'm implementing the retry pattern. If I fail to grow them, I'd like to try it again later. The first part I've implemented is a collection of delay generators. Their base ...
1
vote
1answer
75 views

Print Professor and Student Object using Inheritance in C++

I'm a newbie in C++ (6 hours) and I have implemented this problem in C++ . I know this is a simple example but how can this be improved? Syntax wise or shortened code wise? Here is the question from ...
3
votes
2answers
85 views

Structure of inheritance between Animal classes and methods

I'm trying to do some basic inheritance between the 3 classes and use some simple methods, and I'm looking to learn what should be the correct structure between them and what can be improved. ...
-1
votes
2answers
113 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
1answer
54 views

Validation of a couple of model classes using FluentValidator

A couple of model classes are doing the validation using FluentValidator. These model classes are used to Add and Edit the branch data and they are working well but ...
0
votes
0answers
107 views

AngularJS factory for Angular material $md-Toast notifications

If you are writing an Angular 1.5 App and incorporating elements of Angular-Material you can use this factory to create many customizable toasts with $mdToast ...
3
votes
1answer
55 views

Map object types using custom converter

I'm trying to design a mapper that will convert one object type to another shown in the diagram below: The object has structure as follows (it's not a JSON): ...
0
votes
4answers
110 views

Multilingual command handler using inheritance

My problem is that you have a lot of ifconditions to be checked and inside that if condition you have multiple lines of code. I ...
-2
votes
1answer
51 views

Is it ok to change implementation of parent function with child data?

I was wondering is it OK to change implementation of parent class with child class data. I have situation of creating a child class (form) which extends the parent class (other form with same elements)...
-1
votes
2answers
70 views

Swift inheritance versus composition

Say I'm using Parse Server and utilising the PFObject class from the iOS SDK. Say I want to have a Chat class. To use inheritance code (design 1): ...
3
votes
1answer
40 views

Emulating super() in Python 3.x using Python 2.7

Depending on the name of the first argument, self.__sup or cls.__sup behaves like super() in ...
1
vote
0answers
46 views

AWS Redshift wrapper class that automates similar types of loads from S3

I have a AWS Redshift wrapper class that automates similar types of loads from S3 for me, and I have recently adapted it to work for Spark jobs, which don't require a manifest, and instead need a ...
3
votes
1answer
81 views

Extending functionality of org.springframework.batch.item.file.transform.DefaultFieldSet

I would like to be able to set token values (defaultFieldSet.tokens) and names (defaultFieldSet.names) on ...
4
votes
2answers
147 views

Spell and cooldown system for an Unity game

So I have doubts about my code and if it is any good. I have a parent class Spell: ...
1
vote
0answers
63 views

Refactoring ValidationContext from inheritance into decorator

In one of my questions I used a ValidationContext class that looked like this: ...
2
votes
1answer
158 views

Pizza Delivery System

I have made this code as my summers vacation project in Turbo C++ (I know its old and outdated, but that's what they teach us in our school). The code allows users to order different pizzas and even ...
0
votes
1answer
229 views

Document (PDF, TXT, DOCX) to text classes

I wrote some classes to convert some documents (PDF, DOC, DOCX and TXT) to only text so that it can be stored in a search engine. Here's how I use those classes : ...
2
votes
3answers
152 views

Code Smell in Unit Testing Serialized Classes

I can feel that something is wrong with my code. Here's an excerpt where I think the code smell is... ...
0
votes
0answers
25 views

Class property holds data from database

I have a class, it has two properties: var fruitsPackId: Int var fruitsPackContent: Array<Fruit>? Once the class is ...
2
votes
1answer
81 views

Inheritence Cleanup

I have the following interface ...
2
votes
1answer
23 views

Draggable toolbar header class, inheriting from a draggable parent class

I have written a draggable parent class using a module pattern: ...
2
votes
1answer
135 views

Parsing a string containing arithmetic operations in prefix notation

This is a piece from the complete program. What it does is parses mathematical expressions of the form (+(*3,x),5) to 3*x + 5 ...
1
vote
1answer
52 views

JavaScript inheritance with super calls and mixins

I needed JavaScript inheritance that offered calling of overridden methods (super calls). Furthermore I needed a possibiliy to add behaviour to instances (mixins). Mixins should not only be full ...
4
votes
1answer
45 views

Random distributions in Go with inheritance

I am currently discovering Golang, and I try to implement some random variable generation functions similar to R functions. To avoid code repetition, I'd like to use inheritance, which is quite ...
1
vote
2answers
55 views

Class inheritance testing

I'm just messing around with class inheritance. I originally had a separate goal in mind but I ended up here, and my new goal was to have a parent that was completely ignorant of it's self, i.e. no ...
0
votes
2answers
116 views

File processor for text and HTML

I recently took a test. One of the questions was to find problems in the following code and suggest refactoring which can provide adding new formats of data: ...
6
votes
0answers
188 views

Recorder for keyboard and mouse events

I'm building an event recorder. So far the code looks clean, but I feel like I'm missing something that can make this code even better. Is composition a better solution? If yes, how can I do it ...
3
votes
0answers
125 views

Shape inheritance hierarchy

I have managed to build an inheritance hierarchy for shape class object and I am wondering if there is a better solution to combine the following 2 hierarchies. To begin, I have a 4 shapes classes ...
4
votes
3answers
250 views

Swing GUI in Java

I'm learning Java at the moment and I'm currently trying to make a GUI using Swing. I've done some reading and people usually prefer and advice to use composition instead of inheritance of e.g. ...
8
votes
1answer
209 views

Extending the functionality of lxml.etree

I wrote a class to slightly customize the behavior of lxml.etree.ElementTree and I use it quite extensively. It works great, but there are a few methods that I'm ...
3
votes
1answer
226 views

Object-oriented web scraping with Python

I usually write function-only Python programs, but have decided on an OOP approach (my first thereof) for my current program, a web-scraper. Here is the working code I wrote which I am looking to have ...
1
vote
1answer
120 views

Restricting types not related through inheritance without using instanceOf by creating own class hierarchy

Restricting types not related through inheritance without using instanceOf by creating own class hierarchy. It needs to interact with a key value data store, will ...
1
vote
0answers
831 views

Reusable REST service class for Angular2 in TypeScript

I am creating an Angular 2 web application using TypeScript. This application performs REST requests to a REST "service". For each REST resource in my service I create a separate "Service" class in ...
3
votes
0answers
107 views

Mortgage calculator in JavaScript

I'm learning JavaScript and decided to build this mortgage calculator as a starting point. For the most part it was reasonably straightforward, but when I implemented the graphs using D3 I found ...
3
votes
2answers
194 views

Follow up - Creating Inheritance hierarchy using function constructor

In continuation with this question, Animal class has four fields: name sound <...
8
votes
1answer
133 views

Creating Inheritance hierarchy using function constructor

Problem statement You need to create the Animal base class having four fields: a. name b. ...
3
votes
3answers
516 views

Logic Gate Simulator - Proper Encapsulation

So I was checking out the courses on InteractivePython, and I came across this example to demonstrate inheritance. My focus is on the Connector class and how it ...
1
vote
2answers
67 views

Adding new articles

Following is a working program to add new articles. The only thing I want is to check if there is any way to write it in a better way, or if the architecture is good as it is. Maybe I did not have to ...
2
votes
3answers
215 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 ...
3
votes
2answers
450 views

Creating n-dimensional mathematical vector classes through inheritance

Right now I have no knowledge of templates, but I just finished learning about inheritance, and wanted to apply it to a Vector3 class that I had already created. My ...
2
votes
1answer
216 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 ...