From a59fcafb2e81f3cb40ff320b106030e8fed4bd66 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 2 Nov 2023 18:38:53 -0400 Subject: Modernized C++ a bit (and removed global highscores) --- highscore.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'highscore.h') diff --git a/highscore.h b/highscore.h index f7ecacc..a3e531b 100644 --- a/highscore.h +++ b/highscore.h @@ -1,18 +1,23 @@ #ifndef HIGHSCORE_H #define HIGHSCORE_H +#include + class Highscore { public: - Highscore(char* name, int level); - char* getName(); - int getLevel(); - void setRank(int rank); - int getRank(); + Highscore() = default; + + Highscore(std::string name, int level) : name_(name), level_(level) {} + + const std::string getName() const { return name_; } + int getLevel() const { return level_; } + void setRank(int rank) { rank_ = rank; } + int getRank() const { return rank_; } private: - char* name; - int level; - int rank; + std::string name_; + int level_; + int rank_; }; #endif -- cgit 1.4.1