Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Old-School-Game/ScoreRecord(nicolas maxoutis).txt
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76 lines (54 sloc)
1.82 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author:Nicolas Maxoutis | |
#include <iostream> | |
#include <string> | |
#include <fstream> | |
#include <vector> | |
#include "libsqlite.hpp" | |
using namespace std; | |
// void scorePrint ()// this function will print the High Score database | |
// { sqlite::sqlite db( "PlayerRecords.sqlite" ); // open database | |
// auto cur = db.get_statement(); // create query | |
// cur->set_sql( "SELECT * FROM playerRecords;" ); | |
// cur->prepare(); // run query | |
// string tName; | |
// int sScore; | |
// while(cur->step()){ | |
// tName = get_text(0); | |
// sScore = get_int(1); | |
// cout <<"Name "<< "Score"<<endl; | |
// cout <<tName<<sScore<<endl; | |
// | |
int main() | |
{ | |
int win_status = 1; | |
int score1 = 0; | |
int score2 = 0; | |
string player1 = "Player1"; | |
string player2 = "Player2"; | |
if(win_status == 1){ | |
cout<<"Player1 wins"<<endl; | |
score1 = score1 + 20; | |
} | |
else if(win_status == 2){ | |
cout<<"Player2 wins"<<endl; | |
score2 = score2 +20; | |
} | |
//win_status = 0; | |
return 0; | |
if (score1>score2) | |
{ sqlite::sqlite db( "PlayerRecords.sqlite" ); // open database | |
auto cur = db.get_statement(); // create query | |
cur->set_sql( "INSERT INTO playerRecords(Name, Score) VALUES('Kwstas', '80')" ); | |
cur->prepare(); // run query | |
// while( cur->step() ) // | |
} | |
if (score1<score2) | |
{ | |
sqlite::sqlite db( "PlayerRecords.sqlite" ); // open database | |
auto cur = db.get_statement(); // create query | |
cur->set_sql( "INSERT INTO playerRecords(Name, Score) VALUES('Kwstas', '80')" ); | |
cur->prepare(); // run query | |
//while( cur->step() ) // | |
} | |
return 0; | |
} |