AdventOfCode2024/src/MullData.cpp

67 lines
1.5 KiB
C++

// Solutions to the Advent Of Code 2024.
// Copyright (C) 2024 Stefan Müller
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#include <aoc/MullData.hpp>
MullData::MullData()
: isEnabled_{ true }, factor1_{ 0 }, factor2_{ 0 }, part1_{ 0 }, part2_{ 0 } {};
bool MullData::getIsEnabled()
{
return isEnabled_;
}
void MullData::setIsEnabled(const bool value)
{
isEnabled_ = value;
}
int MullData::getFactor(const int index)
{
return index == 1 ? factor1_ : factor2_;
}
void MullData::setFactor(const int index, const int value)
{
if (index == 1)
{
factor1_ = value;
}
else
{
factor2_ = value;
}
}
void MullData::updateResult()
{
auto product = factor1_ * factor2_;
part1_ += product;
if (isEnabled_)
{
part2_ += product;
}
}
long long int MullData::getResultPart1()
{
return part1_;
}
long long int MullData::getResultPart2()
{
return part2_;
}