Skip to content
Permalink
Browse files
Source Code 1
  • Loading branch information
manns18 committed Mar 20, 2020
0 parents commit 8543e4feabb989feb4027786b69f601d13ade08b
Show file tree
Hide file tree
Showing 15 changed files with 11,202 additions and 0 deletions.
@@ -0,0 +1,62 @@
//
// CreateTeam.cpp
// BasketBallGame
//
// Created by Suraj Mann on 02/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#include "CreateTeam.h"
#include <iostream>
using namespace std;

CreateTeam::CreateTeam()
{

}

void CreateTeam::create_players()
{
int number_of_players = 5;
cout << "" << endl;
cout << "" << endl;
cout << "You now to create 5 different players for your team, allocating attributes for each player" << endl;
cout << "Each attribute value of 1 equals the use of £10 in currency" << endl;

int currency = 10000;
for(int i=0; i<number_of_players; i++)
{
string player;
cout << "Currency remaining: " << currency << endl;
cout << "" << endl;

int a=0;
while(a<1)
{
cout << "Please name your player: "; cin >> player;
cout << "" << endl;
players_list.push_back(player);
int shooting, dribbling, guarding, stamina, acceleration, height;
cout << "Please enter your player attributes choosing a number between 0-99" << endl;
cout << "Shooting: "; cin >> shooting;
cout << "Dribbling: "; cin >> dribbling;
cout << "Guarding: "; cin >> guarding;
cout << "Stamina: "; cin >> stamina;
cout << "Acceleration: "; cin >> acceleration;
cout << "Height (cm): "; cin >> height;
cout << "" << endl;

int new_currency = (shooting*10) + (dribbling*10) + (guarding*10) + (stamina*10) + (acceleration * 10);
if(new_currency > currency)
{
cout << "You do not have enough money left for this allocation, please try again" << endl;
cout << "Please try again" << endl;
}
else
{
currency = currency - new_currency;
a=1;
}
}
}
}
@@ -0,0 +1,29 @@
//
// CreateTeam.h
// BasketBallGame
//
// Created by Suraj Mann on 02/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#ifndef CreateTeam_h
#define CreateTeam_h
#endif /* CreateTeam_h */
#include <iostream>
#include <vector>
using namespace std;

class CreateTeam
{
private:
std::vector<std::string> players_list;

public:

CreateTeam();

void create_players();



};
@@ -0,0 +1,59 @@
//
// Database.cpp
// BasketBallGame
//
// Created by Suraj Mann on 05/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#include "Database.h"
#include <iostream>
#include "libsqlite.hpp"
using namespace std;

Database::Database()
{

}

void Database::database_queries()
{
//open database
sqlite::sqlite db("BasketBallGame");

auto cur = db.get_statement();
cur->set_sql("SELECT * FROM USERS;");
cur->prepare();

while( cur->step() ) // loop over results
cout << cur->get_int(0) << " " << cur->get_text(1) << endl;

}

/* void Database::add_players_db()
{
try
{
//open database
sqlite::sqlite db("basketDatabase");
int shooting, dribbling, guarding, stamina, acceleration, height;
auto cur = db.get_statement();
cur->set_sql( "INSERT INTO staff (forename, surname, job) "
"VALUES (?, ?, ?);" );
cur->prepare();
cur->bind( 1, forename );
cur->bind( 2, surname );
cur->bind( 3, job );
cur->step();
}
catch( sqlite::exception e )
{
cerr << e.what() << endl;
return 1;
}
return 0;
} */

@@ -0,0 +1,28 @@
//
// Database.h
// BasketBallGame
//
// Created by Suraj Mann on 05/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#ifndef Database_h
#define Database_h


#endif /* Database_h */
#include <iostream>
using namespace std;

class Database
{
public:

Database();

void database_queries();

void add_players_db();

};

@@ -0,0 +1,79 @@
//
// Menu.cpp
// BasketBallGame
//
// Created by Suraj Mann on 02/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#include <iostream>
#include "Menu.h"
#include "login.h"
#include "NewScreen.h"
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;

Menu::Menu()
{

}

//object method for first menu display
void Menu::display_Menu()
{
cout << "|----------------------------------------------------------------------|" << endl;
cout << "|----------------- Welcome To Basketball Simulator! -------------------|" << endl;
cout << "|----------------------------------------------------------------------|" << endl;
cout << "" << endl;
}

// object method for first menu screen
int Menu::first_Menu()
{
Login set_user_credentials;
Login check_user_credentials;
NewScreen clear_screen;
int mychoice=0;
cout << "Please press 1 to login" << endl;
cout << "Please press 2 to create a username/login" << endl;
cout << "Please press 3 to close the application" << endl;
cin >> mychoice;

choice = mychoice;

//switch statement to run menu options
switch(choice)
{
case 1:
{
check_user_credentials.check_user_credentials();
//clear_screen.clear_screen();
}
break;
case 2:
{
set_user_credentials.set_user_credentials();
//clear_screen.clear_screen();
}
break;
case 3:
return 0;
}
return 0;
}

int Menu::second_Menu()
{
string user_team;
cout << "" << endl;
cout << "Please create your basketball team" << endl;
cout << "Team Name: "; cin >> user_team;
user_team_list.push_back(user_team);
user_team_name = user_team;
return 0;
}



44 Menu.h
@@ -0,0 +1,44 @@
//
// Menu.h
// BasketBallGame
//
// Created by Suraj Mann on 02/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#ifndef Menu_h
#define Menu_h
#endif /* Menu_h */
#include <iostream>
#include <string>
#include <vector>
using namespace std;


// creating menu class
class Menu
{
private:
std::string user_team_name;
std::vector<std::string> user_team_list;


public:
int choice;

//constructor method
Menu();

Menu(std::string user_team)
{
this->user_team_name = user_team;
}

// creating function for displaying menu
void display_Menu();

// creating function for first menu screen
int first_Menu();

int second_Menu();
};
@@ -0,0 +1,23 @@
//
// NewScreen.cpp
// BasketBallGame
//
// Created by Suraj Mann on 02/03/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//
#include <iostream>
#include "NewScreen.h"
#include <stdlib.h>
#include <stdio.h>
//#include <conio.h>
using namespace std;

NewScreen::NewScreen()
{

}

void NewScreen::clear_screen()
{
//clrscr();
}
@@ -0,0 +1,28 @@
//
// NewScreen.h
// BasketBallGame
//
// Created by Suraj Mann on 24/02/2020.
// Copyright © 2020 Suraj Mann. All rights reserved.
//

#ifndef NewScreen_h
#define NewScreen_h
#endif /* NewScreen_h */
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
//#include <conio.h>

using namespace std;


class NewScreen
{
public:

NewScreen();

void clear_screen();

};

0 comments on commit 8543e4f

Please sign in to comment.