Questions tagged [object-oriented]

Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.

Filter by
Sorted by
Tagged with
0
votes
0answers
4 views

C++ Calendar Alignment

Here is what it should look like I am having trouble aligning the first day of the month with the right weekday. The calendar is going to be for this year so January first will be on Friday but I cant ...
3
votes
0answers
116 views

VBA class managing loading DLL libraries

I am playing with a custom-built SQLite library intending to access it from VBA via the C-language API. I keep the library within the project folder, so I load it via the LoadLibrary API. To make the ...
1
vote
1answer
50 views

Learning Javascript OOP with a Collapsing Item Class

I'm trying to get into object oriented javascript programming. I have written a class for collapsible elements as a test. These elements all have a certain class and no matter how many elements there ...
1
vote
1answer
60 views

Predeclared class instance tracks the number of regular instances

Predeclared class instance tracks the number of regular instances In VBA, predeclared class instances can act as object factories, and in general, it makes sense to keep this instance stateless. ...
1
vote
0answers
28 views

Resolving circular references in VBA via ObjectStore class and CleanUp cascade

Resolving circular references in VBA via ObjectStore class and CleanUp cascade I have been working on a VBA database library and realized I had a few circular reference loops in my class hierarchy, as ...
14
votes
4answers
1k views

Numerical integration in C++: Newton-Cotes formulas

