Based off early uni assignment for Java, but done in C++ instead (for practice!).