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.

2
votes
0answers
18 views

Agent based model in Python

My model is based on this game https://en.wikipedia.org/wiki/Ultimatum_game . I won't go into the intuition behind it but generally speaking it functions as follows: The game consists of a n x n ...
4
votes
2answers
62 views

Papers, Please - Kata from CodeWars - Python

This is possibly one of the longest katas I've finished so far. https://www.codewars.com/kata/59d582cafbdd0b7ef90000a0/train/python I've been working on this one for about an hour a day for about 2 ...
8
votes
4answers
1k views

Skipping over failed imports until they are needed (if ever)

We have a program with many dependencies. Because the user may not want to use all of them, the program should skip over failed imports and only raise an error if absolutely necessary. e.g. if the ...
0
votes
2answers
61 views

Find missing element in an array of unique elements from 0 to n

The task is taken from LeetCode Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. ...
2
votes
1answer
24 views

Two ways to implement DND type abilities

I am creating a game in Java that uses the DND model for a lot of its components. I've hit a roadblock when it comes to creating and implementing abilities. I have ...
1
vote
0answers
52 views

An implementation of an AVL tree with unique_ptr

I've implemented an AVL tree using unique_ptr. The code has been stress-tested and there are no crashes or segmentation faults. I left the program running at night and stopped it manually the next ...
4
votes
1answer
57 views

A Versatile Algebraic Variable Class Template with full operator support

I've been working on this concept for the past few days where a variable_t is of any type T; assuming that it is at least ...
-4
votes
0answers
24 views

How to maintain data abstraction in the explained scenario? [closed]

I have two classes class A and class B. There is an API function aFun() inside class A which should be used by class B. class B is recursively calling itself to create some kind of child objects. All ...
3
votes
1answer
58 views

PHP Error handler class

I set up an error handler class to handle all server errors, I know there are already quite a few out there, but I like creating my own for better learning and understanding of how things work. I am ...
3
votes
0answers
32 views

Dynamic Bootstrap 4 modal using JavaScript OOP

I have created dynamic Bootstrap 4 modal using JavaScript OOP. Please verify and give your reviews how I can improve the code. I have passed four parameters to create a dynamic modal: ...
6
votes
1answer
94 views

Python3 OOP Tic-Tac-Toe

I'm studying Object-oriented Programming and decided to apply some things doing an Object-oriented Tic-Tac-Toe. I wanted to know if you have some hints of what to improve and why! ...
1
vote
2answers
73 views

github page/ DHH Score Challenge in ruby

I wrote the following code which when executed prints the score of https://github.com/dhh. ...
2
votes
2answers
61 views

Simple calculator in Object-oriented JavaScript

There is a simple form which takes two numbers num1, num2 and an operation op. After ...
4
votes
2answers
203 views

Object-oriented design implementation of an Elevator

I am a newbie when it comes to Object Oriented Programming and I have read a lot of online articles and lessons so I want to try it out on my own. I've written a console app in C# and tried ...
4
votes
1answer
43 views

CUDA matrix class

I started to work on this CUDA C matrix class to learn both the object oriented programming in C++ and to learn CUDA. The initial goal of this project was to make a matrix class that can have almost ...
6
votes
2answers
102 views

Class to generate a pdf invoice

I am learning to work with OOP design patterns and so I challenged myself with the idea of creating a way to generate a pdf invoice based on some information entered. So, this is what I have done so ...
2
votes
1answer
60 views

Prioritize objects using PriorityQueue and custom comparator in Java

I have a list of objects and a query. I need to rank the objects, based on how do they match the query. An object would match the query 100% if it contains all properties in the query. My program ...
2
votes
1answer
50 views

OOP in PHP. Exercising on creating a blog

I am attempting to do object oriented programming in right way, and appreciate any review to see if my approach is correct. class_blogpost.php as below: ...
1
vote
2answers
95 views

Object-oriented implementation on Expense Tracking App [closed]

I am creating a Expense Tracking Application in C# and right now I am trying to build its building blocks in a console app. I Would like to know your feedback if it is in a Object Oriented Design/...
1
vote
0answers
31 views

Project Management System focused on forking and web-of-trusting-code

I'm writing a project management system focused on forking and web-of-trusting-code, which is a fancy way of saying "take someone's code, do whatever you want with it, and see if others agree with you"...
5
votes
1answer
83 views

C++ practice project: Blackjack

For the longest time I always felt lost designing a robust OOP program, especially in C++. I felt like I didn't know enough theory or algorithms so I would study and never write code, not to mention I ...
4
votes
1answer
35 views

Generic calendar which can hold Mayan, Babylonian, Fantasy, Gregorian calendars

I have created this generic calendar class which I call a TimePeriodGrouping. It can contain a series of interlocking time periods (i.e. years, months, days, hours...). When time is added to one of ...
0
votes
1answer
29 views

Python classes to grab HTTP response from website entities

I am trying to implement a parent WebContent class and child classes to grab HTTP responses from the actual website entities. There are highlevel codes below and I ...
8
votes
2answers
190 views

C++17 thread pool

I've implemented a thread pool in C++17. This is not backwards compatible with C++14, due to the usage of std::invoke_result, which is new to C++17. The focus of ...
5
votes
1answer
73 views

Classic Tetris implementation for Windows console (Follow up)

