PLEASE DO IT AS PER REQUIREMENT AND ADD ALL THE FILES AND HEADERS Goal: create a
ID: 666736 • Letter: P
Question
PLEASE DO IT AS PER REQUIREMENT AND ADD ALL THE FILES AND HEADERS
Goal: create a HighScoreManager and a User class.
HighScoreManager class should have a function to create a record and save it to a file organized descending based on the score and to print the top 10 High Scores to the screen. The class should look like the following. The High score structure should be stored in a binary file called highScore.dat file.
Class HighScoreManager
Private: Structure (username, score, date)
Public: CreateHighScore, UpdateHighScore, PrintHighScore
The user class will have the user login with his username if the username does not exist it will be added to a list of records. Once logged in the user will be able to update his info, set a high score, delete his information, or print all the high scores in a table format. The users will be stored in a text file called user.txt
The user class will contain the following:
Class User
Private: Structure (username, user info(between 1-4 fields)
Public: Login, CheckIfUserExist, UpdateUserList, DeleteUser, SetHighScore
In the main, the user will first login and then be shown a menu with the options to update his info, set a high score, delete his information, print all the high scores, exit.
Explanation / Answer
You can build your program based on this concept
}
class design :
#include "highscoremanager.h" #include <QDebug> HighScoreManager *HighScoreManager::_instance = NULL; HighScoreManager::HighScoreManager() : settings("thpinfo.com", "2002CCCF") { } QString HighScoreManager::keyFromLevel(int level) { return QString("scores/level%1").arg(level); } HighScoreManager * HighScoreManager::instance() { if (!_instance) _instance = new HighScoreManager; return _instance; } bool HighScoreManager::registerScore(int level, ulong score) { QString key = keyFromLevel(level); ulong oldScore = 0; qDebug() << "setHighScore: " << level << " -> " << score; if (settings.contains(key)) { oldScore = settings.value(key).toULongLong(); } if (oldScore < score) { settings.setValue(key, (qulonglong)score); } return (oldScore < score); } ulong HighScoreManager::getHighScore(int level) { QString key = keyFromLevel(level); ulong value = settings.value(key).toULongLong(); qDebug() << "getHighScore: " << level << " / " << key << " -> " << value; return value;}
class design :
#include "HighScoreManager.h" using namespace std; HighScoreManager::HighScoreManager(){}; HighScoreManager::highScoreInfo::highScoreInfo(){}; //Constructor HighScoreManager::highScoreInfo::highScoreInfo(const std::string userNamex, const std::string datex, const unsigned int scorex) : userName(userNamex), date(datex), score(scorex) { highScoreInfo::userName = userNamex; highScoreInfo::date = datex; highScoreInfo::score = scorex; }; void HighScoreManager::createHighScore() { ofstream outfile; outfile.open("highScore.dat"); outfile << "Username Score Date"; }; void HighScoreManager::updateHighScore() { }; void HighScoreManager::printHighScore() { }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.