38 lines
937 B
C++
38 lines
937 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include "../include/FileReader.h"
|
|
#include "../include/FileHelper.h"
|
|
#include "../include/NumberHelper.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 (!FileHelper::fileExists(argv[1])) {
|
|
cerr << "Filepath: " << argv[1] << " doesn't exist.";
|
|
return 0;
|
|
}
|
|
|
|
string file = FileReader::getFile(argv[1]);
|
|
vector<int> rolls = NumberHelper::getRolls(file);
|
|
|
|
if (!NumberHelper::validateRolls(rolls)) {
|
|
cerr << "Non-valid number in rolls.";
|
|
return 0;
|
|
}
|
|
|
|
PrintFrames::printHeader(rolls);
|
|
PrintFrames::printValue(rolls);
|
|
|
|
int score = ScoreCalculator::getScore(rolls);
|
|
cout << "Score: " << score << endl;
|
|
|
|
return 0;
|
|
}
|