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
76
votes
6answers
218k views

Design a chess game using object-oriented principles

I would like to know if my approach is correct and how could it could be improved? Also, is there a way to get rid of the relation between the Piece and the ...
59
votes
11answers
13k views

Sales tax calculator, rejected for being not OOP

I applied for an Application Developer position. They require all their applicants to complete 1 of 3 programming assignments. I picked one for sales tax calculation. It was quite simple. Write ...
54
votes
2answers
59k views

Class for reducing development time

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job (...
41
votes
5answers
34k views

Designing a coffee machine

I was recently rejected from what looked like a really promising string of interviews. I did very well in a questionnaire style review, and then they handed me this assignment (more or less): ...
38
votes
4answers
7k views

OO coffee dispenser

This picture inspired a contest between a few of my friends to rewrite this code in more proper OO style. This is what I have come up with. Any thoughts: ...
38
votes
2answers
11k views

A new approach to multithreading in Excel

Intro Multithreading tools exist in Excel - often to run macros in multiple instances of Excel, or to convert macros to vbscripts that can run independently. However I've often come across projects ...
34
votes
5answers
147k views

Modifying an array during a foreach loop [closed]

This question is always on my mind. I usually alter the array while looping through its keys, based on my gut feelings: ...
32
votes
6answers
3k views

To 'this' or not to 'this'?

I was given a homework and I have 2 solutions: one that uses this and other one that doesn't. I tested both solutions on jsPerf but sometimes it says the version ...
30
votes
5answers
15k views

A Fraction class in C++

I am trying to learn clear and concise C++. Currently I'm learning classes in school, and to practice I have made a Fraction class. I'd appreciate any help regarding style, cleanliness or anything ...
30
votes
1answer
3k views

Unit Testing in VBA

Unit testing in VBA is... lacking. (What isn't lacking in VBA though?) Since I've become more interested in unit testing lately, I decided I needed something better than ...
29
votes
7answers
28k views

Basic OOP Poker - Deck, Cards and Hands

I decided it would be interesting to simulate a game of Poker. Baby steps at the moment, and eventually I'll attempt to turn it into a GUI. The code I have so far is very basic such as populating a ...
29
votes
1answer
569 views

Lua OOP and classically-styled prototypal inheritance

I want to do some object-oriented programming in Lua, and I decided on something like this: ...
28
votes
1answer
4k views

Extensible logging

Whenever I need logging functionality in .net, I use a logging framework, such as NLog. Obviously there's no logging framework for vba, at least none that I know of. As much as I love using NLog, the ...
27
votes
3answers
2k views

How is my CMS design? Any security, design, or other issues?

I am trying to learn PHP in depth by creating this personal CMS. I try to utilize OOP concepts and do best I can... The way I am trying to design this CMS is to keep including 'modules' within a page ...
26
votes
5answers
25k views

Object Oriented Design of Card Deck

I am designing classes for a game with card deck. Please review my code. Each Player gets Hand of cards The Deck can be shuffled and cards are dealt one at a time from the deck and added to the ...
26
votes
4answers
39k views

Simple card game to learn OOP

My goal was to get my hands dirty in OOP by designing and using classes and getting started with inheritance and other OOP concepts. I have written a very small code to play a card Game called "War"....
25
votes
4answers
3k views

Calculate distance using speed of sound

I've been working on learning Java and this was a challenge as part of a chapter on data types: Create a program that computes how far away, in feet, a listener is from a sound. Sound travels ...
25
votes
3answers
4k views

What does the Bob say?

Description: Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a question. He answers 'Whoa, chill out!' if you yell ...
25
votes
3answers
3k views

Simple object-oriented calculator

After studying several ways of doing OOP in JavaScript I think I finally came up with one that seems OK to me. Is it okay? Do you see some problems I can face by using OOP in JavaScript like this? ...
25
votes
1answer
2k views

A Pong Game using C++

I wrote a simple, 2-player Pong game for a Udacity Nanodegree in C++. The program has the following class structure (relatively new to UML so any tips on here would be very much welcome too): ...
24
votes
6answers
7k views

Simulating an OOP Coffee Machine

Today I learnt the basics of OOP. I have tried to apply them to this coffee machine project. However I'm still a beginner, and so I feel my code can be improved. Are there any tips, trick or other ...
23
votes
4answers
10k views

Python OOP - creating library

I have been learning programming in Python recently and I got a task to program a library in OOP. You can add books to a library, search for a specific book according to the ISBN, name of the author ...
23
votes
5answers
7k views

Modelling a Call Center

This is the requirement I have (from the book: Cracking the Coding Interview) Imagine you have a call center with three levels of employees: fresher, technical lead (TL), and product manager (PM). ...
23
votes
3answers
9k views

Interview task - SOLID Principle and TDD

I had a small technical C# task using SOLID principle and TDD. But I failed to prove my coding skill through the test. Can anyone offer any small advice for me? I am really eager to learn what my ...
23
votes
2answers
3k views

Zork-like text adventure w/ Python

I've been using Python for around 3 months and decided to make a simple text adventure game for fun and to exercise a lot of ideas I've been learning about. I've just recently learned about classes ...
21
votes
3answers
2k views

How to Train Your Dragon

I started out practicing on implementing the builder pattern and somehow ended it up with this 2 hours later. It isn't really much, but it works and I'm hoping review should bring about a lot of ...
21
votes
3answers
9k views

C++ Shop Keeper Program

I have made a little shop keeper program and I would love someone to critique it and list all of the improvements I could make. This is my first time using OOP techniques so I imagine there is a lot ...
21
votes
1answer
648 views

Thoughts on my brain fart interpreter?

Had some free time this weekend and I hacked together a small Brainfuck interpreter, with the sole intention of explaining PHP's flavour of OO to a friend. This is a bit over-engineered on purpose, ...
20
votes
3answers
4k views

A reusable ProgressIndicator

There was a Tweet from @ExcelEasy earlier this week, that linked to this article, to which I replied with a little challenge: @ExcelEasy well done! #Challenge: make a more #OOP one without using the ...
20
votes
2answers
4k views

Designing another Coffee Machine Application

After reading Designing a coffee machine yesterday, I decided I could also give the same problem a try. I have used the following problem statement (copied from the given question): Design a ...
19
votes
4answers
26k views

Simple builder pattern implementation for building immutable objects

This is a builder pattern implementation to build immutable Person objects: Person class ...
19
votes
3answers
2k views

Tic Tac Toe - console application

I have made a little Tic Tac Toe console application using OOP techniques and would love to get some advice and guidance on what I have done. I have tried to structure the program to be as organized ...
19
votes
2answers
7k views

A Python wrap-around list

I want to gain experience creating data structures that look and feel like Python builtin types. As a first exercise, I've written a WraparoundList class meant to ...
19
votes
2answers
4k views

Down the rabbit hole with MVP

Following-up on this post where I implemented a Repository Pattern in vba to abstract ADODB and enable testing my Excel app without hitting a database backend; curious about how far vba would let me ...
19
votes
2answers
2k views

Hangman on the C++ommand line

I'm wondering if my code is just a tad too long to post here, but if the only consequence seems to be getting high-level reviews, then that's perfectly fine. This is my implementation of Hangman in C+...
18
votes
4answers
26k views

Returning Groovy class fields as a map

I want to get a map of all the fields in a class (aka value object) in a generic way. The following works fine for me: ...
18
votes
4answers
3k views

Hero battle game

This is my first attempt at OOP/classes: a game where you will select a character and use attacks and abilities to defeat the enemy character. I have a few specific questions: I was told that having ...
18
votes
2answers
3k views

Using events together with interfaces in VBA

Introduction Because of the limitation of VBA in using events in interfaces I was searching for a kind of workaround. For sure I also read this which also provides an approach, but I was searching for ...
17
votes
3answers
5k views

Python code that sorts books

I am currently a student just starting to learn python and I need help improving my code for a school assignment. I've already written the code for the program, just need suggestions on how to improve ...
17
votes
3answers
7k views

Snakes Game Using ncurses

This is my version of snakes in C++ using the ncurses library. I would like to hear from you how this piece of code can be improved and general advice for future projects regarding coding and ...
17
votes
1answer
4k views

Should I put default values of attributes on the prototype to save space?

Suppose I've got a JavaScript function that I'm treating like a class - that is, I want to make many instances of it: ...
17
votes
5answers
2k views

Generating Robot Name

Problem: Write a program that manages robot factory settings. When robots come off the factory floor, they have no name. The first time you boot them up, a random name is generated, such ...
17
votes
2answers
12k views

Big integer class in C++

I have been trying my hand a bit at creating a big integer class in C++. This is a continuation of a homework assignment. The class stores a big integer in a double linked list. Each slot contains 8 ...
16
votes
8answers
7k views

Find the first non-repeating character in a string: ("DEFD" → E)

I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Find the first non-repeating character in a string: ("DEFD" --> E) I didn't pass the coding ...
16
votes
5answers
4k views

Mini RPG equipment code

what do you think about this code? It's upgraded version of: Classes representing items in an RPG game ...
16
votes
4answers
14k views

Simple Blackjack game in console

edit: After receiving the great feedback, I have tried to make my code better. The new version can be seen here: Simple Blackjack game in console (update) This is one of my first finished projects ...
16
votes
3answers
1k views

Calculate balance wages

In the following code I'm trying to calculate Net Wage of employees and classes Earning, Deduction and ...
16
votes
2answers
3k views

A completely overkill BrainFuck lexer/parser

I'll need to build a syntax tree (AST) for Rubberduck, but since VBA has dozens of tokens and complex rules, I needed a simpler language to play with first, so I thought BrainFuck would be a perfect ...
15
votes
7answers
6k views

Java OOP Temperature Converter

I am doing a college exercise and would like to know how to improve the execution of the idea. The idea is to create a program that converts temperature measurements. Main.java ...

1
2 3 4 5
73