Category "oop"

inheritance TypeError: __init__() takes from 1 to 2 positional arguments but 8 were given

I am trying to follow an example related to inheritance from a Python OOP book. However, I am facing an error. from __future__ import annotations class Contact

I have some instances of a class and I pushed them into an array. Can I loop through the array and update the price of all the array objects?

I have a parent constructor like this: let list = []; class Pictures { constructor(price, title) { this.price = price; this.title = title;

How do I call the functions for when I create the character class - Python - This is for a quiz game but using a tree traversal

#here I want to define the self.__tree but I am not sure how to do so, how would I create the tree? oijh0ij0ihoihihoihou

How to use a class as a type in a variable with typescript?

I'm bit confused in how to use OOP in typescript. I'm used to do it with PHP. 1 - Can I use a class as a type without having to fill all attributes values? 2 -

Object Oriented Programming - Inheritance C++, Code does not compile

Source Code #include <iostream> using namespace std; class A { private: long int a; public: long int b,x; void s

How can I use classes for python turtle to define a position? error message - TypeError: turtle.Vec2D() argument after * must be an iterable, not int

This is the code import turtle from turtle import * class character:

JavaScript: Best way to add custom properties/methods to built-in objects (e.g. arrays)

It is known that you should not customize the built-in prototypes in JavaScript. But, what is the best way to add custom properties/methods to specific instance

Object() vs. Function()

It is my understanding that pretty much everything in JS is an object and that constructors are one way to make a new object. I know that data types like Array,

Diamond problem with constructor - Python

I have a problem with the constructor of the WorkingStudent class: class Person: def __init__ (self, firstName, lastName): self.firstName = firstNam

How can an object reference in java hold the reference to a primitive double dimensional int array [duplicate]

I have a piece of code- public class Sudoku { static int[][] game; public static void main(String[] args) { int [][] games= n

Infer type from subclass method return type

I'm trying to infer a type from the returned type of a subclass method. So far I haven't been able to make this work without making Parent a generic class (whic

How to add items to array of objects using loops

I've got a multiple student objects I want to write into with a CSV file containing their details. I've set each row of the CSV file to an array then was going

Creating classes dynamically in python [duplicate]

Is it a good coding practice to have the class name as variable. E.g def create_class(class_name): class class_name: def __init__(self

This is confusing, is there any tips so I can understand this better? (OOP Inheritances)

I am having difficulties understanding what to do here. Please bear with me I'm new to JavaScript and this section is giving me a hard time understanding how I

using methods of differents objects in pygame in a while True, chess project [duplicate]

I'm new to pygame, and OOP in python ( used a lot of java before) For a personal project, i'm trying to make a chess game, but I have a probl

Variable Declared Outside of For Loop Vs Inside

//assume there is a java class call Node, and node is an array of Node for(Node i: node){ Node j = i; } Node j; for(Node i: node){ j = i; } Can some

Rails helper doesn't have access to base class method

I've got helper which I'm including inside Create service class. This Create service inherits from Base class and I'm including ::Imports::HashFieldsBuilder to

In C#, when a variable passes through a function/method, will the original variable change?

I am confused by how a function can change a variable passed through it. For example, if I created a variable t = 1, and pass a function by adding 2 to it, insi

How overload < and [] operatot on Python

Recently OOP has moved from C++ to Python. I know the basics of the language more or less, but I had to work with OOP for the first time. The task is as follows

Recursively update nested object values for specific keys based on another object

*** UPDATED object structure *** I'd like to update recursively the property values of mainObject from the properties that exist in updatingObject. let mainObje