1. #include <iostream>
  2. #include <cstdlib>
  3. #include <sstream>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int g1=0,g2=1;
  9.  
  10. class games {
  11.     public:
  12.      string name;
  13.      int year;
  14.      string type;
  15.      games(int&);
  16.      games(){}
  17. };
  18.  
  19. class games_d {                                                            
  20.     public:
  21.      games u1;
  22.      string car;
  23.      string team;
  24.      string strategy_dif;
  25. }u2;
  26.  
  27. class func: games_d{
  28.     int assign_b(string,string,int);
  29.     int assign_d(string,string,string);
  30.    
  31.     public:
  32.      void base();
  33.      int details(int);
  34.      int disp(int);
  35. }f1;
  36.  
  37. games::games(int& a)
  38. {
  39.     if(a==1) {
  40.         name="Need for Speed Most Wanted";
  41.         year=2005;
  42.         type="Racing";
  43.     }
  44.     system("CLS");
  45.     cout<<"Name: "<<name<<endl;
  46.     cout<<"Year: "<<year<<endl;
  47.     cout<<"Type: "<<type<<endl;
  48.     cin.ignore();
  49.     a=0;
  50. }
  51.  
  52. int func::assign_b(string na,string ty,int ye)
  53. {
  54.     games_d *p=&u2;
  55.    
  56.     p->u1.name=na;
  57.     p->u1.type=ty;
  58.     p->u1.year=ye;
  59.     return 0;
  60. }
  61.  
  62. int func::assign_d(string te,string ca,string stra_dif)
  63. {
  64.     games_d *p=&u2;
  65.     p->car=ca;
  66.     p->team=te;
  67.     p->strategy_dif=stra_dif;
  68.     return 0;
  69. }
  70.  
  71. void func::base()
  72. {
  73.     string na,ty,y;
  74.     int ye,x;
  75.    
  76.     cout<<"Enter the name of the game: ";
  77.     getline(cin,na,'\n');
  78.     g2=0;
  79.     cout<<"Which year was it released?"<<endl;
  80.     getline(cin,y,'\n');
  81.     stringstream(y)>>ye;
  82.     cout<<"The type of game."<<endl;
  83.     cout<<"\n\t1. Racing."<<endl;
  84.     cout<<"\t2. Soccer."<<endl;
  85.     cout<<"\t3. Strategy."<<endl;
  86.     cout<<"\t4. Other."<<endl;
  87.     cout<<"\nSelection: ";
  88.     cin>>x;
  89.     switch(x) {
  90.      case 1:
  91.       system("CLS");
  92.       cin.ignore();
  93.       ty="Racing";
  94.       g1=1;
  95.       break;
  96.      
  97.      case 2:
  98.       system("CLS");
  99.       cin.ignore();
  100.       ty="Soccer";
  101.       g1=2;
  102.       break;
  103.                    
  104.      case 3:
  105.       system("CLS");
  106.       cin.ignore();
  107.       ty="Strategy";
  108.       g1=3;
  109.       cout<<"\nWow! Wanna improve your thinking huh? Good game!!!";
  110.       break;
  111.      
  112.      case 4:
  113.       system("CLS");
  114.       cin.ignore();
  115.       ty="Other";
  116.       g1=4;
  117.       cout<<"\nChoose better games next time!";
  118.       cin.get();
  119.       break;
  120.      
  121.      default:
  122.       cin.ignore();
  123.       g1=0;
  124.       cout<<"ERROR(101): Invalid Input!!!";
  125.       cin.get();
  126.       break;
  127.     }
  128.     assign_b(na,ty,ye);
  129. }
  130.  
  131. int func::details(int global)
  132. {
  133.     games_d *p=&u2;
  134.     string ca,te,stra_dif_string;
  135.    
  136.     if(global==1){
  137.         cout<<"Enter your best car in "<<p->u1.name<<": ";
  138.         getline(cin,ca,'\n');
  139.         if(ca=="Lamborghini Murcielago" || ca=="lamborghini murcielago" || ca=="Lamborghini murcielago" || ca=="lamborghinimurcielago") {
  140.             cout<<"You know the best ride to choose!!!";
  141.             cin.get();
  142.         }
  143.         p=&u2;
  144.     }
  145.     else if(global==2) {
  146.     cout<<"Enter your best team: ";
  147.     getline(cin,te,'\n');
  148.     if(te=="Inter Milan" || te=="Inter milan" || te=="inter milan" || te=="InterMilan")
  149.         cout<<"That's my team too!";
  150.     cin.get();
  151.     }
  152.     else if(global==3){
  153.         int stra_dif=0;
  154.        
  155.         cout<<"\n\nWhich difficulty do you play?";
  156.         cout<<"\n\t1. Easy"<<endl;
  157.         cout<<"\t2. Normal"<<endl;
  158.         cout<<"\t3. Hard"<<endl;
  159.         cout<<"\n\nSelection: ";
  160.         cin>>stra_dif;
  161.         switch(stra_dif){
  162.             case 1:
  163.                 cin.ignore();
  164.                 stra_dif_string="Easy";
  165.                 cout<<"\n\nEasy coco boy! mann crack your brains with hard!";
  166.                 cin.get();
  167.                 break;
  168.             case 2:
  169.                 stra_dif_string="Medium";
  170.                 cin.ignore();
  171.                 cout<<"Intermediate huh? master it and move on to hard!";
  172.                 cin.get();
  173.                 break;
  174.             case 3:
  175.                 stra_dif_string="Hard";
  176.                 cin.ignore();
  177.                 cout<<"Nice to see you suffer boy!!!";
  178.                 cin.get();
  179.                 break;
  180.         default:
  181.             cin.ignore();
  182.             cout<<"ERROR(101): Invalid Input!!!";
  183.             cin.get();
  184.             break;
  185.         }
  186.     }
  187.     else if(global==4){}
  188.     else{
  189.         system("CLS");
  190.         cout<<"Enter valid input before this function can be reached.";
  191.         cin.get();
  192.         return 0;
  193.     }
  194.     assign_d(te,ca,stra_dif_string);
  195.     return 0;
  196. }
  197.  
  198. int func::disp(int global)
  199. {
  200.     games_d *p=&u2;
  201.    
  202.     if(g2==1){
  203.         cout<<"\nEnter a game with a name before trying to view the gallery!";
  204.         cin.get();
  205.         return 0;
  206.     }
  207.     else {
  208.         cout<<"Name: "<<p->u1.name<<endl;
  209.         cout<<"Year: "<<p->u1.year<<endl;
  210.         cout<<"Type: "<<p->u1.type<<endl;
  211.         if(global==1)
  212.             cout<<"\n\nYour best car is: "<<p->car<<endl;
  213.         else if(global==2)
  214.             cout<<"\n\nYour best team   is: "<<p->team<<endl;
  215.         else if(global==3)
  216.             cout<<"\n\nYou play: "<<p->strategy_dif<<endl;
  217.         else{}
  218.     }
  219.     cin.ignore();
  220. }
  221.  
  222.  
  223. int main()
  224. {
  225.     int x, input1;
  226.     string comm_s;
  227.    
  228.     cout<<"Do you want my configs or yours(1 or 2 respectively): ";
  229.     cin>>x;
  230.    
  231.     if(x==1){
  232.         games a1(x);
  233.         cin.get();
  234.         goto recurse;
  235.     }
  236.     else if(x==2) {
  237.         recurse:
  238.         do {
  239.             system("CLS");
  240.             cout<<"Do you want to..."<<endl;
  241.             cout<<"\n1. Add a game to the gallery."<<endl;
  242.             cout<<"2. View the gallery."<<endl;
  243.             cout<<"3. Exit";
  244.             cout<<"\n\nSelection: ";
  245.             cin>>input1;
  246.             switch(input1){
  247.                 case 1:
  248.                     system("CLS");
  249.                     cin.ignore();
  250.                     f1.base();
  251.                     f1.details(g1);
  252.                     break;
  253.  
  254.                 case 2:
  255.                     system("CLS");
  256.                     cin.ignore();
  257.                     f1.disp(g1);
  258.                     break;
  259.  
  260.                 case 3:
  261.                     char comm;
  262.  
  263.                     cin.ignore();
  264.                     system("CLS");
  265.                     cout<<"Any comments(y/n)? ";
  266.                     cin>>comm;
  267.                     if(comm=='y'||comm=='Y') {
  268.                         cin.ignore();
  269.                         ofstream commentz("comments.txt", ios::app);
  270.                         cout<<"Enter them: ";
  271.                         getline(cin,comm_s,'\n');
  272.                         commentz<<"\n"<<comm_s;
  273.                         }
  274.                     else{cin.ignore();}
  275.                     cout<<"\n\n\t\t\t\t\t\t\t\tThanks!!!";
  276.                     cin.get();
  277.                     exit(0);
  278.                     break;
  279.                 default:
  280.                     cin.ignore();
  281.                     cout<<"ERROR(101): Invalid Input!!!";
  282.                     cin.get();
  283.             }
  284.         } while(input1!=3);
  285.     }
  286.     else{
  287.         cin.ignore();
  288.         cout<<"\nERROR(101): Invalid Input.\tmoving on...";
  289.         cin.get();
  290.         goto recurse;
  291.     }
  292.     return 0;
  293. }