Questions tagged [subclass]

A subclass is a class that derives or inherits from a parent (or super) class. Subclassing is used extensively in object-oriented programming (OOP).

A subclass is any class that inherits from a parent (or super/base) class. Depending on the language, a subclass will have a subset of the attributes and methods of the (parent/base) class from which it inherits. As a result, it is important to always tag a question with the language being used when tagging it with this tag

4137 questions
1
vote
0 answers

Wrapping numpy slices using super().take in narray subclass

I am attempting to subclass a numpy array in order to create arrays that have periodic boundary conditions. I only need this to work for 1D arrays. What I Want: Suppose I have an object a=Periodic_Grid([0,1,2,3,4,5,6,7,8,9]). I would like the…
gabe
  • 193
  • 1
  • 10
1
vote
1 answer

Custom ConstraintLayout class can't seem to lay things out horizontally - Android - Kotlin

I am trying to subclass ConstraintLayout to build a dynamic menu that I can pass in items and it will build a View with sub-views set up. I seem to be struggling with, in Kotlin, laying out things horizontally I've tried a few things, I've tried…
1
vote
1 answer

UILabel text truncating with wrong alignment when I add an imageView

I have a subclassed UILabel that I am going to be using for about 10 different labels of varying length (all on 1 line!) in IB. The text within each of these labels are static. This subclassed UILabel should display an imageView to the left of the…
Joe
  • 3,772
  • 3
  • 33
  • 64
1
vote
2 answers

Using interface implemented by subclass from a superclass collection without instanceof

I'm coding a little 2D game, all the game elements are subclasses of GameObject. The class Game has a collection of GameObject. My problem is, when the player performs an action, I go through the collection of GameObject to find what's in front of…
niboro14
  • 13
  • 3
1
vote
1 answer

Observe text in subclass of UITextView

I want to observe the var text! property of UITextView, I do not want to use a delegate. My solution is this: class MessageTextView: UITextView { override var text: String! { didSet { print(text) } } } But it does…
PaFi
  • 888
  • 1
  • 9
  • 24
1
vote
2 answers

objective c subclass UIImageView

I'm trying to subclass UIImageView to add some custom functionality in it. I started trying to do the basics, just init an object with a given image and display it on the screen. Using UIImageView everything works fine, but if i change my object…
CdB
  • 4,738
  • 7
  • 46
  • 69
1
vote
2 answers

Nhibernate/hibernate Avoid Insert in joined table or view

I have to join a entity with a view to retrieve some data into properties
Andreanta
  • 175
  • 1
  • 8
1
vote
2 answers

Redefine (override) methods in PyQt5 with uic.loadUI()

I'm actually developping a small soft using PyQt5 and QtDesigner since few weeks now. I've watched a lot of tutos and looked for many answers on SO but I can't find the one concerning the way to override a QWidget's method using uic.loadUI(). Note…
Nqsir
  • 829
  • 11
  • 19
1
vote
3 answers

Can I call a superclass sort with a subclass compare in perl?

I want to use a superclass sort which uses a subclass compare function. I've tried to distill the nature of the question in the following code. This isn't the "production" code, but is presented here for illustration. It's…
Erik Bennett
  • 1,049
  • 6
  • 15
1
vote
2 answers

How to add overloads to an existing API in PyQt

There is an existing class whose __init__() already takes a varying number & types for its arguments. I wish to subclass to add a new argument. I do not know how I am intended to write the subclass's new __init__() definition. I do not have the…
JonBrave
  • 4,045
  • 3
  • 38
  • 115
1
vote
1 answer

Is it possible to create a subclass which extends from another subclass?

I am still learning how to code java and had a question about how inheritance works. Class A is the parent class and Class B is the subclass which inherits all the methods from Class A. Suppose I create a third class, Class C. If I do Class C…
1
vote
2 answers

Accessing full dictionary when setting a nested dictionary item in Python

I'm trying to create a dictionary subclass which allows a dictionary A to be created which will update a value in a pre-exiting dictionary B to equal a string representation of dictionary A. I see it as an observer pattern, without the ability to…
1
vote
3 answers

Invoking different methods in python

Okay so I have the following: Class OwnableObject(MobileObject): def __init__(self, name): MobileObject.__init__(self, name) self.owner = None # not owned def is_ownable(self): return True def is_owned(self): return…
Scheme 2020
  • 111
  • 1
  • 4
1
vote
0 answers

Super constructor in cdef classes

I am working on wrapping a C library using cython. I would like to use a cdef class to wrap a simple struct. The struct does require some parameters to be properly initialized. I put the corresponding code int the __cinit__ method like so: cdef…
hfhc2
  • 4,182
  • 2
  • 27
  • 56
1
vote
1 answer

How to fix 'incompatible types: SomeObject cannot be converted to CAP#1' error in Java

I'm trying to make a game, in order not to write the same methods and functions, I'm using covariance and wildcards in Java to be able to re-use to code later for other type of (similar) games. My current problem is that I can't add a Piece to my…
TierTwo
  • 123
  • 2
  • 11
1 2 3
99
100