Advertisement
a_pramanik

Project so far

Nov 17th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.04 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using  namespace std;
  3.  
  4. struct data
  5. {
  6.     int games_played, won, drawn, lost, goals_for, goals_against, goal_difference, points, d_points;
  7.     string TEAM_NAME;
  8.     data()
  9.     {
  10.         TEAM_NAME="";
  11.         games_played=0;
  12.         won=0;
  13.         drawn=0;
  14.         lost=0;
  15.         goals_for=0;
  16.         goals_against=0;
  17.         goal_difference=0;
  18.         points=0;
  19.         d_points=0;
  20.     }
  21. };
  22.  
  23. bool cmp(data lhs, data rhs)
  24. {
  25.     if(lhs.points>rhs.points)return true;
  26.     else if(lhs.points==rhs.points && lhs.goal_difference>rhs.goal_difference)return true;
  27.     else if(lhs.points==rhs.points && lhs.goal_difference==rhs.goal_difference && lhs.goals_for>rhs.goals_for)return true;
  28.     else if(lhs.points==rhs.points && lhs.goal_difference==rhs.goal_difference && lhs.goals_for==rhs.goals_for && lhs.TEAM_NAME<rhs.TEAM_NAME)return true;
  29.     else return false;
  30. }
  31.  
  32. class player
  33. {
  34.     string name;
  35.  
  36. public:
  37.     void get_player()
  38.     {
  39.         cout<<"Enter name: "<<endl;
  40.         cin>>name;
  41.     }
  42.  
  43.     void display_player()
  44.     {
  45.         cout<<"Name : "<<name<<endl;
  46.     }
  47. };
  48.  
  49. class matches
  50. {
  51. protected:
  52.     int won, drawn, lost, played;
  53.  
  54. public:
  55.     matches(){
  56.         played=0;
  57.     won=0;
  58.     drawn=0;
  59.     lost=0;
  60.     }
  61.  
  62. };
  63.  
  64. class goals
  65. {
  66. protected:
  67.     int goals_for, goals_against;
  68. public:
  69.     goals(){
  70.         goals_for=0;
  71.         goals_against=0;
  72.     }
  73. };
  74.  
  75. class cards
  76. {
  77. protected:
  78.     int yellow, red;
  79.  
  80. public:
  81.     cards(){
  82.         yellow=0;
  83.         red=0;
  84.     }
  85.  
  86. };
  87.  
  88. class teams : public matches, goals, cards
  89. {
  90. protected:
  91.     player p[2];
  92.     string team_name;
  93.     int demerit_points;
  94.  
  95.     data team_data;
  96.  
  97. public:
  98.     /*teams(){
  99.         demerit_points=0;
  100.     }*/
  101.     string give_me_d_team_name(){
  102.         return team_name;
  103.     }
  104.     void get_team(){
  105.         cout<<"Enter team name: "<<endl;
  106.         cin>>team_name;
  107.         cout<<"Enter player names: "<<endl;
  108.         for(int i=0; i<1; i++){
  109.             p[i].get_player();
  110.         }
  111.     }
  112.         void display_team()
  113.         {
  114.             cout<<"Information of team "<<team_name<<":"<<endl;
  115.  
  116.             for(int i=0; i<1; i++){
  117.                 p[i].display_player();
  118.             }
  119.         }
  120.  
  121.         /*void update_demerit_points(){
  122.             demerit_points = yellow*10+red*20;
  123.         }*/
  124.  
  125.  
  126.  
  127.     int ret_played_matches()
  128.     {
  129.         return played;
  130.     }
  131.  
  132.     int ret_won_matches()
  133.     {
  134.         return won;
  135.     }
  136.  
  137.     int ret_lost_matches()
  138.     {
  139.         return lost;
  140.     }
  141.     int ret_drawn_matches()
  142.     {
  143.         return drawn;
  144.     }
  145.  
  146.     int ret_goals_for()
  147.     {
  148.         return goals_for;
  149.     }
  150.     int ret_goals_against()
  151.     {
  152.         return goals_against;
  153.     }
  154.     int ret_yellow_cards()
  155.     {
  156.         return yellow;
  157.     }
  158.  
  159.     int ret_red_cards()
  160.     {
  161.         return red;
  162.     }
  163.  
  164.  
  165.    ///Increment Part***************************
  166.  
  167.     void yellow_inc(int x){
  168.         yellow+=x;
  169.     }
  170.     void red_inc(int x){
  171.         red+=x;
  172.     }
  173.     void goals_for_inc(int x){
  174.         goals_for+=x;
  175.     }
  176.     void goals_against_inc(int x){
  177.         goals_against+=x;
  178.     }
  179.     void played_inc(){
  180.         played++;
  181.     }
  182.     void won_inc(){
  183.         won++;
  184.     }
  185.     void drawn_inc(){
  186.         drawn++;
  187.     }
  188.     void lost_inc(){
  189.         lost++;
  190.     }
  191.  
  192.     ///*************************************
  193.  
  194. };
  195.  
  196.  
  197.  
  198. class all_teams : public teams
  199. {
  200. protected:
  201.     teams t[6];
  202.     data info[6];
  203.  
  204.     string fix1[20], fix2[20];
  205.     map<string, int> str_int;
  206.     map<int, string>int_str;
  207.     string state_of_match[20];
  208.     int no_of_games;
  209.  
  210.  
  211. public:
  212.     all_teams()
  213.     {
  214.         no_of_games=0;
  215.         for(int i=1; i<15; i++){
  216.             state_of_match[i]="NOT PLAYED";
  217.         }
  218.     }
  219.     void get_all_teams(){
  220.     for(int i=0; i<5; i++){
  221.         cout<<"Enter the informations of team "<<i+1<<endl;
  222.         t[i].get_team();
  223.     }
  224.  
  225.     for(int i=0; i<5; i++){
  226.         str_int[t[i].give_me_d_team_name()]=i;
  227.         int_str[i]=t[i].give_me_d_team_name();
  228.     }
  229.  
  230.     }
  231.  
  232.     void display_all_teams(){
  233.         for(int i=0; i<5; i++){
  234.         cout<<"Informations of team "<<i+1<<":"<<endl;
  235.         t[i].display_team();
  236.         }
  237.     }
  238.  
  239.     ///Result_input_section**************************
  240.  
  241.     void get_match_results()
  242.     {
  243.         int g1, g2, y1, y2, r1, r2;
  244.         cout<<endl;
  245.         if(no_of_games>=10){
  246.             cout<<"Results of all matches have been taken"<<endl<<endl;
  247.             return;
  248.         }
  249.         cout<<"##JU FOOTBALL TOURNAMENT##"<<endl;
  250.         cout<<"     MATCH NO : "<<no_of_games+1<<endl;
  251.         cout<<"*** "<<fix1[no_of_games]<<" vs "<<fix2[no_of_games]<<" ***"<<endl;
  252.         cout<<endl<<"Enter Number of goals scored by "<<fix1[no_of_games]<<" : "<<endl;cin>>g1;
  253.         cout<<"Enter Number of goals scored by "<<fix2[no_of_games]<<" : "<<endl;cin>>g2;
  254.         cout<<endl<<"Enter cards received by "<<fix1[no_of_games]<<" ::"<<endl;
  255.         cout<<"Number of red cards : ";cin>>r1;
  256.         cout<<"Number of yellow cards : ";cin>>y1;
  257.         cout<<endl<<"Enter cards received by "<<fix2[no_of_games]<<" ::"<<endl;
  258.         cout<<"Number of red cards : ";cin>>r2;
  259.         cout<<"Number of yellow cards : ";cin>>y2;
  260.  
  261.         t[str_int[fix1[no_of_games]]].played_inc();
  262.         t[str_int[fix2[no_of_games]]].played_inc();
  263.  
  264.         if(g1>g2){
  265.                 t[str_int[fix1[no_of_games]]].won_inc();
  266.                 t[str_int[fix2[no_of_games]]].lost_inc();
  267.         }
  268.         else if(g2>g1){
  269.         t[str_int[fix2[no_of_games]]].won_inc();
  270.         t[str_int[fix1[no_of_games]]].lost_inc();
  271.         }
  272.         else{
  273.             t[str_int[fix1[no_of_games]]].drawn_inc();
  274.             t[str_int[fix2[no_of_games]]].drawn_inc();
  275.         }
  276.  
  277.         t[str_int[fix1[no_of_games]]].goals_for_inc(g1);
  278.         t[str_int[fix1[no_of_games]]].goals_against_inc(g2);
  279.         t[str_int[fix1[no_of_games]]].yellow_inc(y1);
  280.         t[str_int[fix1[no_of_games]]].red_inc(r1);
  281.  
  282.         t[str_int[fix2[no_of_games]]].goals_for_inc(g2);
  283.         t[str_int[fix2[no_of_games]]].goals_against_inc(g1);
  284.         t[str_int[fix2[no_of_games]]].yellow_inc(y2);
  285.         t[str_int[fix2[no_of_games]]].red_inc(r2);
  286.         no_of_games++;
  287.  
  288.     }
  289.  
  290.  
  291.     ///**************************************************
  292.  
  293.  
  294.  
  295.     ///Inherited_data_returning_from_base_classes*********
  296.  
  297.     string give_me_d_team_name(){
  298.         return (teams:: give_me_d_team_name());
  299.     }
  300.  
  301.     int  ret_played_matches(){
  302.         return (teams:: ret_played_matches());
  303.     }
  304.  
  305.     int ret_won_matches()
  306.     {
  307.         return (teams:: ret_won_matches());
  308.     }
  309.     int ret_lost_matches()
  310.     {
  311.         return (teams:: ret_lost_matches());
  312.     }
  313.     int ret_drawn_matches()
  314.     {
  315.         return (teams:: ret_drawn_matches());
  316.     }
  317.  
  318.     int ret_goals_for()
  319.     {
  320.         return (teams:: ret_goals_for());
  321.     }
  322.  
  323.     int ret_goals_against()
  324.     {
  325.         return (teams:: ret_goals_against());
  326.     }
  327.  
  328.     int ret_yellow_cards()
  329.     {
  330.         return (teams:: ret_yellow_cards());
  331.     }
  332.     int ret_red_cards()
  333.     {
  334.         return (teams:: ret_red_cards());
  335.     }
  336.  
  337.     ///***********************************************
  338.  
  339.  
  340.  
  341.     ///Fixture related functions************************
  342.  
  343.     void build_fixture()
  344.     {
  345.         int cnt=-1;
  346.         for(int i=0; i<5; i++){
  347.             for(int j=i+1; j<5; j++){
  348.                 fix1[++cnt]=t[i].give_me_d_team_name();
  349.                 fix2[cnt]+=t[j].give_me_d_team_name();
  350.             }
  351.         }
  352.  
  353.         swap(fix1[2], fix1[7]);
  354.         swap(fix1[4], fix1[9]);
  355.     }
  356.  
  357.     void show_fixture()
  358.     {
  359.  
  360.         cout<<"#######################################################"<<endl;
  361.         cout<<"#######################################################"<<endl;
  362.         for(int i=0; i<10; i++){
  363.                 cout<<"##   ";
  364.             cout<<fix1[i]<<" vs "<<fix2[i]<<"       ##"<<endl;
  365.         }
  366.         cout<<"#######################################################"<<endl;
  367.         cout<<"#######################################################"<<endl;
  368.     }
  369.  
  370.  
  371.     ///***************************************************************************
  372.  
  373.     void update_info()
  374.     {
  375.         for(int i=0; i<5; i++){
  376.                 if(info[i].TEAM_NAME==""){
  377.                     info[i].TEAM_NAME=t[i].give_me_d_team_name();
  378.                 }
  379.             info[i].games_played = t[i].ret_played_matches();
  380.             info[i].won=t[i].ret_won_matches();
  381.             info[i].drawn=t[i].ret_drawn_matches();
  382.             info[i].lost=t[i].ret_lost_matches();
  383.             info[i].goals_for=t[i].ret_goals_for();
  384.             info[i].goals_against=t[i].ret_goals_against();
  385.             info[i].goal_difference=t[i].ret_goals_for()-t[i].ret_goals_against();
  386.             info[i].points=t[i].ret_won_matches()*3+t[i].ret_drawn_matches();
  387.  
  388.         }
  389.         sort(info, info+5, cmp);
  390.     }
  391.  
  392.     void show_info()
  393.     {
  394.         cout<<"      GP   WON   DRAWN   LOST   GF   GA   GD   PTS"<<endl;
  395.         for(int i=0; i<5; i++){
  396.             cout<<info[i].TEAM_NAME<<"    ";
  397.             cout<<info[i].games_played<<"      "<<info[i].won<<"     "<<info[i].drawn<<"      ";
  398.             cout<<info[i].lost<<"    "<<info[i].goals_for<<"    "<<info[i].goals_against<<"      ";
  399.             cout<<info[i].goal_difference<<"    "<<info[i].points<<endl;
  400.         }
  401.     }
  402.  
  403. };
  404.  
  405.  
  406. class points_table : public all_teams
  407. {
  408. protected:
  409.  
  410. public:
  411.  
  412.     void get_all_teams()
  413.     {
  414.         all_teams:: get_all_teams();
  415.     }
  416.  
  417.     void display_all_teams()
  418.     {
  419.         all_teams:: display_all_teams();
  420.     }
  421.  
  422.     void update_points_table()
  423.     {
  424.         all_teams:: update_info();
  425.     }
  426.  
  427.     void show_points_table()
  428.     {
  429.         all_teams:: show_info();
  430.     }
  431.  
  432.     void get_match_results()
  433.     {
  434.         all_teams :: get_match_results();
  435.     }
  436.  
  437.     void build_fixture()
  438.     {
  439.         all_teams :: build_fixture();
  440.     }
  441.  
  442.     void show_fixture()
  443.     {
  444.         all_teams :: show_fixture();
  445.     }
  446.  
  447.  
  448. };
  449.  
  450.  
  451.  
  452.  
  453. int main()
  454. {
  455.    /*fixture a;
  456.    a.get_all_teams();
  457.    //a.display_all_teams();
  458.    a.build_fixture();
  459.    a.show_fixture();
  460.    /*a.display_all_teams();*/
  461.  
  462.     points_table a;
  463.  
  464.     a.get_all_teams();
  465.     a.build_fixture();
  466.     a.show_fixture();
  467.     //a.display_all_teams();
  468.     /*a.get_match_results();
  469.     a.get_match_results();
  470.     a.get_match_results();
  471.     a.update_points_table();
  472.     a.show_points_table();*/
  473.     //int x;
  474.     /*while(1)
  475.     {
  476.         cout<<"1. for#include <bits/stdc++.h>
  477. using  namespace std;
  478.  
  479. struct data
  480. {
  481.     int games_played, won, drawn, lost, goals_for, goals_against, goal_difference, points, d_points;
  482.     string TEAM_NAME;
  483.     data()
  484.     {
  485.         TEAM_NAME="";
  486.         games_played=0;
  487.         won=0;
  488.         drawn=0;
  489.         lost=0;
  490.         goals_for=0;
  491.         goals_against=0;
  492.         goal_difference=0;
  493.         points=0;
  494.         d_points=0;
  495.     }
  496. };
  497.  
  498. bool cmp(data lhs, data rhs)
  499. {
  500.     if(lhs.points>rhs.points)return true;
  501.     else if(lhs.points==rhs.points && lhs.goal_difference>rhs.goal_difference)return true;
  502.     else if(lhs.points==rhs.points && lhs.goal_difference==rhs.goal_difference && lhs.goals_for>rhs.goals_for)return true;
  503.     else if(lhs.points==rhs.points && lhs.goal_difference==rhs.goal_difference && lhs.goals_for==rhs.goals_for && lhs.TEAM_NAME<rhs.TEAM_NAME)return true;
  504.     else return false;
  505. }
  506.  
  507. class player
  508. {
  509.     string name;
  510.  
  511. public:
  512.     void get_player()
  513.     {
  514.         cout<<"Enter name: "<<endl;
  515.         cin>>name;
  516.     }
  517.  
  518.     void display_player()
  519.     {
  520.         cout<<"Name : "<<name<<endl;
  521.     }
  522. };
  523.  
  524. class matches
  525. {
  526. protected:
  527.     int won, drawn, lost, played;
  528.  
  529. public:
  530.     matches(){
  531.         played=0;
  532.     won=0;
  533.     drawn=0;
  534.     lost=0;
  535.     }
  536.  
  537. };
  538.  
  539. class goals
  540. {
  541. protected:
  542.     int goals_for, goals_against;
  543. public:
  544.     goals(){
  545.         goals_for=0;
  546.         goals_against=0;
  547.     }
  548. };
  549.  
  550. class cards
  551. {
  552. protected:
  553.     int yellow, red;
  554.  
  555. public:
  556.     cards(){
  557.         yellow=0;
  558.         red=0;
  559.     }
  560.  
  561. };
  562.  
  563. class teams : public matches, goals, cards
  564. {
  565. protected:
  566.     player p[2];
  567.     string team_name;
  568.     int demerit_points;
  569.  
  570.     data team_data;
  571.  
  572. public:
  573.     /*teams(){
  574.         demerit_points=0;
  575.     }*/
  576.     string give_me_d_team_name(){
  577.         return team_name;
  578.     }
  579.     void get_team(){
  580.         cout<<"Enter team name: "<<endl;
  581.         cin>>team_name;
  582.         cout<<"Enter player names: "<<endl;
  583.         for(int i=0; i<1; i++){
  584.             p[i].get_player();
  585.         }
  586.     }
  587.         void display_team()
  588.         {
  589.             cout<<"Information of team "<<team_name<<":"<<endl;
  590.  
  591.             for(int i=0; i<1; i++){
  592.                 p[i].display_player();
  593.             }
  594.         }
  595.  
  596.         /*void update_demerit_points(){
  597.             demerit_points = yellow*10+red*20;
  598.         }*/
  599.  
  600.  
  601.  
  602.     int ret_played_matches()
  603.     {
  604.         return played;
  605.     }
  606.  
  607.     int ret_won_matches()
  608.     {
  609.         return won;
  610.     }
  611.  
  612.     int ret_lost_matches()
  613.     {
  614.         return lost;
  615.     }
  616.     int ret_drawn_matches()
  617.     {
  618.         return drawn;
  619.     }
  620.  
  621.     int ret_goals_for()
  622.     {
  623.         return goals_for;
  624.     }
  625.     int ret_goals_against()
  626.     {
  627.         return goals_against;
  628.     }
  629.     int ret_yellow_cards()
  630.     {
  631.         return yellow;
  632.     }
  633.  
  634.     int ret_red_cards()
  635.     {
  636.         return red;
  637.     }
  638.  
  639.  
  640.    ///Increment Part***************************
  641.  
  642.     void yellow_inc(int x){
  643.         yellow+=x;
  644.     }
  645.     void red_inc(int x){
  646.         red+=x;
  647.     }
  648.     void goals_for_inc(int x){
  649.         goals_for+=x;
  650.     }
  651.     void goals_against_inc(int x){
  652.         goals_against+=x;
  653.     }
  654.     void played_inc(){
  655.         played++;
  656.     }
  657.     void won_inc(){
  658.         won++;
  659.     }
  660.     void drawn_inc(){
  661.         drawn++;
  662.     }
  663.     void lost_inc(){
  664.         lost++;
  665.     }
  666.  
  667.     ///*************************************
  668.  
  669. };
  670.  
  671.  
  672.  
  673. class all_teams : public teams
  674. {
  675. protected:
  676.     teams t[6];
  677.     data info[6];
  678.  
  679.     string fix1[20], fix2[20];
  680.     map<string, int> str_int;
  681.     map<int, string>int_str;
  682.     string state_of_match[20];
  683.     int no_of_games;
  684.  
  685.  
  686. public:
  687.     all_teams()
  688.     {
  689.         no_of_games=0;
  690.         for(int i=1; i<15; i++){
  691.             state_of_match[i]="NOT PLAYED";
  692.         }
  693.     }
  694.     void get_all_teams(){
  695.     for(int i=0; i<5; i++){
  696.         cout<<"Enter the informations of team "<<i+1<<endl;
  697.         t[i].get_team();
  698.     }
  699.  
  700.     for(int i=0; i<5; i++){
  701.         str_int[t[i].give_me_d_team_name()]=i;
  702.         int_str[i]=t[i].give_me_d_team_name();
  703.     }
  704.  
  705.     }
  706.  
  707.     void display_all_teams(){
  708.         for(int i=0; i<5; i++){
  709.         cout<<"Informations of team "<<i+1<<":"<<endl;
  710.         t[i].display_team();
  711.         }
  712.     }
  713.  
  714.     ///Result_input_section**************************
  715.  
  716.     void get_match_results()
  717.     {
  718.         int g1, g2, y1, y2, r1, r2;
  719.         cout<<endl;
  720.         if(no_of_games>=10){
  721.             cout<<"Results of all matches have been taken"<<endl<<endl;
  722.             return;
  723.         }
  724.         cout<<"##JU FOOTBALL TOURNAMENT##"<<endl;
  725.         cout<<"     MATCH NO : "<<no_of_games+1<<endl;
  726.         cout<<"*** "<<fix1[no_of_games]<<" vs "<<fix2[no_of_games]<<" ***"<<endl;
  727.         cout<<endl<<"Enter Number of goals scored by "<<fix1[no_of_games]<<" : "<<endl;cin>>g1;
  728.         cout<<"Enter Number of goals scored by "<<fix2[no_of_games]<<" : "<<endl;cin>>g2;
  729.         cout<<endl<<"Enter cards received by "<<fix1[no_of_games]<<" ::"<<endl;
  730.         cout<<"Number of red cards : ";cin>>r1;
  731.         cout<<"Number of yellow cards : ";cin>>y1;
  732.         cout<<endl<<"Enter cards received by "<<fix2[no_of_games]<<" ::"<<endl;
  733.         cout<<"Number of red cards : ";cin>>r2;
  734.         cout<<"Number of yellow cards : ";cin>>y2;
  735.  
  736.         t[str_int[fix1[no_of_games]]].played_inc();
  737.         t[str_int[fix2[no_of_games]]].played_inc();
  738.  
  739.         if(g1>g2){
  740.                 t[str_int[fix1[no_of_games]]].won_inc();
  741.                 t[str_int[fix2[no_of_games]]].lost_inc();
  742.         }
  743.         else if(g2>g1){
  744.         t[str_int[fix2[no_of_games]]].won_inc();
  745.         t[str_int[fix1[no_of_games]]].lost_inc();
  746.         }
  747.         else{
  748.             t[str_int[fix1[no_of_games]]].drawn_inc();
  749.             t[str_int[fix2[no_of_games]]].drawn_inc();
  750.         }
  751.  
  752.         t[str_int[fix1[no_of_games]]].goals_for_inc(g1);
  753.         t[str_int[fix1[no_of_games]]].goals_against_inc(g2);
  754.         t[str_int[fix1[no_of_games]]].yellow_inc(y1);
  755.         t[str_int[fix1[no_of_games]]].red_inc(r1);
  756.  
  757.         t[str_int[fix2[no_of_games]]].goals_for_inc(g2);
  758.         t[str_int[fix2[no_of_games]]].goals_against_inc(g1);
  759.         t[str_int[fix2[no_of_games]]].yellow_inc(y2);
  760.         t[str_int[fix2[no_of_games]]].red_inc(r2);
  761.         no_of_games++;
  762.  
  763.     }
  764.  
  765.  
  766.     ///**************************************************
  767.  
  768.  
  769.  
  770.     ///Inherited_data_returning_from_base_classes*********
  771.  
  772.     string give_me_d_team_name(){
  773.         return (teams:: give_me_d_team_name());
  774.     }
  775.  
  776.     int  ret_played_matches(){
  777.         return (teams:: ret_played_matches());
  778.     }
  779.  
  780.     int ret_won_matches()
  781.     {
  782.         return (teams:: ret_won_matches());
  783.     }
  784.     int ret_lost_matches()
  785.     {
  786.         return (teams:: ret_lost_matches());
  787.     }
  788.     int ret_drawn_matches()
  789.     {
  790.         return (teams:: ret_drawn_matches());
  791.     }
  792.  
  793.     int ret_goals_for()
  794.     {
  795.         return (teams:: ret_goals_for());
  796.     }
  797.  
  798.     int ret_goals_against()
  799.     {
  800.         return (teams:: ret_goals_against());
  801.     }
  802.  
  803.     int ret_yellow_cards()
  804.     {
  805.         return (teams:: ret_yellow_cards());
  806.     }
  807.     int ret_red_cards()
  808.     {
  809.         return (teams:: ret_red_cards());
  810.     }
  811.  
  812.     ///***********************************************
  813.  
  814.  
  815.  
  816.     ///Fixture related functions************************
  817.  
  818.     void build_fixture()
  819.     {
  820.         int cnt=-1;
  821.         for(int i=0; i<5; i++){
  822.             for(int j=i+1; j<5; j++){
  823.                 fix1[++cnt]=t[i].give_me_d_team_name();
  824.                 fix2[cnt]+=t[j].give_me_d_team_name();
  825.             }
  826.         }
  827.  
  828.         swap(fix1[2], fix1[7]);
  829.         swap(fix1[4], fix1[9]);
  830.     }
  831.  
  832.     void show_fixture()
  833.     {
  834.  
  835.         cout<<"#######################################################"<<endl;
  836.         cout<<"#######################################################"<<endl;
  837.         for(int i=0; i<10; i++){
  838.                 cout<<"##   ";
  839.             cout<<fix1[i]<<" vs "<<fix2[i]<<"       ##"<<endl;
  840.         }
  841.         cout<<"#######################################################"<<endl;
  842.         cout<<"#######################################################"<<endl;
  843.     }
  844.  
  845.  
  846.     ///***************************************************************************
  847.  
  848.     void update_info()
  849.     {
  850.         for(int i=0; i<5; i++){
  851.                 if(info[i].TEAM_NAME==""){
  852.                     info[i].TEAM_NAME=t[i].give_me_d_team_name();
  853.                 }
  854.             info[i].games_played = t[i].ret_played_matches();
  855.             info[i].won=t[i].ret_won_matches();
  856.             info[i].drawn=t[i].ret_drawn_matches();
  857.             info[i].lost=t[i].ret_lost_matches();
  858.             info[i].goals_for=t[i].ret_goals_for();
  859.             info[i].goals_against=t[i].ret_goals_against();
  860.             info[i].goal_difference=t[i].ret_goals_for()-t[i].ret_goals_against();
  861.             info[i].points=t[i].ret_won_matches()*3+t[i].ret_drawn_matches();
  862.  
  863.         }
  864.         sort(info, info+5, cmp);
  865.     }
  866.  
  867.     void show_info()
  868.     {
  869.         cout<<"      GP   WON   DRAWN   LOST   GF   GA   GD   PTS"<<endl;
  870.         for(int i=0; i<5; i++){
  871.             cout<<info[i].TEAM_NAME<<"    ";
  872.             cout<<info[i].games_played<<"      "<<info[i].won<<"     "<<info[i].drawn<<"      ";
  873.             cout<<info[i].lost<<"    "<<info[i].goals_for<<"    "<<info[i].goals_against<<"      ";
  874.             cout<<info[i].goal_difference<<"    "<<info[i].points<<endl;
  875.         }
  876.     }
  877.  
  878. };
  879.  
  880.  
  881. class points_table : public all_teams
  882. {
  883. protected:
  884.  
  885. public:
  886.  
  887.     void get_all_teams()
  888.     {
  889.         all_teams:: get_all_teams();
  890.     }
  891.  
  892.     void display_all_teams()
  893.     {
  894.         all_teams:: display_all_teams();
  895.     }
  896.  
  897.     void update_points_table()
  898.     {
  899.         all_teams:: update_info();
  900.     }
  901.  
  902.     void show_points_table()
  903.     {
  904.         all_teams:: show_info();
  905.     }
  906.  
  907.     void get_match_results()
  908.     {
  909.         all_teams :: get_match_results();
  910.     }
  911.  
  912.     void build_fixture()
  913.     {
  914.         all_teams :: build_fixture();
  915.     }
  916.  
  917.     void show_fixture()
  918.     {
  919.         all_teams :: show_fixture();
  920.     }
  921.  
  922.  
  923. };
  924.  
  925.  
  926.  
  927.  
  928. int main()
  929. {
  930.    /*fixture a;
  931.    a.get_all_teams();
  932.    //a.display_all_teams();
  933.    a.build_fixture();
  934.    a.show_fixture();
  935.    /*a.display_all_teams();*/
  936.  
  937.     points_table a;
  938.  
  939.     a.get_all_teams();
  940.     a.build_fixture();
  941.     a.show_fixture();
  942.     //a.display_all_teams();
  943.     /*a.get_match_results();
  944.     a.get_match_results();
  945.     a.get_match_results();
  946.     a.update_points_table();
  947.     a.show_points_table();*/
  948.     //int x;
  949.     /*while(1)
  950.     {
  951.         cout<<"1. for
  952.     }*/
  953.  
  954.    return 0;
  955. }
  956.  
  957.  
  958.     }*/
  959.  
  960.    return 0;
  961. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement