Questions tagged [class]

32818 questions
1

votes
0

answer
91

Views

How to use classes from other module in JSDoc annotations

Best explained with an example: some-class.js function SomeClass() { /* ... */ } SomeClass.prototype.doSomething = function() { /* ... */ }; export function createSomeClass() { return new SomeClass(); } index.js import { createSomeClass } from './some-class'; /** * @param {SomeClass} someClass */ f...
suamikim
1

votes
2

answer
68

Views

C++ best practices for running other programs from within 'main'

So I have a short program that has to run a few other programs and wait for them to complete. Currently I am doing this in my main method like this: // Connect to the service cout
Kevin Glasson
1

votes
1

answer
32

Views

Java Button not appearing on (GUI)

I've been figuring out a nice way to lay nice foundations when working on a somewhat bigger project than I have before. If i write everything in main it works fine. When doing classes like this the Frame works but the Button i've added doesn't wanna appear: //main package taxsystem; import java.awt....
Aspect
1

votes
0

answer
22

Views

How to prevent listview from refreshing automatically?

I'm creating a music player application for android. In my custom listview I have title,artist and album art. I'm using universal image loader to load album art in the imageview. The problem is listview is lagging while scrolling. In the logs I checked that listviewadapter is running again and again...
Mr Nobody
1

votes
1

answer
210

Views

Xamarin, Android, PCL SQLLite, SQLite.NET snafu

It's pretty hard to understand the nuget packages to install in a Xamrin solution when searching around the web, there are dozens of packages, dozens of different solutions. Right now, our solution has 2 projects, an Android one and a PCL one. Our model and data access is defined in the PCL. Our pla...
Nicolas Belley
1

votes
1

answer
336

Views

Django CreateView get_initial Foreign Key

I have a form and I am trying to use the get_initial method to set a foreign key. The model is class CardioRecord(models.Model): date_uploaded = models.DateField(auto_now=True) client = models.ForeignKey(User, on_delete=models.CASCADE) run_dist = models.FloatField(blank=True, null=True) run_time = m...
leelum1
1

votes
3

answer
36

Views

Delete one of two elements with same class

I have two HTML elements: Both have the same structure, class and attributes. How can I delete only one of them if I have two? (This is a bug) Thanks in advance.
Jose Peres
1

votes
3

answer
48

Views

Select Second child and attribute an ID - Javascript

How can I attribute an ID to the second gs-title? I try this, but doesn't work: var stopInterval = false; var interval = setInterval(function($Document) { if(!stopInterval) { $('div > gs-title:nth-child(2)').attr('id','pweb'); stopInterval = true; } else { clearInterval(interval); } },12000...
Jim A.
1

votes
0

answer
54

Views

Reduce class constraints in haskell and inspecting persistent tables

I'm trying to setup a basic endpoint which takes an id and goes through a join table to return all joined records using persistent and spock, a working implementation looks like this. get ('songs' var) $ \id -> do song Key a -> m (Entity a) getRecord404 k = do res Maybe (Entity a) -> ActionCtxT c...
SJH
1

votes
0

answer
24

Views

Cannot get next batch's embedding indexes

The first module minibatch. import numpy as np import tensorflow as tf import Utils.neighbor_samplers as samplers class Minibatch: def __init__(self, embedding, batch_size): self.embedding = embedding self.batch_idx = [i for i in range(self.embedding.shape[0])] self.batch_size = batch_size self.iter...
Ethan Song
1

votes
0

answer
33

Views

Create Hierarchical tree with nodes name as str

I need to create tree showing calculation of formula at each level. I receive data in as dictionaries level1={'Operating Cash Flow':['Total Revenue','Operating Expenses']} level2={'Total Revenue':['Net Income','Change in Asset'],'Operating Expenses':['Non Cash Expense','XYZ']} And So on. Idea i...
dgomzi
1

votes
1

answer
26

Views

MStest throwing errors for Class library using multiple config files [duplicate]

This question already has an answer here: Can a unit test project load the target application's app.config file? 10 answers I have created a class library MultipleConfigFiles, which has a method getConfigData. This method reads data from config files. public class Class1 { public string getConfi...
CrazyCoder
1

votes
1

answer
47

Views

Best practice on instantiating different types of the same es6 class

I am building an HTML5 Canvas 2d game and i have some es6 classes on my project. One of them is Obstacles. What i want to do is having the ability to create a different instance of this class depending on a given type (eg. small, thick, tall etc). What is the best way to do this? Just add another pa...
user2753348
1

votes
0

answer
166

Views

Uncaught ReferenceError: Imported Class is not defined

While extending from a parent class I get: Uncaught ReferenceError: Plottable is not defined Place.js: import {Plottable} from '../Plottable.js'; console.log(Plottable.word); export class Place extends Plottable {} Plottable.js: import {Place} from './Place/Place.js'; export class Plottable extends...
Henry Zhang
1

votes
0

answer
17

Views

How to correctly update an empty ete3.Tree object with a newick formatted tree string [Python]?

I'm creating a class that inherits from ete3.Tree. I want to add a newick formatted string to the object but I can't figure out the correct way to update the object. I want t2 below to be the same structure as t1 and by structure I mean to be the same as me build the t2 object like I did t1 but fr...
O.rka
1

votes
1

answer
239

Views

Room Abstract Pojo

I'm creating for fun an android application that tracks the spendings. I'm using Room to persist the user's data and I have POJOs that show the daily/weekly/monthly summaries. These classes are quite similar, thus I would like to have one abstract POJO that contains the fields and extensions of it...
xecto
1

votes
0

answer
32

Views

why is the class method called by instance and class not the same thing [duplicate]

This question already has an answer here: Is there a difference between “==” and “is”? 20 answers Why does id({}) == id({}) and id([]) == id([]) in CPython? 4 answers for start, let's define a class and instance of the class class c: @classmethod def m(cls, a): return a + 1 a = c() those m...
Superior
1

votes
1

answer
32

Views

Adding Element to Class Array with function. “Paint” in Processing 3

I'm trying to create a 'Paint' application with Processing 3, and I want to add buttons to change the color (later on for brushes, size, etc). I'm stuck because I'm keep getting a NullPointerException for adding the button to my array. (I know i could just ask for the mouseX and Y after creating ev...
Alex
1

votes
0

answer
36

Views

Updating object on Python < arcade library >

I'm currently coding in some assignment. I create a class named Ship and created some methods to make the object class ship be able to move. class Ship(): def __init__(self): self.center.x = 400 self.center.y = 300 self.velocity.dx = .25 self.velocity.dy = .25 def advance_down(self): self.center.y =...
SkylarR95
1

votes
2

answer
33

Views

hash of object included another object [closed]

hi I'm new in java and I need help please . if I have this programme public class block (){ public String hash . public String previous hash . public twotransaction data ; public int timestamp ; public block (twotransaction data ){ this.data=data; } } where class twotransaction : public class twotr...
Nancy Housseiny
1

votes
1

answer
76

Views

How to apply function to value defined in data class constructor before init method?

Let's say I have a data class like this: data class MyData(val something: Int, val somethingElse : String) { init { require(something > 20) { 'Something must be > 20' } require(StringUtils.isNotEmtpy(somethingElse)) { 'Something else cannot be blank' } } } I'd like to be able to apply a function to...
Johan
1

votes
1

answer
13

Views

Using the @property decorator for interrelated attributes within a Python class

This question relates to using the @property decorator within a class in Python. I want to create a class with two public attributes (say a and b). I also want the class to have a further public attribute (say c) that is always equal to some calculation based on the other attributes within the class...
Sam Brock
1

votes
0

answer
160

Views

robot.mouseMove not moving to a proper location with Video Evidence

This is one of the weirdest problems I have encountered in my programming. When I use the robot class to move my cursor, it wont move it to the proper location on the first try. It seems to 'lock in' and get closer each to time to the specified location. I attached a link below to a youtube video I...
Luke Darcy
1

votes
0

answer
41

Views

transformation into python class IndexError

I'm trying to turn a code into a python class. my dataframe 'URM' looks like : user_id anime_id user_rating 0 1 20 7.808497 1 3 20 8.000000 2 5 20 6.000000 3 6 20 7.808497 4 10 20 7.808497 I filter only 999users for computation reason. If i copy paste all that code below w...
user9176398
1

votes
1

answer
103

Views

How to implement websocket inside a class?

I'm trying to use websocket.WebSocketApp inside a class so I could later on use the data retrieved from the websocket: import requests from urlparse import (urlparse, parse_qs) import json import websocket class NeuroStream: def __init__(self, sensor, token): self._sensor = sensor self.token = token...
Rtucan
1

votes
0

answer
619

Views

How to build a es6 vue-component library using vue-class-component

I am trying to create a vuejs component library in typescript with vue-class-component and vue-property-decorator with the following requirements: The library components should be written in class-style typescript. The library components should be exported as es6 modules to allow treeshaking in the...
ShabbY
1

votes
1

answer
42

Views

Get one element from a variable with multiple elements

I'm (was) basically trying to get one specific element from a variable with multiple elements. Edit with answer, thanks to @pointy : var $item = $('.item'); var $activeItem = $item.filter('.active'); $activeItem.css('borderColor', 'red'); The objective was to use the variable $item. This code was si...
searrow
1

votes
4

answer
55

Views

Android: intent.putExtra() changes objects?

I want to pass myObject to the NewActivity class. For this I use the putExtra() and getExtras() methods from Intent. It appears however that the object changes somehow? I'm printing the object both before and after I pass it. Is this normal? I'm running into problems because I'm using myObject in a...
SJ19
1

votes
1

answer
40

Views

JS constructor class scope error

var bubbles; function setup() { createCanvas(600, 400); bubbles = new Bubble(); } function draw() { background(50); bubbles.displ(); bubbles.mov(); } class Bubble { constructor() { this.x = 200; this.y = 200; }; displ() { noFill(); stroke(255); strokeWeight(4); ellipse(this.x, this.y, 25, 25); }; mo...
andfra
1

votes
1

answer
25

Views

Python - how to move data from class (not instances) to database and link together?

I have many classes with class methods. All classes contain some additional 'metadata' that I want to move to the DB. I have no idea how to link classes with db entities. It's not a classical Object Relational Mapping, it's Class-With-Code Relational Mapping. Should I use class name + module name (...
Behoston
1

votes
1

answer
61

Views

Access class functions from d3 event handler

I'm trying to use es6 classes in a d3 app. I have an event handler bound to the 'drag' event, but I cannot access the class from within the event handler. this is my class when I manually call the handler, but when the event is triggered, this is the DOM element. Code: class Point { constructor(cro...
Jake Irvine
1

votes
0

answer
29

Views

A Cleaner way, how to refactor async call

I have the following endpoint @Patch('/games/:id') @HttpCode(200) async updateGame(@Param('id') id: number, @Body() update: Partial) { const updatedGame = await Game.findOne(id); if (!updatedGame){ throw new NotFoundError('HTTP 404 Not Found: No Games Here'); } else if (update.color !== validColor(...
newDev
1

votes
1

answer
52

Views

Convert xml string different objects

There are 3 classes like this public class Product { public string ProudctId { get; set; } public string ProductName { get; set; } } public class Owner { public string OwnerId { get; set; } public string OwnerName { get; set; } } public class Master { public string MasterId { get; set; } public stri...
Manish Dhariwal
1

votes
0

answer
24

Views

Scope of variables in circular dependent import modules

This question is to understand the scope of the variables(class variables) when the modules imported are circularly dependent. main_.py import a_ class MyClass: my_list = ['hello'] @classmethod def append_my_list(cls, item): if item not in cls.my_list: cls.my_list.append(item) if __name__ == '__main...
Sohn
1

votes
1

answer
47

Views

func Get<T:EVObject>(){}

public func _Delete(contentType:String,url:String,callback:@escaping (Bool,String)->Void){ let headers :Dictionary = ['Content-Type':contentType] Alamofire.request(url,method: .delete,headers: headers).validate(statusCode: 200.. in my function like _Delete function what my < T > should be? i cant d...
Mr Zee
1

votes
0

answer
48

Views

How to make class member NOT shared between threads (2 browser sessions)

I'm implementing a web application. I send 1 ajax request to call 1000+ api requests and save the result into a class member when it's finished. Meanwhile, I send another async request to poll if the request was finished then return result to browser. The problem is that class member is shared betw...
Jackie chen
1

votes
1

answer
399

Views

Object Memory Management Python Vs Java

Can some one explain on the way Python manages memory management during creation of an object in class. For example in java we can only declare member variables and the initialisation part happens inside the constructor. That means memory used when an object is constructed. But in python we can init...
Sabyasachi
1

votes
0

answer
25

Views

Validity test error when defining fields in a Reference Class

Context I've defined two RCs. The first is VectorCharacterElements. I've assigned a validity test to it. VectorCharacterElements
Joshua Daly
1

votes
0

answer
157

Views

Type mismatch: cannot convert from Son to Super

I'm making a Stratego game in java and I'm having a problem with one of the game pieces, which throws me the error: 'Type mismatch: cannot convert from General to Piece' I have all other pieces such as bomb scout, Marshall etc.. all defined and properly working, however, this gGeneral is giving me...
Rui Inacio
1

votes
2

answer
40

Views

Dynamically convert Base Class to Derived Class

For People that don't like to read a lot of Pseudo-Code: I want to dynamically convert a base class to a derived class based on a variable and then use this newly converted derived class without having to do heavy casting. Is this even possible and if so how can i accomplish it? What I'm trying to d...
PeterSinclair

View additional questions