Follow c++ naming convention

This commit is contained in:
2025-03-19 11:21:04 +01:00
parent 5f8cabb56a
commit 5b61f0e5d9
11 changed files with 40 additions and 51 deletions
+1 -4
View File
@@ -1,10 +1,7 @@
#include "../include/FileHelper.h"
#include <sys/stat.h>
FileHelper::FileHelper() {};
FileHelper::~FileHelper() {};
bool FileHelper::FileExists(char *path){
bool FileHelper::fileExists(char *path){
struct stat s;
// Check if file exists, and if it isn't a folder.
+4 -7
View File
@@ -2,15 +2,12 @@
#include <string>
#include <fstream>
FileReader::FileReader() {};
FileReader::~FileReader() {};
std::string FileReader::GetFile(char *path){
std::ifstream file(path);
string FileReader::getFile(char *path){
ifstream file(path);
std::string line;
string line;
std::getline(file, line);
getline(file, line);
file.close();
+7 -9
View File
@@ -3,16 +3,14 @@
#include <sstream>
#include <vector>
NumberHelper::NumberHelper() {};
NumberHelper::~NumberHelper() {};
std::vector<int> NumberHelper::GetNumbers(std::string csv){
std::vector<int> rolls;
std::stringstream ss(csv);
std::string number;
vector<int> NumberHelper::getRolls(string csv){
vector<int> rolls;
stringstream ss(csv);
string number;
while (std::getline(ss, number, ',')) {
rolls.push_back(std::stoi(number));
// Get number from the CSV file, split by comma, and convert to int.
while (getline(ss, number, ',')) {
rolls.push_back(stoi(number));
}
return rolls;
+2 -5
View File
@@ -1,10 +1,7 @@
#include "../include/PrintFrames.h"
#include <iostream>
PrintFrames::PrintFrames() {};
PrintFrames::~PrintFrames() {};
void PrintFrames::PrintHeader(vector<int> rolls){
void PrintFrames::printHeader(vector<int> rolls){
int frame = 0;
int i = 1;
@@ -50,7 +47,7 @@ void PrintFrames::PrintHeader(vector<int> rolls){
}
}
void PrintFrames::PrintValue(vector<int> rolls){
void PrintFrames::printValue(vector<int> rolls){
int frame = 0;
while (true) {
+1 -4
View File
@@ -1,9 +1,6 @@
#include "../include/ScoreCalculator.h"
ScoreCalculator::ScoreCalculator() {};
ScoreCalculator::~ScoreCalculator() {};
int ScoreCalculator::GetScore(vector<int> rolls) {
int ScoreCalculator::getScore(vector<int> rolls) {
int score = 0;
int frame = 0;
+6 -6
View File
@@ -14,18 +14,18 @@ int main(int argc, char *argv[]) {
return 0;
}
if (!FileHelper::FileExists(argv[1])) {
if (!FileHelper::fileExists(argv[1])) {
cerr << "Filepath: " << argv[1] << " doesn't exist.";
return 0;
}
string file = FileReader::GetFile(argv[1]);
vector<int> rolls = NumberHelper::GetNumbers(file);
string file = FileReader::getFile(argv[1]);
vector<int> rolls = NumberHelper::getRolls(file);
PrintFrames::PrintHeader(rolls);
PrintFrames::PrintValue(rolls);
PrintFrames::printHeader(rolls);
PrintFrames::printValue(rolls);
int score = ScoreCalculator::GetScore(rolls);
int score = ScoreCalculator::getScore(rolls);
cout << "Score: " << score << endl;
return 0;