Category "oop"

Creating a list from the class attributes - Python

I was wondering if someone could elaborate on exactly why creating a new list out of the two attributes passed in the class returns a "NoneType"? class Finance:

TypeError: 'int' object is not iterable - When trying to convert a string to a list

My code is as follows down below. However the x that I input into this function is not int data type, it should be a string. The other code will show you where

What is a "free object"?

Source: https://refactoring.guru/design-patterns/factory-method I was wondering what the exact definition of a "free object" was in below context, and what free

Tuple return dynamic in c# while passing parameter as dynamic

As per the image showing CheckDynamic has two methods which has different return type but still allow to return from one to another and allowing to build. Shoul

Exception Handling using a Constructor (JAVA)

I'm currently working on a project in which I am to ask the user to input 2 numbers, divide them, and then throw an exception if the denominator is 0. I feel li

Tkinter object-oriented file dialog?

The following code displays a file dialog, returning a file_path string that I may then use to, for example, import a csv directly into a pandas dataframe. util

compilation problem while trying to iterate a class of ArrayList<Obj>

I have a class to generate an Arraylist it all seems to work but in main it produces a compilation problem which I guess does not recognize my variable name as

trying to figure these project errors

I'm stuck in my project, tried about anything, but can't solve this, getting errors, and testers are not working as well. airport class is the one making troubl

Intercept specific function invocations using parent/child classes?

I am writing a framework that allows us to intercept certain function invocations so that we can manage them(enforce timeouts and retries, persist return

What is the correct OOP way to add functionality to a set of classes deriving from an abstract base class?

Setting My friend told me that in OOP, you generally don't want to modify any abstract base classes in an existing codebase, because that means you have to impl

Method returns NoneType object

Classes and Objects in Python I'm creating a bot in discord.py, and I have a class which stores all the information related to the user, like name, settings, pr

How to apply seperation in one service for multiple tasks?

I have a service method that does so many things. public Result DoSomething(){ var queryResult = service.GetResult(); SaveResultToRedis(queryResult

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,