Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <sstream>
- #include <fstream>
- using namespace std;
- int g1=0,g2=1;
- class games {
- public:
- string name;
- int year;
- string type;
- games(int&);
- games(){}
- };
- class games_d {
- public:
- games u1;
- string car;
- string team;
- string strategy_dif;
- }u2;
- class func: games_d{
- int assign_b(string,string,int);
- int assign_d(string,string,string);
- public:
- void base();
- int details(int);
- int disp(int);
- }f1;
- games::games(int& a)
- {
- if(a==1) {
- name="Need for Speed Most Wanted";
- year=2005;
- type="Racing";
- }
- system("CLS");
- cout<<"Name: "<<name<<endl;
- cout<<"Year: "<<year<<endl;
- cout<<"Type: "<<type<<endl;
- cin.ignore();
- a=0;
- }
- int func::assign_b(string na,string ty,int ye)
- {
- games_d *p=&u2;
- p->u1.name=na;
- p->u1.type=ty;
- p->u1.year=ye;
- return 0;
- }
- int func::assign_d(string te,string ca,string stra_dif)
- {
- games_d *p=&u2;
- p->car=ca;
- p->team=te;
- p->strategy_dif=stra_dif;
- return 0;
- }
- void func::base()
- {
- string na,ty,y;
- int ye,x;
- cout<<"Enter the name of the game: ";
- getline(cin,na,'\n');
- g2=0;
- cout<<"Which year was it released?"<<endl;
- getline(cin,y,'\n');
- stringstream(y)>>ye;
- cout<<"The type of game."<<endl;
- cout<<"\n\t1. Racing."<<endl;
- cout<<"\t2. Soccer."<<endl;
- cout<<"\t3. Strategy."<<endl;
- cout<<"\t4. Other."<<endl;
- cout<<"\nSelection: ";
- cin>>x;
- switch(x) {
- case 1:
- system("CLS");
- cin.ignore();
- ty="Racing";
- g1=1;
- break;
- case 2:
- system("CLS");
- cin.ignore();
- ty="Soccer";
- g1=2;
- break;
- case 3:
- system("CLS");
- cin.ignore();
- ty="Strategy";
- g1=3;
- cout<<"\nWow! Wanna improve your thinking huh? Good game!!!";
- break;
- case 4:
- system("CLS");
- cin.ignore();
- ty="Other";
- g1=4;
- cout<<"\nChoose better games next time!";
- cin.get();
- break;
- default:
- cin.ignore();
- g1=0;
- cout<<"ERROR(101): Invalid Input!!!";
- cin.get();
- break;
- }
- assign_b(na,ty,ye);
- }
- int func::details(int global)
- {
- games_d *p=&u2;
- string ca,te,stra_dif_string;
- if(global==1){
- cout<<"Enter your best car in "<<p->u1.name<<": ";
- getline(cin,ca,'\n');
- if(ca=="Lamborghini Murcielago" || ca=="lamborghini murcielago" || ca=="Lamborghini murcielago" || ca=="lamborghinimurcielago") {
- cout<<"You know the best ride to choose!!!";
- cin.get();
- }
- p=&u2;
- }
- else if(global==2) {
- cout<<"Enter your best team: ";
- getline(cin,te,'\n');
- if(te=="Inter Milan" || te=="Inter milan" || te=="inter milan" || te=="InterMilan")
- cout<<"That's my team too!";
- cin.get();
- }
- else if(global==3){
- int stra_dif=0;
- cout<<"\n\nWhich difficulty do you play?";
- cout<<"\n\t1. Easy"<<endl;
- cout<<"\t2. Normal"<<endl;
- cout<<"\t3. Hard"<<endl;
- cout<<"\n\nSelection: ";
- cin>>stra_dif;
- switch(stra_dif){
- case 1:
- cin.ignore();
- stra_dif_string="Easy";
- cout<<"\n\nEasy coco boy! mann crack your brains with hard!";
- cin.get();
- break;
- case 2:
- stra_dif_string="Medium";
- cin.ignore();
- cout<<"Intermediate huh? master it and move on to hard!";
- cin.get();
- break;
- case 3:
- stra_dif_string="Hard";
- cin.ignore();
- cout<<"Nice to see you suffer boy!!!";
- cin.get();
- break;
- default:
- cin.ignore();
- cout<<"ERROR(101): Invalid Input!!!";
- cin.get();
- break;
- }
- }
- else if(global==4){}
- else{
- system("CLS");
- cout<<"Enter valid input before this function can be reached.";
- cin.get();
- return 0;
- }
- assign_d(te,ca,stra_dif_string);
- return 0;
- }
- int func::disp(int global)
- {
- games_d *p=&u2;
- if(g2==1){
- cout<<"\nEnter a game with a name before trying to view the gallery!";
- cin.get();
- return 0;
- }
- else {
- cout<<"Name: "<<p->u1.name<<endl;
- cout<<"Year: "<<p->u1.year<<endl;
- cout<<"Type: "<<p->u1.type<<endl;
- if(global==1)
- cout<<"\n\nYour best car is: "<<p->car<<endl;
- else if(global==2)
- cout<<"\n\nYour best team is: "<<p->team<<endl;
- else if(global==3)
- cout<<"\n\nYou play: "<<p->strategy_dif<<endl;
- else{}
- }
- cin.ignore();
- }
- int main()
- {
- int x, input1;
- string comm_s;
- cout<<"Do you want my configs or yours(1 or 2 respectively): ";
- cin>>x;
- if(x==1){
- games a1(x);
- cin.get();
- goto recurse;
- }
- else if(x==2) {
- recurse:
- do {
- system("CLS");
- cout<<"Do you want to..."<<endl;
- cout<<"\n1. Add a game to the gallery."<<endl;
- cout<<"2. View the gallery."<<endl;
- cout<<"3. Exit";
- cout<<"\n\nSelection: ";
- cin>>input1;
- switch(input1){
- case 1:
- system("CLS");
- cin.ignore();
- f1.base();
- f1.details(g1);
- break;
- case 2:
- system("CLS");
- cin.ignore();
- f1.disp(g1);
- break;
- case 3:
- char comm;
- cin.ignore();
- system("CLS");
- cout<<"Any comments(y/n)? ";
- cin>>comm;
- if(comm=='y'||comm=='Y') {
- cin.ignore();
- ofstream commentz("comments.txt", ios::app);
- cout<<"Enter them: ";
- getline(cin,comm_s,'\n');
- commentz<<"\n"<<comm_s;
- }
- else{cin.ignore();}
- cout<<"\n\n\t\t\t\t\t\t\t\tThanks!!!";
- cin.get();
- exit(0);
- break;
- default:
- cin.ignore();
- cout<<"ERROR(101): Invalid Input!!!";
- cin.get();
- }
- } while(input1!=3);
- }
- else{
- cin.ignore();
- cout<<"\nERROR(101): Invalid Input.\tmoving on...";
- cin.get();
- goto recurse;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement