Advertisement
Guest User

Untitled

a guest
May 11th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.87 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. dartscorer
  9. //Intro
  10. cout << "\nDarts Scorer!\n";
  11.                                      
  12. //Oh One Darts Game Scorer
  13. ohone:
  14. int gamestart; //Start score
  15. string players; //Number of player
  16.  
  17.   //What is the start score
  18. startscore:
  19. cout << "\nWhat is the starting score?\n";
  20. cin >> gamestart;
  21.  
  22.   //How many people are playing
  23. players:
  24.     cout << "\nHow many people are playing " << gamestart << "? (Max 4)\n";
  25.     cin >> players;
  26.    
  27.     if (players!="1" && players!="2" && players!="3" && players!="4")
  28.    
  29.     cout << "\nThis program doesn't support more than 4 players";
  30.     goto players;
  31.  
  32.     //What are the players names
  33. playername:
  34. string player1 = "";
  35. string player2 = "";
  36. string player3 = "";
  37. string player4 = "";
  38.  
  39. if (players=="1") goto p1;
  40. if (players=="2") goto p2;
  41. if (players=="3") goto p3;
  42. if (players=="4") goto p4;
  43.  
  44.            p1:
  45.            cout << "\n\nWhat is the name of Player 1?\n";
  46.            cin >> player1;
  47.            goto scoreboard;
  48.            
  49.            p2:
  50.            cout << "\n\nWhat is the name of Player 1?\n";
  51.            cin >> player1;
  52.            cout << "What is the name of Player 2?\n";
  53.            cin >> player2;
  54.            goto scoreboard;
  55.            
  56.            p3:
  57.            cout << "\n\nWhat is the name of Player 1?\n";
  58.            cin >> player1;
  59.            cout << "What is the name of Player 2?\n";
  60.            cin >> player2;
  61.            cout << "What is the name of Player 3?\n";
  62.            cin >> player3;
  63.            goto scoreboard;
  64.            
  65.            p4:
  66.            cout << "\n\nWhat is the name of Player 1?\n";
  67.            cin >> player1;
  68.            cout << "What is the name of Player 2?\n";
  69.            cin >> player2;
  70.            cout << "What is the name of Player 3?\n";
  71.            cin >> player3;
  72.            cout << "What is the name of Player 4?\n";
  73.            cin >> player4;
  74.            goto scoreboard;
  75.  
  76. //Scorecard and Entering Player Scores
  77.            scoreboard:  
  78.            int player1throw = 0;
  79.            int player2throw = 0;
  80.            int player3throw = 0;
  81.            int player4throw = 0;
  82.            int player1score = gamestart - player1throw;
  83.            int player2score = gamestart - player2throw;
  84.            int player3score = gamestart - player3throw;
  85.            int player4score = gamestart - player4throw;
  86.    
  87. roll:
  88. if (players=="1") goto s1;
  89. if (players=="2") goto s2;
  90. if (players=="3") goto s3;
  91. if (players=="4") goto s4;
  92.            
  93.            //1 PLayer
  94.            s1:
  95.            cout << "\n\n" << player1 << "";
  96.            cout << "\n" << player1score << "";
  97.            cout << "\n\n" << player1 << " scored...\n";
  98.            cin >> player1throw;
  99.            player1score -= player1throw;
  100.            if (player1score == 0)
  101.            {cout << player1 << " Wins!!";
  102.            goto rerun;}
  103.            goto roll;
  104.            
  105.            //2 Players
  106.            s2:
  107.            cout << "\n\n" << player1 << "     " << player2 << "";
  108.            cout << "\n" << player1score << "     " << player2score << "";
  109.  
  110.            cout << "\n\n" << player1 << " scored...\n";
  111.            cin >> player1throw;
  112.            player1score -= player1throw;
  113.            if (player1score == 0)
  114.            {cout << player1 << " Wins!!";
  115.            goto rerun;}
  116.            
  117.            cout << "\n\n" << player1 << "     " << player2 << "";
  118.            cout << "\n" << player1score << "     " << player2score << "";
  119.  
  120.            cout << "\n\n" << player1 << "     " << player2 << "";
  121.            cout << "\n\n" << player2 << " scored...\n";
  122.            cin >> player2throw;
  123.            player2score -= player2throw;
  124.            if (player2score == 0)
  125.            {cout << player2 << " Wins!!";
  126.            goto rerun;}
  127.            
  128.            cout << "\n\n" << player1 << "     " << player2 << "";
  129.            cout << "\n" << player1score << "     " << player2score << "";
  130.            goto roll;
  131.            
  132.            //3 Players
  133.            s3:
  134.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "";
  135.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "";
  136.            
  137.            cout << "\n\n" << player1 << " scored...\n";
  138.            cin >> player1throw;
  139.            player1score -= player1throw;
  140.            if (player1score == 0)
  141.            {cout << player1 << " Wins!!";
  142.            goto rerun;}
  143.            
  144.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "";
  145.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "";
  146.            
  147.            cout << "\n\n" << player2 << " scored...\n";
  148.            cin >> player2throw;
  149.            player2score -= player2throw;
  150.            if (player2score == 0)
  151.            {cout << player3 << " Wins!!";
  152.            goto rerun;}
  153.            
  154.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "";
  155.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "";
  156.            
  157.            cout << "\n\n" << player3 << " scored...\n";
  158.            cin >> player3throw;
  159.            player3score -= player3throw;
  160.            if (player3score == 0)
  161.            {cout << player3 << " Wins!!";
  162.            goto rerun;}
  163.            
  164.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "";
  165.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "";
  166.            goto roll;
  167.            
  168.            //4 Players
  169.            s4:
  170.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "     " << player4 << "     ";
  171.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "     " << player4score << "";        
  172.            
  173.            cout << "\n\n" << player1 << " scored...\n";
  174.            cin >> player1throw;
  175.            player1score -= player1throw;
  176.            if (player1score == 0)
  177.            {cout << player1 << " Wins!!";
  178.            goto rerun;}
  179.            
  180.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "     " << player4 << "     ";
  181.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "     " << player4score << "";        
  182.            
  183.            cout << "\n\n" << player2 << " scored...\n";
  184.            cin >> player2throw;
  185.            player2score -= player2throw;
  186.            if (player2score == 0)
  187.            {cout << player3 << " Wins!!";
  188.            goto rerun;}
  189.            
  190.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "     " << player4 << "     ";
  191.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "     " << player4score << "";
  192.            
  193.            cout << "\n\n" << player3 << " scored...\n";
  194.            cin >> player3throw;
  195.            player3score -= player3throw;
  196.            if (player3score == 0)
  197.            {cout << player3 << " Wins!!";
  198.            goto rerun;}
  199.            
  200.            cout << "\n\n" << player1 << "     " << player2 << "     " << player3 << "     " << player4 << "     ";
  201.            cout << "\n" << player1score << "     " << player2score << "     " << player3score << "     " << player4score << "";
  202.            
  203.            cout << "\n\n" << player4 << " scored...\n";
  204.            cin >> player4throw;
  205.            player4score -= player4throw;  
  206.            if (player4score == 0)
  207.            {cout << player4 << " Wins!!";
  208.            goto rerun;}    
  209.            goto roll;
  210.  
  211. //Do you want to run the program again          
  212. rerun:
  213.     cout << "\n\nDo you want to run the program again? (y/n): ";
  214.     string startagain;
  215.     cin >> startagain;
  216.     cout << "\n";
  217.     if (startagain=="y") goto dartscorer; else goto close;
  218.    
  219.     close:
  220.     return 0;
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement