Questions tagged [class]

25706 questions
1

votes
2

answer
2.5k

Views

Calling GSL function inside a class in a shared library

I'm trying make a shared library in c++ implementing tools for Fermi gases. I'm using the GSL library to solve a function numerically and my code runs without a problem without when running as a script, but when trying to convert it to a shared library and classes I encounter problems. I've seen sim...
1

votes
2

answer
2.5k

Views

How to resolve groovy.lang.MissingMethodException?

How to resolve groovy.lang.MissingMethodException: No signature of method: methodMissing() is applicable for argument types: () values: []? In my project I have two plugins and I am getting this exception at start-up for one of the plugins (All the functionality of this plugin is fine) I've got the...
Ima Miri
1

votes
3

answer
3.3k

Views

Delete a Python object and make it point to None

Here is my class definition : class Playingsound: def ___init___(self): # blah def fadeout_and_stop(self): # do somthing (fadeout during 100 ms) del self Here is my problem (similar to that one : Python object deleting itself) : >>> a = Playingsound() >>> time.sleep (1.0) >>> a.fadeout_and_stop() >>...
Basj
1

votes
3

answer
1.1k

Views

Inheritance: Selecting which base class methods to inherit [closed]

I have a class Base and want to write a class Derive which inherits only some of the member functions from Base. Is there any convenient way to do this? For example, class Base { ... void fooA(); void fooB(); ... } I wish to define a class Derive which inherits all members except fooB from Base.
C. Wang
1

votes
4

answer
655

Views

Does Java call an abstract classe's constructor automatically?

Say I've made an abstract class called animal, and then I make a subclass called dogs which extends animal. The animal class has a constructor method written inside. If I decide to instantiate a "dog" object, will the animal classes's constructor automatically be called as well? If someone could cl...
Vimzy
1

votes
1

answer
456

Views

How to pass entity atribute value to form Symfony2?