I have tried my hand with implementing simple quadrature formulas in C++. Definite integral: $$\int_a^b f(x) dx$$ Domain of integration \$[a, b]\$ divided into \$n\$ intervals of equal length \$h = (b ...
3
votes
2answers
132 views

TicTacToe Objects calisthenics OOP

I'm learning Objects calisthenics and I was practicing with the typical Tic Tac Toe game, I was wondering if you could gimme feedback about my mistakes (Algorithmic problems, logic, and especially OOP ...
0
votes
0answers
71 views

Thinking about the efficiency of my chess program [closed]

I am currently working on a chess console app. However i feel like i got some inefficient code. For example: In order to find out whether an enemy is in check I start iteration over all pieces and all ...
2
votes
2answers
78 views

Fractions in C++

I started learning classes and operator overloading in C++. To test my skills I decided to make a Fraction class with all necessary operations. I would appreciate improvements and suggesstions on my ...
2
votes
2answers
65 views

Setting instance variable for salary bonus based on academic position

I have a class Scholar which is basically a teacher in a university. I have to calculate the yearly salary of a scholar instance where the formula is ...
7
votes
2answers
96 views

Connect to MYSQL database in PHP with prepared statements

I have recently learned about using PDO. I created a db class which could handle common actions like create, update, delete and select. Is this method a correct way to connect to the database using ...
2
votes
1answer
94 views

Builiding a Model from Stored Procedures

After reading that Data Classes can be considered a code smell, I am shifting from a pattern with many data classes and a single manager class that handles all the instantiation of the classes, to a ...
7
votes
3answers
4k views

Enum usage to restrict class attribute values

I am using enums in python3 for the first time but unsure if I am using them correctly. I want to restrict the 'allowed values' for a class attribute ...
2
votes
1answer
79 views

Evaluating postfix expression on multidigit numbers

This is my solution for evaluating postfix expression using a stack. It does work on multidigit numbers, the problem I was struggling with last time. Now it works completely fine. This is the stack ...
10
votes
2answers
2k views

Is my PHP login system following best practices? Is the code really OOP?

I'm learning about OOP and putting my knowledge into practice. I created a login system in PHP, so I wish someone could tell me if I'm on the right track. I feel like I'm getting better at coding, but ...
2
votes
2answers
101 views

Router and solid principle

I would like to know if my Routing system respects the solid principle ? The system is simple, Router class contains the routes and returns the correct route and Route class represents a route, ...
1
vote
2answers
105 views

Card deck for Blackjack in an OOP style [closed]

So far I have made a class called Deck, to create and shuffle a deck of cards, and a class called Player, which I want to use to create the gambler and the dealer. My Player class inherits from the ...
2
votes
1answer
85 views

Simple Lagrange interpolation

I wrote a Lagrange polynomial interpolation class. It works fine. At the beginning some definitions: $$ \begin{align} &nodes:\qquad x_0, \dots, x_n \\ &values:\qquad f(x_0), \dots, f(x_n) \\ &...
0
votes
0answers
34 views

Implementing a programming language with objected-oriented programming in EcmaScript 6

I am trying to implement the Dis language as a webpage in order to reproduce Dis programs for code golfing easily on browser. Since a famous online environment tio.run is not accepting new languages, ...
1
vote
2answers
49 views

optimization csv from url analyzer

I was messing around with the csv package and I tried to implement a class that returns csv objects whenever I need to open a csv file directly from a url(and occasionally prints out something).I am ...
4
votes
1answer
109 views

Class to build and execute dynamic SQL statements

I'm uncertain about proper OOP design since my teachers are explaining OOP very vaguely. Do I need to use the constructor and the mutators like this or am I better off removing the constructor and ...
1
vote
0answers
22 views

Android Kotlin: Main Concept: Nested RecyclerView Handling Clicks; Secondary Concept: Appropriate use of OOP concepts

Brief Background: I just started learning Android Development recently. I have some experience with programming and understand the basics of OOP but am not confident that I am using principles of OOP ...
0
votes
1answer
38 views

React code that controls user permissions

I have this code that controls the user permissions provided to a user. In my case, I constructed a simple example of CRUD. When the admin checks the boxes, it will grant the user access to perform ...
1
vote
1answer
81 views

Simple State Machine and Transition Table

The goal is to have well defined state transitions, and the ability to provide the next event to execute. I'd like to know if this is a proper implementation of State Machine, considering how states ...
7
votes
7answers
2k views

DnD Die in Java with regex

For my game I need to roll some values with a die. A die is formally described as: nDs[+a] n amount of die (optional, 1 of not set, zero must be set explicitly) D ...
6
votes
2answers
207 views

ASCII-based OOP blackjack game in Python

I'm new to programming and have been teaching myself to code for about 6 months. Since I have no one to ask about any of coding-related questions, I may have developed bad habits in the meantime, but ...
4
votes
1answer
95 views

Code to scan filesystem, store every path into sqlite and update only when something has changed

I have made a program that does what the title explains. It also hashes the file to check for changes. I will be doing this for a project to keep track of files that has been changed when doing ...
0
votes
1answer
34 views

Stream that computes running median value

I was solving a DSA question, running median in a stream. And I decided to design my own stream class with additional features. ...
13
votes
1answer
37k views

Python class initialize with dict

how can I express this idea in Pythonic way? The problem is that I want to create class with many attributes, but don't want to initialize all in __init__(self, arg1, arg2, ..., argN). Instead of this ...
9
votes
1answer
195 views

Minesweeper implementation java

I'm writing Minesweeper implementation in Java. I have little experience yet, so I need some advices: about improving code, making it more readable and flexible about coding style about common ...
3
votes
0answers
53 views

Sudoku sequence solver for non-standard constraints

This script is designed to help solve sequences in Sudoku puzzles with variant constraints (ex: Thermometer, Renban, etc.). Summary The user specifies the constraints they want applied as well as the ...
6
votes
2answers
10k views

Calculator - C++ operator-overloading

I am new to object-oriented concepts. The following is my attempt at creating a basic calculator using class and operator overloading concepts. Please review it for improvements. Also, how do I make ...
1
vote
1answer
87 views

Model animals using inheritance in Java

I was assigned the following problem: You've gone back in time to 500BC Athens and Socrates wants you to build him an app to help classify animals. Build the classes ...
7
votes
3answers
5k views

Discrete Event Simulator

I'm an undergraduate student and I have this assignment on a Discrete Event simulator. Currently I have completed to the end of v1.2 here. Attached also, is an algorithmic overview. I have wrote my ...
3
votes
2answers
73 views

Finding Number of Objects in Image

I wrote a program that, given a 2D array representing pixels in a birds eye view image, it returns the number of Objects in the image. Pixels that are connected in the up, down, left, and right ...
2
votes
0answers
73 views

Arcade Stacker Game - Core Logic

This is my first post here, so I apologize if anything is incorrect. I have created an endless arcade stacker game (like the stacker games at the arcade, but when you hit the top the grid resets and ...
1
vote
1answer
84 views

Snake game MVC (Vanilla JS) - Help separating concerns

I'm making a snake game for practicing the MVC pattern and also going out of my comfort zone (I'm in data processing / data science, mostly procedural coding) The game is available in https://nabla-f....
3
votes
2answers
217 views

Snakes and Ladders OOP

I've created a simple Snakes and Ladders game. The goal is improving my knowledge about OOP.There are some basic rules. I need to be able to move my token. The token starts in the square 1. If the ...
0
votes
2answers
75 views

Separating odd numbers and even numbers into two vectors in C++

I'm learning C++, and would like some guidance. I'm pretty sure I'm doing something wrong. This algorithm runs in O(n) time and uses O(n) external space. Could I make a more efficient algorithm for ...
4
votes
1answer
83 views

PHP object oriented programming

I'm trying to learn OOP with PHP (I know it's hard because It's not an OOP language). I'm rewriting my procedural code to OOP.Please provide any feedback on my code, naming and file/folder structure. ...
4
votes
1answer
314 views

A Basic HashMap (Python)

A hashmap is a data structure that implements an associative array abstract data type using keys and values and has a hash function to compute an index into an array, from which the desired value can ...
1
vote
2answers
106 views

checking is ellipse is filled or not

following code below works fine but feels kind of a mess. Any one has a better way to do this? I am creating a basic "Enter Pin" to unclick screen on an app. So if the user enters the 1st ...
0
votes
3answers
71 views

What is the elegant way to merge collection of entities with a duplicate field?

I have the following entity, I am getting it in response of REST API. class Account { private String ownerId; private List<String> coOwners; } REST ...
1
vote
2answers
35 views

Refactoring Ruby recharge REST API wrapper by using class variables

I am trying to create an API wrapper for recharge (A Shopify subscription service), I am using the HTTParty gem ...
8
votes
3answers
3k views

Calculate evapotranspiration

I am trying to create a code for the Basic evapotranspiration equation by Hargreaves. I have attached a screenshot of the equation to be replicated. I want to create a class wherein I can input data ...
1
vote
1answer
70 views

Prevent Column Name Collision

I have been working on a series of posts about a library to connect to databases but most of the scenarios I have to resort to some "JOIN" the problem arose when two or more tables had some ...
0
votes
0answers
70 views

Android app class serialization with static Load / Save method

This is a follow-up question for Android app class serialization. As forsvarir's updated answer mentioned "A static load that returns a new instance of a ...
3
votes
2answers
162 views

Print a Menu in the Command Line following SOLID

Problem Description I am building a library that helps me building TUI Apps more faster, for example printing TUI Menus and other components. I would like to get feedback on my design decisions to see ...
0
votes
1answer
179 views

Coding convention when using differential inheritance

Ever since reading Crockford's "Good Parts" and Johansen's TDD book, I have wanted to use more of the differential inheritance pattern in my coding at work (as in avoiding ...

1
2 3 4 5
74