Questions tagged [polymorphism] (19)

3
answers

Is there a polymorphism in languages with dynamic typing?

Is there a polymorphism in python? If there is something in what form is it expressed? For example, statically typed languages - it is clear why you need it.
Mohammad_Wilkinson20 asked April 18th 20 at 12:19
1
answer

In my example, there is a polymorphism?

class A(): def __init__(): pass def cprint(): print("A") class B(): def __init__(): pass def cprint(): print("B") class C(): def __init__(): pass def cprint(): print("C") obj_list = [A, B, C] for obj in obj_list: obj.cprint()
Ashleigh_R asked April 16th 20 at 11:17
3
answers

How to understand what type of object?

I can not understand one point of polymorphism. It can be represented in the form of the game. Let's say we have the types of game characters that inherit from the generic type Hero. class Hero { } class Hero extends Hero1 { } class Hero2 extends Hero { } Hero3 class extends Hero { } class Hero4 extends Hero { } c...
elwyn_Wol asked April 7th 20 at 09:00
1
answer

What is the difference between override (override), from the overlap of (new) inherited method?

Good day! Condition: I have parent and child from him the methods I need to modify the functionality of an inherited method, which may use or override the existing method, or to override the original new.Questions How can you visualize these approaches? Override - crossed out and written over, but New ? When to use override...
aileen_Jerde asked March 19th 20 at 08:34
1
answer

Is it possible in a descendant class to override the method with new parameters?

Good day! Trying to figure out the details of the PLO. A simple example. There is an abstract class Layer:public abstract class Layer: ICreatable { float[,] Heights { get; set; } public abstract void Create(); } The interface that it implements, is also simple:interface ICreatable { void Create(); } I want to create a cl...
Elissa asked March 16th 20 at 21:28
8
answers

Matrix polymorphism?

Colleagues, good afternoon. Arose the architectural task, which is not immediately mastered. So, in the application there is a processing of the data depending on two parameters(m, n). Depending on the combination of parameters can be performed some action, sometimes the same, for different settings, sometimes different. T...
Jared.Johns asked October 3rd 19 at 17:15
2
answers

Couple of stupid questions on polymorphism and inheritance?

Why you need to write IList list = new list() , but not List List = new List() ? I understand why need a interface in a General sense, but do not understand why it should be used in this situation. What happens in this situation, the Base A = new Derived()? And how it differs from the Derived B = new Derived()?
Hoyt_Balistreri24 asked October 2nd 19 at 21:04
1
answer

Does polymorphism when calling methods inside the superclass?

Question about this, there is a superclasspublic class SuperClass { //... public void method0(){ /*Call this block of code A*/} public void method1(){ this.method0() }; //... } And inherit from it class public class SubClass extends SuperClass { //... @Override public void method0(){ /*And the B*/} //... } What code will be...
Eri asked September 26th 19 at 15:25
2
answers

How to organize the code using OOP for simple tasks?

Given the task. Apply all the OOP principles in the code of the game "Minesweeper". Game written, created two classes: "Box", where all the logic is processed, and the class "Game" where the client invokes the necessary methods and gets results. Objects are present, encapsulation, but inheritance and polymorphism do not kno...
Veda_DuBuq asked September 26th 19 at 05:50
1
answer

How to use polymorphically annotation One-to-Any, Many-to-Any in hibernate?

Help with the example using annotation @Many-to-Any, @One-to-Any. there is very little information on the Internet, and to take advantage of such a simple solution - damn nice. task. HumanUnits -id -data MachineUnits -id -anotherData UnitTable -id One-to-any (HumanUnit.id or MachineUnit.id) guided by examples from the Int...
monserrate_Rippin65 asked September 24th 19 at 12:44