Conway’s Game of Life Object oriented implementation in Java

I have designed Conway’s Game of Life in Java, the solution follows Object Oriented design and paradigm, please review and let me know the feedback Class Cell Cell has one property alive and behavior to update alive status public class Cell { private boolean alive; public Cell( boolean alive) { this.alive = alive; } public … Read more

High performance physics simulation – core class design

Below is some stripped down code from a physics simulation. The classes Vector2, Line and Polygon are probably self explanatory. I will focus here on the fact that Polygon stores its Vector2 vertices, as well as its Lines. The reason is that the calling code, here just operator<<, benefits from the convenience of simple ranged-for … Read more

Calculator using variable names

I’ve recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions. The question is here: Jimmy has invented a new kind of calculator that works with words rather than numbers. Input … Read more

Playing “craps” for the win

No specific question here. I am beginning with Java and here is an exercise. The rules of game: You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots, respectively. After the dice have come to rest, the sum of the spots on the two upward faces … Read more

Collection with both Set and List interface

Here’s something I wrote a while ago. I needed a collection that was ordered, but also guaranteed duplicates did not occur. So I made a class with both Set and List interfaces. It seems to work well. I’m interested if there are better ways of doing this, maybe in the standard API or some library. … Read more

Coin Change: Minimum number of coins

Problem: You are given n types of coin denominations of values v(1)<v(2)<…<v(n) (all integers). Assume v(1)=1, so you can always make change for any amount of money C. Give an algorithm which makes change for an amount of money C with as few coins as possible. #include <stdio.h> #include <stdlib.h> int main() { int i,n,den[20],temp[20],min,min_idx, … Read more

C++ Stack using template

I’m learning C++, so I wrote a stack with the help of templates. I’m wondering if there is anything I can improve or if I did something vastly wrong. Stack.h #pragma once #include <ostream> template <class Type> struct Node { Node(Type data, Node<Type>* next) : data(data), next(next) {} Node* next; Type data; }; template <class … Read more