I have a form type: $builder->add('paises', 'collection', array( 'options' => array('data_class' =>'Acc\ApssBundle\Entity\Pais'), 'prototype' => true, 'type' => new PaisType(), )) ; How to add attribute "name" to the class Pais to the label form ?? In twig I have: {% for pais in form.paises %} {{...
Alex
1

votes
1

answer
512

Views

Class variable losing scope on assignment

I have a question regarding class variable scope persistence on assignment. I have a dictionary as a class variablle, and as soon as I assign another dictionary to the variable in an instance method, the scope seems to be lost and values are not persisted between instances anymore. Here's the code...
haren
1

votes
2

answer
888

Views

Calling check internet connectivity class when clicking a button from another activity

What i have is an android application , i have an activity which check if internet connectivity exist or not and here it is : public class MainActivity extends Activity { private static final String LOG_TAG = "CheckNetworkStatus"; private NetworkChangeReceiver receiver; private boolean isConnected =...
sereen
1

votes
3

answer
11k

Views

Java (eclipse): How to call a int or string from another class in same project?

How can I use an int or string from another class in same project, for example, here we go with a class called Estadisticas: public class Estadisticas { public void stats() { final String c1 = "Tu personaje"; final int Nivel = 1; final int Salud = 50; final int Ataque = 2; final int Defensa = 1; fin...
Cristobal Ruiz
1

votes
2

answer
142

Views

Issue with Java and command line error

I'm new to programming and need help. Basically, I'm working exercises out of my class text book. I'm trying to execute a simple print line command. Here is the java file through NetBeans: package test; public class Test { public static void main(String[] args) { System.out.println("Test"); }...
Matthew Schmitt
1

votes
2

answer
65

Views

Declare and initialize in a method that has the same name as the class and data type

I am new to object oriented programming and I am trying to declare and initialize left, but I don't know how to do it. I tried left = new Counter(4, left.mod); But it Netbeans is saying that incompatible types: int cannot be converted to Number This is not the real program. public class Number{ pri...
eLg
1

votes
2

answer
44

Views

Final variables within anonymous classes

I have an anonymous class which takes the iterated value from a collection as shown below. With this code, is that immediate variable in preserved within anonymous class? Or different threads can take same in value? List list = new ArrayList(); for (int i = 1; i
vinayag
1

votes
2

answer
425

Views

What's the proper way to declare a field holding a function in dart?

Imagine a silly class like this: class ConditionalWorker{ var validityChecker= (inputs)=>true; ConditionalWorker(this.validityChecker) ... Now my question is, what is the proper way of declaring the validityChecker field? This tutorial suggests using typedefs. But that's not very practical. Firstly...
CarrKnight
1

votes
1

answer
1.7k

Views

Unittest.TestCase Method to Verify Arrays are of Equal Length

How do I pass variables declared from the python command line to the testcase instance? Edit: a and b are inputs to the method func(). a = [1,2,3] b = np.array([1,2]) Filename: code.py import unittest import numpy as np def func(a,b) c = a*b return (c) class TestCases(unittest.TestCase): def test_le...
MyopicVisage
1

votes
3

answer
722

Views

Inherit a class with same namespace and same class name

I manage to work it out in 2 Classes, but I failed in 3. Let's say I have an assembly A.DLL which have namespace = "City" and a class= "NY" (I will refer this class in my question as "A") In My new project My namespace is = "City" and I have a class = "NY" (I will refer this class in my question as...
1

votes
1

answer
371

Views

How to access fields of case class from JSP?

When I was a Java programmer my typical approach was to write a POJO with getters and access its fields in JSP through those getters ${pojo.field}. Now I'm trying to use Scala. Case classes looks like a good replacement for POJO's, but scala provides field() getters instead of getField() which is re...
Jofsey
1

votes
2

answer
474

Views

Map a JSON object to a Javascript class

I want to know the "good practice" to map a JSON object to a Javascript instance Class. My example is that I have a database of Cards in a JSON file. Each Card has several attributes. I have a Class Card that has the same attributes plus several methods. How to map the Cards in the JSON file into in...
Samuel
1

votes
2

answer
565

Views

Using local class in practice

When should we use local classes? The Best practice approach? Is it possible to make them abstract or static? Any other solution to avoid them?
Med Besbes
1

votes
1

answer
430

Views

Sorttable.js apply to all tables

The script below only applies to tables with the .sortable class. How can I make it apply to all tables? (Source) /* SortTable version 2 7th April 2007 Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ Instructions: Download this file Add to your HTML Add class="sortable" to any ta...
feacco
1

votes
1

answer
2.3k

Views

order of inheritance in Python classes

I have a class ExampleSim which inherets from base class Physics: class Physics(object): arg1 = 'arg1' def physics_method: print 'physics_method' class ExampleSim(Physics): print 'example physics sim' Imagine these classes containing lots of code. Now i have made some modifications to Physics by def...
nluigi
-1

votes
1

answer
27

Views

How would an instance variable be used in a class method?

Is there a way that in a class methods I can use an instance variable to perform a calculation? Very simplified, this is what I am attempting to do: class Test: def __init__(self, a): self.a = a @classmethod def calculate(cls, b): return self.a + b
callmeGuy
1

votes
1

answer
917

Views

How to create a custom method for my rails model

I have a Company model and a Payment model. For my Company model I whish to create a custom (class/instance?) method that performs a sumproduct of a selected company's associated attributes. My Company model: def total_payments self.payments.map { |s| s.value * s.currency }.sum end However if I ru...
Matthias
1

votes
2

answer
484

Views

java.lang.Class:ERROR while initializing log4j properties file in java program

I am trying to run a standalone java program using log4j, but receiving below while debugging (with no log4j related logs on console): log= {[email protected]} "java.lang.Class:ERROR in 18b4aac2" Can someone please suggest what is wrong here? The code is as below: import org.apache.logging.log4j.LogManage...
psg
1

votes
3

answer
982

Views

How do I call a method from another class component in React.js

So I have to class components: Class1: has a clickbutton Class2: has a method calling my api Basically, what I want is to call a method that sets and edits states inside one class from another class. But I keep failing. Example: Class1.js export class Class1 extends Component { render() { return ( )...
Cédric Bloem
0

votes
0

answer
25

Views

Call C++ class method stored in a DLL

When calling a class method that is loaded from a dll the 'this' pointer changes in my application when I call that function. In my example, the error happens at the line "if (Func2) return (*Func2)( s );" In the debugger the program finds Func2 in the DLL and I can step through Func2, but it's...
DuxburyDutch
0

votes
1

answer
23

Views

Is it a good idea to make composition member objects public?

I have a top-level class which instantiates sub modules using composition. The user knows that the top class will have these submodules. Is it a good idea to make the submodule objects public members so that the user can call their functions directly? The alternative seems to be to wrap their functi...
coderoo
0

votes
3

answer
18

Views

Align div class to left using style in html

How do I align a div class to left, center and right using style in the html itself. Here is my html code: code.....
user11066242
0

votes
0

answer
20

Views

Redefine Method In Class C++

I've been trying to create buttons for my new game in c++, and I have created a class for them holding data. I need to be able to allocate a method to each button click class. For example, let's say I have ten buttons, I need each one to output a different word when it is clicked. class button{ floa...
ProgrammerAdam
0

votes
0

answer
13

Views

How to analyze class diagrams? Where do you start?

How to analyze and describe the right class diagram? What class diagrams will be built, from the system features that the system can do? Or through the use case diagram whose use case has been defined? Or from sequence diagrams that represent objects?
Heri Prastio
0

votes
2

answer
19

Views

Inject class in other class

I've got a Tag class and a TagCollection class to store multiple tags. Now the TagRepository class needs to construct a new Tag object to return. But when I try to create a new Tag inside the TagRepository it returns an error: Tag is not defined This is how I include all the classes in the main Jav...
Schotsl
-1

votes
1

answer
38

Views

The “if” condition in “set” method isn't working

So which floor the lift is on should be able to be read and changed, but only within the allowed range for just that house the lift is installed in. I'm trying to get an "If" condition working looking for a boolean true value from method "validFloor". Based on my very beginner knowledge of Java, I a...
Jan cseng
2

votes
0

answer
43

Views

I don't understand why it is wrong to test for possible interfaces in a base class

I have an abstract base class that will be used in hundreds of derived classes, including an additional abstract class. There are at least 2 properties (let's call them Purpose and Description, both strings) that will be added to many (but not all) of the concrete derived classes, so I created inter...
DanK
0

votes
1

answer
22

Views

c#, force method implementation in child class

I have this setting: public class BaseElement { public BaseElement() { } public virtual void method01() { Console.WriteLine("class BaseElement method01"); } } public class Element01 : BaseElement { public Element01() { } public override void method01() { Console.WriteLine("class Element01 method01")...
manton
0

votes
0

answer
9

Views

What is the raw command-line to call a bazel built java program?

bazel built cpp/java programs and run them with a very complex bazel wrapper. I wish I don't rely on this kind of bazel wrapper, because I want a clean runtime/installation package. Here's a simple java example from my "BUILD" java_binary( name = "hello", srcs = ["src/main/java/com/demo/DemoRunner.j...
Hind Forsum
1

votes
1

answer
483

Views

R, R6, Get Full Class Name from R6Generator Object

In R6, How can I get the full list of class inheritances, without creating instances of the generator objects? Consider the following: A = R6::R6Class("Base",NULL) B = R6::R6Class("Top",inherit = A) class(B) #Returns 'R6ClassGenerator' B$classname #Returns 'Top' What I want is c('Top','Base','...
1

votes
1

answer
4.1k

Views

error: 'string' in namespace 'std' does not name a type

I have this 2 separated class and i cant fix this compiler problem: In file included from classA.cpp:2:0: classB.h:6:10: error: 'string' in namespace 'std' does not name a type std::string str; ^ In file included from classA.cpp:3:0: classA.h:6:25: warning: non-static data member initializers only...
BlackB0ltz
0

votes
1

answer
12

Views

Problem with the Property-Setter decorator: “private” attribute is not being setted

I am having serious dificulties finding out why my "Setter Decorator" from my custom Class (Data_Setter_Class) is not working properly. I found out that my "Private" Attribute (self.__Data) is not being properly setted by my Decorated Method (self.Data). Therefore, once I instanciate my "Data_Sett...
0

votes
0

answer
5

Views

How to extend php class to a class which ovverride it's functions

Alright, I have a structure like this: class Creature{ public function sayHi(){ echo "Hi"; } } class HumanType extends Creature(){ } class Human extends HumanType{ } class Human232 extends Human{ public function sayHi(){ echo "Hello, bro"; } } class Human457 extend Human{ } $Human = new Human232($id...
Stever
0

votes
1

answer
22

Views

Declare 2D array of different object types depending on if else (or switch) c#

I am working with matrix and have problem how correctly initialize different 2D array of objects, when their type depends on condition (if else). If I declare matrix and its type before if else, then i can't declare different types inside. If I declare it in if else, it doesn't exist outside of scop...
Tomáš Krechler
0

votes
0

answer
4

Views

how does system bundle has access to system packages?

I'm exploring how OSGI is implemented for the last couple of weeks. I know that each bundle uses its own class loader to load its classes. As part of my investigation, I understood that parent of every bundle's class loader is null i.e boot class loader. System.out.println("ClassInBundle class is lo...
Anilkumar Vemula

View additional questions