FAQ Database Discussion Community


Python: How to extend a class?

python,inheritance,extends
So, I really want to add on a few new methods to pandas.core.frame.DataFrames. For example, I want a method called .idx: pandas.core.frame.DataFrame.idx(self, rows, cols): return self.iloc[rows].loc[cols] Is this possible? I'm not sure what the syntax should be - the class already exists from a library, so I can't just put...

How to make a class extending a jLabel so that it appears as a JLabel in my main class?

java,class,jlabel,extends
So, essentially I'm making memory. I have a tile class, which at this point will only have a number, and a boolean (to show if it is flipped or not). I made duplicates of all the numbers as Tile objects and randomized them, and in turn added them to my...

how to resolve multiple inheritance

java,android,multiple-inheritance,extends
I am working in android.and when I am creating new project than By default it extends the ActionBarActivity.now I want to extends other activity that is List Activity and it is predefined activity in android,but we know that java doesn't support multiple inheritance. so how can i solve it because...

Extending in a package

java,package,extends
In the folder .....\testPackage I have a file Test.java: package testPackage; public class Test {} and another file OtherTest.java: package testPackage; public class OtherTest extends Test {} The second file won't compile, because it can't find the class Test. What am I doing wrong? EDIT: path\testPackage>javac Test.java path\testPackage>java Test Error:...

Why does this method call fail? (Generics & wildcards)

java,generics,extends
I am getting the below error: 'call(ContainsMonitor)' cannot invoke 'call(? extends webscout.Monitor)' in 'WebScoutCallable' Monitor.java WebScoutCallable<? extends Monitor> handler; public setCallable(WebScoutCallable<? extends Monitor> callable) { this.handler = callable; } WebScoutCallable.java public interface WebScoutCallable<T extends Monitor> { public void call(T caller); } ContainsMonitor.java public class ContainsMonitor extends Monitor { public void...

How can you force a class that implements a interface also extend an other class?

java,multithreading,interface,extends
Is it possible to make a class that implements my interface to automatically also extend another class? More specific I want my implementation always to be an extension of Thread. Or for that matter implementing Runnable, but public interface Name implements someInterface seems so wrong... public interface userValidTimer extends Thread...

access $this in extended class

php,class,oop,extends
I've been following a tutorial about OOP programming. And I got this class named User: class User { private $_db, $_data, $_sessionName, $_isLoggedIn; public function __construct($user = null) { $this->_db = DB::getInstance(); $this->_sessionName = Config::get('session/session_name'); if (!$user) { if (Session::exists($this->_sessionName)) { $user = Session::get($this->_sessionName); if ($this->find($user)) { $this->_isLoggedIn = true;...

Types in interfaces c#

java,c#,interface,extends
In java it's seems to be working if I have something like, but in the c# version: public interface MyIterator<T>: IEnumerator<T> { BaseClass<T> GetBaseClass(); } And : public interface IBaseClass<T>: IEnumerator<T>{ bool Remove(T e); IEnumerator<T> Search(T e); bool Contains(T e); bool IsEmpty(); int Size(); } But in the implementation I...

Extending an interface

java,interface,extends
I downloaded a code that has a function that starts like this: public class MDP<S, A extends Action> implements MarkovDecisionProcess<S, A> { //some code...blah blah blah... } S and A are supposed to be some kind of type. Action is an interface. In my code, I want to use the...

C++ equivalent of using for a java parameter/return type

java,c++,generics,extends
In java, to make a function that returns an object that is the same type as a parameter and extends a certain class, I would type: public <T extends MyClass> T foo(T bar) {...} Is there a C++ equivalent of this? In other words, how do I make a function...

Use Case: Almost same use case, different actors

uml,case,actor,extends,use
I have one use case "Transfer request" linked to two Actors (Analyst and Inspector). The scenario/exceptions/alternate flow are essentially the same, but for each actor the pre-conditions and post-conditions are different. The request has different states, and that final state and previous states differ depending on the actor that's calling...

PHP - Extends class modify protect parent

php,class,variable-assignment,extends
I created an extended class in order to modify a protected var for particular purpose. However I don't understand how I can modify a parent class protected var from a child class and use it everywhere in the parent functions. For example: class parent { protected $data; public function __construct()...

Can I embed a JavaFX Application class inside a JFrame?

java,swing,javafx,jframe,extends
I am making a 'Weather Station' application, and I am using JavaFX to plot a streamed graph. I want to know whether I can place the graph inside a JFrame along with other components I wish to have displayed and, if so, how. The class I want inside the JFrame...

Java: Extending ArrayList Using Objects

java,object,arraylist,extends
I'm extending ArrayList (not implementing an interface) in Java. I get an error in the function: public void push(Object o) { add(o); } It says "The method add(E) in the type ArrayList< E > is not applicable for the arguments. How can I fix this?...

What's the purpose of InterruptibleChannel interface extends Channel interface in Java?

java,inheritance,interface,extends
I know it sounds like a dumb question. But since InterruptibleChannel only declare one method: void close() throws IOException which is the same name/signature in Channel interface. What is the purpose of such interface inheritance ? Is this for reflection purpose in Java runtime?...

Inheritance classes (Java), explicit constructor error message

java,inheritance,compilation,extends
so I am trying to learn about inheritance classes. First I created a class called Box to calculate the area of the box. Then I created a TestBox Class in which I have created a box object called fedEx. Box Class: public class Box { private String boxName; public void...

Extending a package model

php,laravel-4,models,extends,extending-classes
I have installed Cmgmyr\Messenger, however, I need to extend the Thread model and potentially a couple of the others as my users table does not contain a name field. The method I need to extend is: /** * Generates a string of participant information * * @param null $userId *...

Is it possible to extend a final class in Java?

java,inheritance,final,extends
On possible duplicate: This thread is not asking how to extend a final class. It is asking why a class declared as final could possibly extend another class. From this thread: A final class is simply a class that can't be extended. However, I have a helper class which...

Custom android component

java,android,extends
I am trying to make a custom android component. For that reason I have make my class extend "View", but the class is already extending "BaseAdapter". The component should be something like this: http://www.brightec.co.uk/blog/android-listview-alphabet-scroller but it should appear in the Palette under the CustomView component. This is the class that...

Can I extend Iterator to allow access to encapsulated inner class fields?

java,iterator,abstract-class,inner-classes,extends
I'm frustrated, trying to add methods to a custom iterator. For an assignment in my second quarter Java class, we are supposed to implement, from scratch, a linked list. No problem: I have created an outer class to implement the linked list and a static private inner class to implement...

How to add dynamically extended element with Polymer?

javascript,polymer,extends
I've got button: <link rel="import" href="../bower_components/polymer/polymer.html"> <link rel="import" href="../bower_components/core-input/core-input.html"> <polymer-element name="count-button" extends="button" on-click="increment"> <template> <content>Increment: </content> </template> <script> Polymer({ counter: 0, increment: function(e, detail, sender) { this.counter++; alert(this.counter); } }) </script> </polymer-element> I successfully use it in html by: <button...

Collection vs Collection

java,syntax,extends
After trying to understand the concepts at Spring MVC, I came across the expression Collection<? extends Book> which I have never seen before. I have tried to figure it out on my own, but I am seeing no difference between using Collection<? extends Book> and Collection<Book>. I was guessing that...

A Fundamental Query about Inheritance using two classes in Java

java,inheritance,extends
Kindly consider the following code in Java: class a { int i = 10; int j = 20; } class b extends a { int i = 100; int j = 200; } public class Test { public static void main(String args[]) { a a1 = new a(); b b1...