37 lines
879 B
C++
37 lines
879 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include "../include/FileUtil.h"
|
|
#include "../include/NumberUtils.h"
|
|
#include "../include/ScoreCalculator.h"
|
|
#include "../include/PrintFrames.h"
|
|
|
|
using namespace std;
|
|
|
|
int main(int argc, char *argv[]) {
|
|
if (argc < 2) {
|
|
cerr << "Please provide a CSV formatted file.";
|
|
return 0;
|
|
}
|
|
|
|
if (!FileUtil::fileExists(argv[1])) {
|
|
cerr << "Filepath: " << argv[1] << " doesn't exist.";
|
|
return 0;
|
|
}
|
|
|
|
string file = FileUtil::getFile(argv[1]);
|
|
vector<int> rolls = NumberUtils::getRolls(file);
|
|
|
|
if (!NumberUtils::validateRolls(rolls)) {
|
|
return 0;
|
|
}
|
|
|
|
vector<Frame> frames = NumberUtils::createFrames(rolls);
|
|
|
|
PrintFrames::printResult(frames);
|
|
|
|
int score = ScoreCalculator::getScore(frames);
|
|
cout << "Score: " << score << endl;
|
|
|
|
return 0;
|
|
}
|