mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//ProjectEuler/C++/Source/Problem2.cpp
|
||||
//ProjectEuler/ProjectEulerCPP/Source/Problem2.cpp
|
||||
//Matthew Ellison
|
||||
// Created: 09-28-18
|
||||
//Modified: 07-14-19
|
||||
//Modified: 07-09-20
|
||||
//The sum of the even Fibonacci numbers less than 4,000,000
|
||||
//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,11 +31,14 @@
|
||||
#include "../Headers/Problem2.hpp"
|
||||
|
||||
|
||||
//Holds the largest number that we are looking for
|
||||
uint64_t Problem2::TOP_NUM = 4000000;
|
||||
|
||||
//Constructor
|
||||
Problem2::Problem2() : Problem("What is the sum of the even Fibonacci numbers less than 4,000,000?"), fullSum(0){
|
||||
}
|
||||
|
||||
//Solve the problem
|
||||
void Problem2::solve(){
|
||||
//If the problem has already been solved do nothing and end the function
|
||||
if(solved){
|
||||
@@ -62,6 +65,13 @@ void Problem2::solve(){
|
||||
solved = true;
|
||||
}
|
||||
|
||||
//Reset the problem so it can be run again
|
||||
void Problem2::reset(){
|
||||
Problem::reset();
|
||||
fullSum = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem2::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
@@ -72,6 +82,7 @@ std::string Problem2::getString() const{
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the requested sum
|
||||
uint64_t Problem2::getSum() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
@@ -79,8 +90,3 @@ uint64_t Problem2::getSum() const{
|
||||
}
|
||||
return fullSum;
|
||||
}
|
||||
|
||||
void Problem2::reset(){
|
||||
Problem::reset();
|
||||
fullSum = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user