This is a follow up question of Classic Tetris implementation for Windows console - Initial Version Review Since the changes this small project of mine suffered after applying all the excellent ...
1
vote
0answers
42 views

correctly implement PHP OOP in blog Post Class [closed]

I would like to know the best way to setup my PHP Blog classes. I have created a Post class which creates a blog post. ...
6
votes
1answer
132 views

OOP demonstration in C++17 using a Pokémon

I want to showcase with as minimal code as possible the basic Object-oriented programming (OOP) principles of Polymorphism, Inheritance, and Encapsulation. I know there are many more principles than ...
9
votes
3answers
83 views

Console Blackjack game, without split or betting system for now

I never programmed in my life, and I am currently self teaching myself some C++ by reading books, online free classes and googling. After beginning to read about OOP and classes, and after seeing that ...
1
vote
2answers
41 views

PHP unit test to confirm that a validator is being called correctly

I have a Responder class whose prepare method takes an entity, checks it with a validator, and returns a response or errorResponse based on the results of validator....
0
votes
1answer
43 views

proper structure of classes using interface classes [closed]

Given the following two interfaces what would the proper way to set up the two actual classes? ...
3
votes
1answer
48 views

JS Simple game in canvas

I'm trying to learn javascript (especially the OOP part) and made this simple game. I'm looking for advice and ways to improve my code. Did I handle OOP well enough? What's the best way to create a ...
8
votes
1answer
178 views

Classic Tetris implementation for Windows console

Let me start by saying that until very recently procedural was the paradigm of choice for about 100% of my programming activity, and I was a complete stranger to C++ and OOP concepts. Since a few ...
11
votes
0answers
61 views

Ruby chess engine gem

This is my first Ruby gem that claims to provide all the rules of the chess game. My goal was to keep this library as simple as possible via OOP principles, and I'd be glad to hear any feedback from ...
3
votes
0answers
22 views

Python: CLI Menu library

I started writing a small CLI menu library in python. I'm uncertain of the structure and scalability of the current code. For example the Menu.choice method would ...
5
votes
1answer
85 views

Beginner's Snake Game using SFML and C++

Never really got past the beginner stage of programming so I'm trying to get better this Summer. I think games are a fun way to learn how to program so I decided to start with snake. I'd appreciate ...
5
votes
0answers
80 views

Java objects for a network sniffer program

I'm working on a network sniffer program, whose structure uses 3 main classes: Frame Class - One per monitored frame, holds reference to all the other sub frames Parse Class - Holds the hex value of ...
0
votes
1answer
75 views

Python program to find the substring with concatenation of all words

This is a Leetcode problem: You are given a string, S, and a list of words, L that are all of the same lengths. Find all starting indices of substring(s) in S that is a concatenation of each word ...
3
votes
0answers
58 views

Sorted LinkedList

A linked list is a data structure that has a beginning, and an end. The only way through the structure is to go to the "next step", like stepping stones. This linked list works the same way, but in ...
1
vote
1answer
36 views

Map client application's DTO to service-proxy's DataContract

My idea is to not not expose/use service's Proxy everywhere throughout the application, rather exercising all service communications(using client Proxy) from a single class. To achieve this I have ...
2
votes
1answer
48 views

Singly-linked queue in PHP 7 #2

I have improved this post to the code below. As always, any critique is much appreciated! ...
3
votes
1answer
28 views

Singly-linked queue in PHP 7

I am learning PHP 7 and decided to implement a simple FIFO singly-linked queue in it: ...
3
votes
1answer
67 views

Get all possible subsets from a set of distinct integers using OOP

An assignment at school required me to write a program for this task: Create a class and define two methods in the class. Method ...
3
votes
2answers
138 views

Strategy advisor for a Yahtzee Roll

I'm implementing a Yahtzee app and i have a class StrategicAdvisor that is responsible for deciding which strategy should be followed. The ...
1
vote
1answer
34 views

Node.js DataBase class for adodb databases

A while ago I was working on a multipurpose database class (an es6 javascript class) that works with any database supporting adodb. This class is a wrapper on the "node-adodb" npm library. This ...
2
votes
1answer
64 views

X, Y Coordinates class in Lazarus (Delphi-like)

After I've now officially announced, that I'm discontinuing my color picker for Windows, I'm about to embark on a journey through Linux development. I was quite strong in Delphi on Windows, and see ...
2
votes
2answers
74 views

Design for a simple a shop

As a continuation to my question Design for a very simple e-shop I made some of the changes proposed but not all of the proposed for example I was not able to make a factory for the setAttributes. ...
4
votes
3answers
114 views

Design for a very simple e-shop

I had to design a very simple e-shop in C++ but I don't know if my design is the correct one. I mean in sense of re-usability. How can I find out if I have done a good design and how can I further ...
6
votes
0answers
60 views

Todo list using pure JavaScript [closed]

I watched a YouTube video and completed the Todo List using Pure JavaScript. Below is the code I wrote. I want to improve this code, but it 's not clear how. I want to change this code to ...
1
vote
1answer
46 views

Convert query string into object in JavaScript

Suppose I have this query and want to convert into an object a1.b2.article1=0&a2.article2=1&c3!article3=0&article16-abc=2 output for this should be ...
1
vote
0answers
61 views

Way to hide logic behind class for better readability of method and refactor class to follow SRP [closed]

I have an algorithm to create a version for an entity and then I save that version against below 2 entity: 1) Variant 2) Category ...