Category "oop"

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

Creating interface in dart like typescript

I am from typescript background and new to dart, in typescript we are able to define interface and attach those types to the required variable which have the co

How can I call out a string from an object array?

I have recently started some OOP in C++, and I was trying to make a small program in Dev-C++ to store arrays of information on employees through a friends funct

Accessing other classes attributes in Python

I want to design specific class hierarchy consisting of three classes: Certificate, Organization, User. Both Certificate and Organization seem to me to be kinda

Making a namespace a friend of a class?

I'm trying to encapsulate the Allegro5 C++ library and I want to have a namespace of rendering functions. The problem is that in order to use the rendering func

How I could use template literals in javascript in a variable name?

I want to declare a variable name via template literals How it is possible ? let z = 3; let test`${z}` = "hello"; //or = new obj() for example console.log

Turning a function based sketch object oriented

I am trying to take Dan Shiffman's prime spiral program and make it object oriented. I am putting all variables into the constructor and making the functions in

Dart abstract factory method

I'm pulling table data from api in my application that I wrote with Flutter. According to the API used in the table data, different types of data are coming. I

Recursively creates dataclasses based in nested dictionary

I have a dataclass called Config that is created through the properties and values of a dictionary. Since this dictionary can have nested dictionaries, i would

How can the __init__ method accept objects and assign attributes if the attributes have not been created in the Constructor? [duplicate]

I am new to OOP in Python. As the title suggests, I am unsure as to how the __init__ method can assign attributes to an object of a given clas

Problems with ABC/Interfaces using pydantic + Mixins pattern

Im trying to implement Mixin patter while Im using Pydantics BaseClass to facilitate the instantiation and validation of data from my class. The problem is that

tkinter radio buttons are selected by default

I am using radio button selection to change a label widget in my window, I've just written this code to save myself having to write essentially the same thing f

OOP sobreencapsulation

Lately I've been learning something about blockchain and I decided to try to make one in c++, without libraries that were made specifically for that, just with

c++ Best practise when passing in arguments to functions [closed]

So I have read a lot of things about people saying const & is always good as it eliminates copying, and passing by value is a bad idea. Th

Inappropriate Intimacy in factory

My Factory has dependency on Repository. It calls many methods from Repository. Lets say something like this: class CarFactory { private Repository reposito