Code from Comp 130 class in C++