Advertisement
Guest User

walka bokserow

a guest
Jun 7th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.50 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include<ctime>
  4. using namespace std;
  5.  
  6. int zawodnik1, zawodnik2, i, pierwszy, A1, A2, U1, U2, x1, x2, x3, x4, runda;
  7. unsigned int W1, W2;
  8.  
  9. class bokser
  10. {
  11. public:
  12.     string imie, nazwisko;
  13.     int sila, unik, wytrzymalosc;
  14. };
  15.  
  16. int main()
  17.  
  18. {
  19.     srand( time( NULL ) );
  20.    
  21.     bokser player1;
  22.     bokser player2;
  23.    
  24.     cout << " Witaj w grze WALKA BOKSEROW \n";
  25.     cout << "____________________________ \n \n";
  26.     cout << " Wybierz pierwszego zawodnika z ponizszych wybierajac reprezentujacy \n";
  27.     cout << " go numer i wciskajac ENTER \n";
  28.    
  29.     cout << " Wybiera gracz 1 \n";
  30.     cout << " 1 - Tomasz Adamek (8, 12, 100) \n";
  31.     cout << " 2 - Wladimir Klitschko (12, 9, 115) \n";
  32.     cout << " 3 - Mike Tyson (13, 10, 110) \n";
  33.    
  34.     cin >> zawodnik1;
  35.     switch( zawodnik1 )
  36.     {
  37.     case 1:
  38.          {
  39.                       zawodnik1 = 1;
  40.                       player1.imie = "Tomasz";
  41.                       player1.nazwisko = "Adamek";
  42.                       player1.sila = 8;
  43.                       player1.unik = 12;
  44.                       player1.wytrzymalosc = 100;
  45.                       break;
  46.          }
  47.     case 2:
  48.         {
  49.                       zawodnik1 = 2;
  50.                       player1.imie = "Wladimir";
  51.                       player1.nazwisko = "Klitschko";
  52.                       player1.sila = 12;
  53.                       player1.unik = 9;
  54.                       player1.wytrzymalosc = 115;
  55.                       break;
  56.          }
  57.     case 3:
  58.          {
  59.                       zawodnik1 = 3;
  60.                       player1.imie = "Mike";
  61.                       player1.nazwisko = "Tyson";
  62.                       player1.sila = 14;
  63.                       player1.unik = 10;
  64.                       player1.wytrzymalosc = 105;
  65.                       break;
  66.          }
  67.     }
  68. do{
  69.     system("cls");
  70.     cout << " Wybiera gracz 2 \n";
  71.     cout << " 1 - Tomasz Adamek (8, 12, 100) \n";
  72.     cout << " 2 - Wladimir Klitschko (12, 9, 115) \n";
  73.     cout << " 3 - Mike Tyson (13, 10, 110) \n";
  74.     cin >> zawodnik2;
  75.     switch( zawodnik2 )
  76.     {
  77.     case 1:
  78.         {
  79.             zawodnik2 = 1;
  80.             player2.imie = "Tomasz";
  81.             player2.nazwisko = "Adamek";
  82.             player2.sila = 8;
  83.             player2.unik = 1;
  84.             player2.wytrzymalosc = 100;
  85.             break;
  86.         }
  87.        
  88.     case 2:
  89.         {
  90.             zawodnik2 = 2;
  91.             player2.imie = "Wladimir";
  92.             player2.nazwisko = "Klitschko";
  93.             player2.sila = 12;
  94.             player2.unik = 1;
  95.             player2.wytrzymalosc = 115;
  96.             break;
  97.         }
  98.        
  99.     case 3:
  100.         {
  101.             zawodnik2 = 3;
  102.             player2.imie = "Mike";
  103.             player2.nazwisko = "Tyson";
  104.             player2.sila = 14;
  105.             player2.unik = 1;
  106.             player2.wytrzymalosc = 105;
  107.             break;
  108.         }
  109.     }
  110. } while(zawodnik1 == zawodnik2);
  111.    
  112.     i = 0;
  113.    
  114.  
  115.        
  116.         W1 = player1.wytrzymalosc;
  117.         W2 = player2.wytrzymalosc;
  118.        
  119.         A1 = player1.sila;
  120.         A2 = player2.sila;
  121.        
  122.         U1 = player1.unik;
  123.         U2 = player2.unik;
  124.        
  125.    
  126.         pierwszy = rand() % 2 + 1;
  127.         if( pierwszy == 1 )
  128.         {
  129.             cout << " RUNDA 1 ";
  130.             cout << "Rozpoczyna zawodnik 1 !";
  131.            
  132.             x1 = (( rand() % 4 ) + 1 );
  133.             x2 = (( rand() % 4 ) + 1 );
  134.            
  135.             A1 = player1.sila * x1;
  136.             U2 = player2.unik * x2;
  137.             cout <<" Parametr A1 = " << A1 <<" Parametr U2 = " << U2 << " \n ";
  138.             cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  139.            
  140.             if( A1 > U2 ) W2 = W2 - A1;
  141.            
  142.             x3 = (( rand() % 4 ) + 1 );
  143.             x4 = (( rand() % 4 ) + 1 );
  144.            
  145.             A2 = player2.sila * x3;
  146.             U1 = player1.unik * x4;
  147.             cout <<" Parametr A2 = " << A2 <<" Parametr U1 = " << U1;
  148.             cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  149.            
  150.             if( A2 > U1 ) W1 = W1 - A2;
  151.            
  152.         }
  153.         else
  154.         {
  155.             cout << " RUNDA 1 ";
  156.             cout << "Rozpoczyna zawodnik 2 !";
  157.            
  158.             x1 = (( rand() % 4 ) + 1 );
  159.             x2 = (( rand() % 4 ) + 1 );
  160.            
  161.             A2 = player2.sila * x1;
  162.             U1 = player1.unik * x2;
  163.             cout <<" Parametr A2 = " << A2 <<" Parametr U1 = " << U1;
  164.            
  165.             if( A1 > U2 ) W2 = W2 - A1;
  166.            
  167.             x3 = (( rand() % 4 ) + 1 );
  168.             x4 = (( rand() % 4 ) + 1 );
  169.            
  170.             A1 = player1.sila * x1;
  171.             U2 = player2.unik * x2;
  172.             cout <<" Parametr A1 = " << A1 <<" Parametr U2 = " << U2;
  173.            
  174.             if( A2 > U1 ) W1 = W1 - A2;
  175.         }
  176.        
  177.         cout <<" Po RUNDZIE 1: \n";
  178.         cout <<" Wytrzymalosc zawodnika 1 wynosi: " << W1;
  179.         cout <<" Wytrzymalosc zawodnika 2 wynosi: " << W2;
  180.        
  181.         if (pierwszy == 1)
  182.         {
  183.            
  184.             for (i = 2; i > 12 || W1 == 0 || W2 == 0; i++)
  185.             {
  186.                 if (i%2 == 0)
  187.                 {
  188.                     cout << " RUNDA " << i;
  189.                     cout << "Rozpoczyna zawodnik 2 !";
  190.            
  191.                     x1 = (( rand() % 4 ) + 1 );
  192.                     x2 = (( rand() % 4 ) + 1 );
  193.            
  194.                     A2 = player2.sila * x1;
  195.                     U1 = player1.unik * x2;
  196.                     cout <<" Parametr A2 = " << A1 <<" Parametr U1 = " << U2 << " \n ";
  197.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  198.            
  199.                     if( A2 > U1 ) W1 = W1 - A2;
  200.            
  201.                     x3 = (( rand() % 4 ) + 1 );
  202.                     x4 = (( rand() % 4 ) + 1 );
  203.            
  204.                     A1 = player1.sila * x3;
  205.                     U2 = player2.unik * x4;
  206.                     cout <<" Parametr Aa = " << A2 <<" Parametr U2 = " << U1;
  207.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  208.            
  209.                     if( A1 > U2 ) W2 = W2 - A1;
  210.                    
  211.                 }
  212.                 else
  213.                 {
  214.                     cout << " RUNDA " << i;
  215.                     cout << "Rozpoczyna zawodnik 1 !";
  216.            
  217.                     x1 = (( rand() % 4 ) + 1 );
  218.                     x2 = (( rand() % 4 ) + 1 );
  219.            
  220.                     A1 = player1.sila * x1;
  221.                     U2 = player2.unik * x2;
  222.                     cout <<" Parametr A1 = " << A1 <<" Parametr U2 = " << U2 << " \n ";
  223.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  224.            
  225.                     if( A1 > U2 ) W2 = W2 - A1;
  226.            
  227.                     x3 = (( rand() % 4 ) + 1 );
  228.                     x4 = (( rand() % 4 ) + 1 );
  229.            
  230.                     A2 = player2.sila * x1;
  231.                     U1 = player1.unik * x2;
  232.                     cout <<" Parametr A2 = " << A2 <<" Parametr U1 = " << U1;
  233.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  234.            
  235.                     if( A2 > U1 ) W1 = W1 - A2;
  236.                    
  237.                     cout <<" Po RUNDZIE " << i <<": \n";
  238.                     cout <<" Wytrzymalosc zawodnika 1 wynosi: " << W1;
  239.                     cout <<" Wytrzymalosc zawodnika 2 wynosi: " << W2;
  240.                     cin >> runda;
  241.                    
  242.                 }
  243.             }
  244.            
  245.         }
  246.         else
  247.         {
  248.             for (i = 2; i > 12 || W1 == 0 || W2 == 0; i++)
  249.             {
  250.                 if (i%2 == 0)
  251.                 {
  252.                     cout << " RUNDA " << i;
  253.                     cout << "Rozpoczyna zawodnik 1 !";
  254.            
  255.                     x1 = (( rand() % 4 ) + 1 );
  256.                     x2 = (( rand() % 4 ) + 1 );
  257.            
  258.                     A1 = player1.sila * x1;
  259.                     U2 = player2.unik * x2;
  260.                     cout <<" Parametr A1 = " << A1 <<" Parametr U2 = " << U2 << " \n ";
  261.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  262.            
  263.                     if( A1 > U2 ) W2 = W2 - A1;
  264.            
  265.                     x3 = (( rand() % 4 ) + 1 );
  266.                     x4 = (( rand() % 4 ) + 1 );
  267.            
  268.                     A2 = player2.sila * x1;
  269.                     U1 = player1.unik * x2;
  270.                     cout <<" Parametr A2 = " << A2 <<" Parametr U1 = " << U1;
  271.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  272.            
  273.                     if( A2 > U1 ) W1 = W1 - A2;
  274.                    
  275.                     cout <<" Po RUNDZIE " << i <<": \n";
  276.                     cout <<" Wytrzymalosc zawodnika 1 wynosi: " << W1;
  277.                     cout <<" Wytrzymalosc zawodnika 2 wynosi: " << W2;     
  278.                 }
  279.                 else
  280.                 {
  281.                     cout << " RUNDA " << i;
  282.                     cout << "Rozpoczyna zawodnik 2 !";
  283.            
  284.                     x1 = (( rand() % 4 ) + 1 );
  285.                     x2 = (( rand() % 4 ) + 1 );
  286.            
  287.                     A2 = player2.sila * x1;
  288.                     U1 = player1.unik * x2;
  289.                     cout <<" Parametr A2 = " << A1 <<" Parametr U1 = " << U2 << " \n ";
  290.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  291.            
  292.                     if( A2 > U1 ) W1 = W1 - A2;
  293.            
  294.                     x3 = (( rand() % 4 ) + 1 );
  295.                     x4 = (( rand() % 4 ) + 1 );
  296.            
  297.                     A1 = player1.sila * x3;
  298.                     U2 = player2.unik * x4;
  299.                     cout <<" Parametr Aa = " << A2 <<" Parametr U2 = " << U1;
  300.                     cout <<" Parametr X1 = " << x1 <<" Parametr X2 = " << x2 << " \n";
  301.            
  302.                     if( A1 > U2 ) W2 = W2 - A1;
  303.                    
  304.                    
  305.                    
  306.                 }
  307.             }
  308.            
  309.         }
  310.      
  311.    
  312.     if( W1 == 0 )
  313.          cout << "Zawodnik 2 znokautowal zawodnika 1 !";
  314.     else
  315.     if( W2 == 0 )
  316.          cout << "Zawodnik 1 znokautowal zawodnika 2 !";
  317.     else
  318.          cout << "REMIS !";
  319.    
  320.     system( "PAUSE" );
  321.     return EXIT_SUCCESS;
  322. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement