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,7 +1,7 @@
//ProjectEuler/C++/Source/Problem19.cpp
//ProjectEuler/ProjectEulerCPP/Source/Problem19.cpp
//Matthew Ellison
// Created: 09-28-18
//Modified: 07-14-19
//Modified: 07-09-20
//How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
/*
You are given the following information, but you may prefer to do some research for yourself.
@@ -16,7 +16,7 @@ A leap year occurs on any year evenly divisible by 4, but not on a century unles
*/
//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
@@ -43,9 +43,7 @@ A leap year occurs on any year evenly divisible by 4, but not on a century unles
unsigned int Problem19::START_YEAR = 1901; //The start year
unsigned int Problem19::END_YEAR = 2000; //The stop year
Problem19::Problem19() : Problem("How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?"), totalSundays(0){
}
//Return the day of the week that the date you pass into it is on
Problem19::DAYS Problem19::getDay(unsigned int month, unsigned int day, unsigned int year){
//Make sure the numbers are within propper bounds
if((month < 1) || (month > 12) || (day < 1) || (day > 31) || (year < 1)){
@@ -122,6 +120,7 @@ Problem19::DAYS Problem19::getDay(unsigned int month, unsigned int day, unsigned
}
}
//Returns true if the year passed to it is a leap year
bool Problem19::isLeapYear(unsigned int year){
if(year < 1){
return false;
@@ -141,6 +140,11 @@ bool Problem19::isLeapYear(unsigned int year){
return false;
}
//Constructor
Problem19::Problem19() : Problem("How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?"), totalSundays(0){
}
//Solve the problem
void Problem19::solve(){
//If the problem has already been solved do nothing and end the function
if(solved){
@@ -171,6 +175,13 @@ void Problem19::solve(){
solved = true;
}
//Reset the problem so it can be run again
void Problem19::reset(){
Problem::reset();
totalSundays = 0;
}
//Return a string with the solution to the problem
std::string Problem19::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -181,6 +192,7 @@ std::string Problem19::getString() const{
return results.str();
}
//Returns the total sundays that were asked for
uint64_t Problem19::getTotalSundays() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -188,8 +200,3 @@ uint64_t Problem19::getTotalSundays() const{
}
return totalSundays;
}
void Problem19::reset(){
Problem::reset();
totalSundays = 0;
}