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
2 answers

Android: What view to use for a image puzzle game?

I'm making a 3x3 image square puzzle game for android. I have my Level class which should contain all the Tile instances. (Tile is a subclass of android.widget.ImageView). My question is what kind of view should Level subclass? And how can I set the…
mrmclovin
  • 1,113
  • 3
  • 13
  • 35
1
vote
2 answers

Workaround for simple protocol inheriting conformance

In our app, we have a service that helps us decide which Modal UIVIewController should we present next. Every ModalVIewController has common function such as dismiss() but also a specific function it implements. So that's what we tried: The base…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
1
vote
3 answers

Java class with typearguments

I am having trouble using Type Arguments in Java Classes. I have one superclass named Game public abstract class Game implements Serializable { public Game(GameEnum game, Player player1, T player2) { this.timer = new…
1
vote
1 answer

Text Adventure in Python: Working with Classes and Inheritance

I'm fairly new to the idea of classes and subclasses in Python. I've found some questions/answers here on Stackoverflow related to my question, but they don't seem really answer the specifics that I am looking for. I consulted YouTube and other…
1
vote
3 answers

Importing a subclass where it is under a package: ModuleNotFoundError

./package/test.py is working smoothly. I am expecting ./test.py would work smoothly just like that, but I am getting this running ./test.py: Traceback (most recent call last): File "test.py", line 2, in from package.subclass import…
Sara Takaya
  • 298
  • 2
  • 17
1
vote
1 answer

Ruby inheritance - child instance has only parent attributes

it is my first time using Ruby subclass inheritence. I have a parent class A with an attribute "name:string", and a child class B < A with an attribute "bankname:string". When I use rails console to create a B instance (B.new) I get an object with…
1
vote
4 answers

Restricting access property in subclass

I have a class with a public property, that I want to restrict access to _for_some_modules_. (The modules that use this class reside in different assemblies, so internal does not help.) My first thought was to subclass, and make the derived property…
user736570
  • 469
  • 4
  • 15
1
vote
0 answers

How to have a subclass of DataFrame (pandas) and an automatically updating Widget (kivy) when the DF is changing?

It's about two, somehow connected problems. On the one hand it is about creating a proper subclass including a "change_DF"-method for pandas’ DataFrame (DF) object. (Prob1) On the other hand it is about using the on_{property} and ObjectProperty…
Clemens
  • 53
  • 6
1
vote
2 answers

Cocos2D: Subclassing sprite and animation as CCLayer is giving me trouble

I started experimenting with Cocos2D with Tiled, and had the player sprite and actions coded within a CCLayer along with everything else. Before continuing on, I wanted to subclass the player into a CCLayer, which I hope is correct. My header and…
Chewie The Chorkie
  • 4,896
  • 9
  • 46
  • 90
1
vote
1 answer

Make method of class using generics be able to return both its own and its subclasses instances

I implemented the following Java classes: public class Data { private List data; public List getData() { return this.data; } public Data setData(List data) { this.data = data; return this; …
Alex
  • 79
  • 1
  • 9
1
vote
4 answers

How do I access a pointer's subclass's methods if those methods are unique to the subclass?

A part of my program has two possible cases: (1) if the user only gives 2 command line arguments, take input from standard input (cin) (2) if the user gives 3 command line arguments (the last one being a file name), take input from the file. In…
Jon Doe
  • 167
  • 1
  • 11
1
vote
1 answer

Unmap inherited child property in parent-child subclass mapping

Is it possible to unmap a property inherited from a parent-child subclass mapping in Fluent Nhibernate set up for separate tables? Classes public class Parent { public int Id { get; set; } public string Name { get; set; } public int…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
1
vote
1 answer

I don't know to initialize my variable in the required init?(coder) method of my UIView subclass

I want to initialize the presenter attribute of my UIView subclass, I do it in my init method but I have the error "Property 'self.presenter' not initialized at super.init call" in the required init?(coder) method. I don't know how to initialize it…
achntrl
  • 23
  • 2
1
vote
1 answer

How do i make my UIImagePickerController auto rotate?

I tried to sub class the UIImagePickerController and return YES from shouldAutorotateToInterfaceOrientation But this didn't work
1
vote
0 answers

Python adding a subclass from a parent object at parent object creation

I'm using Python to communicate with with a hardware device. The communications protocol generally follow as such: {header bytes} {data bytes} {CRC bytes} ctypes works very well for the communication protocol because I can define things like: class…
user2654735
  • 323
  • 5
  • 19