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
1 answer

Get subclassed navigationController of current ViewController

I have a setup, where I subclassed UINavigationController to add a property holding a reference to another ViewController class NavControllerWithReference: UINavigationController { public var referenceToOtherVC: OtherVC? } Now when I am in…
Pauli
  • 343
  • 1
  • 4
  • 17
1
vote
1 answer

How to access a parent class attribute without breaking data encapsulation?

In the 1994 book Design Patterns: Elements of Reusable Object-Oriented Software by the "Gang of Four", I noticed in the C++ code examples that all methods are either declared as public or protected (never as private) and that all attributes are…
Géry Ogam
  • 6,336
  • 4
  • 38
  • 67
1
vote
2 answers

How access event listeners of an object instantiated on runtime in java swing

I have a custom made JPanel itemSmallCard(String prodID, String productName, String price, String retailer), using this I created multiple instances of it in another JPanel with different parameters on the ActionPerformed event of a button as…
Aditya
  • 126
  • 9
1
vote
2 answers

How should I add teacher to new course, while creating it?

I have Course class public class Course implements Comparable { private String nazwa; private Integer lata; private Teacher teacher; private Student[] students; public Course (String name, int years, int maxStudents, Teacher teacher) { …
G. Dawid
  • 162
  • 1
  • 11
1
vote
3 answers

iphone protocol problem

I am missing something here, where I have a class, EditableCell, and protocol, EditableCellDelegate, defined for handling a table cell for editing. (The original code comes from "iPhone for Programmers" by Paul Deitel). While I have imported the…
Jim
  • 5,940
  • 9
  • 44
  • 91
1
vote
0 answers

UIButton as subview: How to add an IBAction

I have a subclassed UIView, which is @IBInspectable and add a UIButton as a subview. In Interface Builder, I can of course only see the UIView but not the subview UIButton. How can I add an IBAction for the UIButton, or be able to define in…
Pauli
  • 343
  • 1
  • 4
  • 17
1
vote
1 answer

Overriding of CorpusView.read_block() not taken into account

I want to process a bunch of text files using NLTK, splitting them on a particular keyword. I am therefore trying to "subclass StreamBackedCorpusView, and override the read_block() method", as suggested by the documentation. class…
Skippy le Grand Gourou
  • 6,976
  • 4
  • 60
  • 76
1
vote
1 answer

Arraylist with 2 constructors from subclasses

I am trying to create a simple GUI with Java. I have an Arraylist executed like this: private List vehicles = new Arraylist<>(); Im trying to pass in a subclass object with more parameters than the superclass. I have tried Casting it and…
matijap
  • 59
  • 9
1
vote
0 answers

How to make [ ] return list-derived subclass and not usual list class

I am trying to create a class derived from list so that it can have size and some other functions with following code: class Mylist(list): def size(self): return len(self) I can add other function similar to above. I can create Mylist…
rnso
  • 23,686
  • 25
  • 112
  • 234
1
vote
1 answer

Repeat a threaded timer with a start delay

I've been using the code from another solution which works well but I would like to add some functionality. The following class creates a threaded timer that starts immediately after the start method is called. I would like the timer to wait some…
Geoff D
  • 369
  • 4
  • 14
1
vote
1 answer

How to use @Autowired in subclass for field defined in base class?

Is it possible to autowire an instance in a subclass for a field which is fdefined in the base class? So, The interface: public interface Xyz { ...} The abstract base class: public abstract class Abc { Xyz xyz; } The subclass(es) of the…
du-it
  • 2,561
  • 8
  • 42
  • 80
1
vote
0 answers

Subclassing in relational database

What is it called in a relational database when you have a class or entity which has multiple sub-classes? That is not a very clear question so let me give an example. In my database i have a table called Vehicle I also have a table called…
teebagz
  • 656
  • 1
  • 4
  • 26
1
vote
1 answer

Declaring object of subclass

Im trying to create a instance of the subclass ''smycken'' but it does not seem to work as ''namn'' in the parameter gets an error. public abstract class Värdesaker { String namn; double värde; double moms = 1.25; public static…
1
vote
1 answer

Casting a Super Class in to a Sub Class

I have a class that looks like: public class MySuperClass { public void PrintValue() { print("SUPER Class"); } } I then have another class that looks like: public class MySubClass : MySuperClass { public void PrintSubValue() { …
Jack_Hu
  • 857
  • 6
  • 17
1
vote
4 answers

Some trouble with inner class visibility

I'm facing java inner class and I'm having some trouble with outer variables visibility. class A { private int x = 5; class B extends A{ public void fun(B b){ b.x = 10; //here } } } Why I can't do something…
Diablo3000
  • 67
  • 2
  • 8
1 2 3
99
100