Questions tagged [oop]

0 votes
1 replies
Generic way to access class properties
I have been trying to read the value from the excel sheet, map it into a dataTable and then map the value to its class in C# using reflection. Th...
asked 4 months ago
1 votes
1 replies
How can I reuse functions across classes
I have a few functions I'd like to reuse. This isn't my EXACT example but it is functionally similar. For example, we'll say I have a bunch of p...
asked 4 months ago
-1 votes
1 replies
How to fix “name 'self' is not defined” error in python?
I'm trying to learn python OOP, I am stuck with the error below. Exception has occurred: NameError name 'self' is not defined File "/home/khal...
asked 4 months ago
-3 votes
0 replies
Uncaught Error: Call to undefined method Shop::setOpeningTime() [closed]
There is a problem in my code but I do not know what the it is. my code: <?php class Shop{ public $name; public $openTime; pub...
asked 4 months ago
0 votes
0 replies
I want to reverse a char array and print the reversed word as an array [duplicate]
In Java, arrays don't override toString(), so if you try to print one directly, you get the className + @ + the hex of the hashCode of the array,...
asked 4 months ago
0 votes
0 replies
How to call a class which is responsible to implement business logic and return a result?
This might sound a silly question, and maybe it is so, but not being a native English speaker and not having found so far a good alternative, I a...
asked 4 months ago
-1 votes
0 replies
Python OOP using Class and GUI [duplicate]
This question already has an answer here: Variable scopes in python classes 4 an...
asked 4 months ago
3 votes
2 replies
Method of a superclass is not being inherited by a subclass
I'm following book about object oriented Python and I stumbled upon code that quite doesn't make sense to me: class Property: def __init__(...
asked 4 months ago
0 votes
2 replies
In Python, changing inherited behavior without rewriting the parent class
In Python, I have a class ParentClass. It defines method ParentClass.process(), among the others. ParentClass is inherited by two child classes:...
asked 4 months ago
3 votes
2 replies
How to correctly implement a generic interface in Java
I apologize if this comes off as someone simply turning to stack overflow or if it sounds too easy. I've been stuck on this problem all day and a...
asked 4 months ago
0 votes
1 replies
Printing objects from one class with another class Python
I wrote a simple object oriented code with python. In first class named A I used __str__ so that I can print my objects. In another class I put t...
asked 4 months ago
1 votes
1 replies
Return middleware in class
I have a class with middleware function, which I want to return. In middleware I want to use this statement, but now it is just undefined. Class...
asked 4 months ago
0 votes
2 replies
Dynamically change a given class in the heritage tree and replace it with another one and initialize it
I am currently working on a library. I would like to write a wrapper that modifies a class (Mean in the example) in the inheritance tree by a ne...
0 votes
1 replies
Which SOLID and modern OO principles will be affected, and how, if we remove adherence to separation of concerns?
Say I break the principle of Separation of Concerns (SoC) and deliberately write, plan, and design my code to break, avoid and go against the SoC...
-1 votes
1 replies
How to store child classes in vector and override parent function
I am trying to code the js super-mario-series from the great YouTube channel "meth meth method" in c++ and SDL2. Now I am stuck on Episode 04 -...
asked 4 months ago
-1 votes
0 replies
Change a method in a parent class from the child class
I would like to change a method in a parent class from the child class. Example: class parent: def a(self): self.b() def b(...
asked 4 months ago
1 votes
1 replies
How did it achieve multiple inheritance before java 8 when there are same method signatures in interfaces
We know that if we want to achieve multiple inheritance in java we can use interfaces. If a class implements two interfaces which have the same m...
asked 4 months ago
1 votes
1 replies
Why string type is not being accepted if it was expected?
I am trying to create and use a stack object (modified to have strings) from here: let s = object val mutable v = [""; ""] method pop...
asked 4 months ago
0 votes
1 replies
Templates vs Polymorphism
I'm writing a library for genetic algorithms/neuroevolution. Currently, the program uses polymorphism to allow multiple types of genomes. So my c...
asked 4 months ago
-1 votes
1 replies
I have a small problem understanding how objects choose what methods to take when there's inheritance
Doing some homework and found out a small problem i cant understand Basically second line of C and D are A.f(double=...) and i dont understand wh...
asked 4 months ago
0 votes
0 replies
C++ How to create two classes where one is a member of the other and viceversa [duplicate]
I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made b...
asked 4 months ago
0 votes
0 replies
parse json data and get the schema of one record from the data
I have a sample json { "id": 1, "type": "deemed", "University": { "student": [{ "id": 10, "...
asked 4 months ago
1 votes
1 replies
How do I implement a Player Interface for my game?
I have just implemented a player interface in order to make my program more object oriented. The game has a computer player and a human player, b...
asked 4 months ago
0 votes
0 replies
How to instantiate different object for each row in dataframe column
I would like to fill a pandas dataframe column with different object instantiations of the same class. I am using datasketch MinhashLSH to compa...
asked 4 months ago
0 votes
0 replies
Constructors with different scopes
In Windev, is it possible to declare multiple constructors with different scopes? Seems not. For example: PROCEDURE CONSTRUCTOR (param1, param2...
asked 4 months ago