Updated comments and made sure style was consistent

This commit is contained in:
2020-07-10 13:36:16 -04:00
parent 7257a118d4
commit c72754dcf8
65 changed files with 1160 additions and 747 deletions

View File

@@ -1,11 +1,11 @@
//ProjectEuler/C++/Source/Problem4.cpp
//ProjectEuler/ProjectEulerCPP/Source/Problem4.cpp
//Matthew Ellison
// Created: 09-28-18
//Modified: 07-14-19
//Modified: 07-09-20
//Find the largest palindrome made from the product of two 3-digit numbers
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
/*
Copyright (C) 2019 Matthew Ellison
Copyright (C) 2020 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -31,12 +31,16 @@
#include "../Headers/Problem4.hpp"
//The first number to check
int Problem4::START_NUM = 100;
//The last number to check
int Problem4::END_NUM = 999;
//Constructor
Problem4::Problem4() : Problem("Find the largest palindrome made from the product of two 3-digit numbers."){
}
//Solve the problem
void Problem4::solve(){
//If the problem has already been solved do nothing and end the function
if(solved){
@@ -75,6 +79,13 @@ void Problem4::solve(){
solved = true;
}
//Resets the problem so it can be run again
void Problem4::reset(){
Problem::reset();
palindromes.clear();
}
//Return a string with the solution to the problem
std::string Problem4::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -86,6 +97,7 @@ std::string Problem4::getString() const{
return results.str();
}
//Returns the list of all palindromes
std::vector<uint64_t> Problem4::getPalindromes() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -94,6 +106,7 @@ std::vector<uint64_t> Problem4::getPalindromes() const{
return palindromes;
}
//Returns the largest palindrome
uint64_t Problem4::getLargestPalindrome() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -101,8 +114,3 @@ uint64_t Problem4::getLargestPalindrome() const{
}
return *(palindromes.end() - 1);
}
void Problem4::reset(){
Problem::reset();
palindromes.clear();
}