SHARE
TWEET

bubster program for baseball

a guest May 24th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Baseball test.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <windows.h>
  5. #include <iostream>
  6. #include <iomanip>
  7. #include <cmath>
  8. #include <ctime>
  9. #include <string>
  10. #include <algorithm>
  11. #include <vector>
  12.  
  13. using namespace std;
  14.  
  15.  
  16.  
  17. class Team {
  18.  
  19. public:
  20.  
  21.     string TeamName;
  22.     int firstInning;
  23.     int secondInning;
  24.     int thirdInningr;
  25.     int fourthInning;
  26.     int fithInning;
  27.     int sixthInning;
  28.     int seventhInning;
  29.     int eigthInning;
  30.     int ninthInning;
  31.     int tenthInning;
  32.     int eleventhInning;
  33.     int twelthInning;
  34.     //Horse(string = "Warhorse");
  35.  
  36.     int generateInningScore() {
  37.         int InningScore;
  38.         InningScore = rand() % 8 + 1;
  39.         return InningScore;
  40.     }
  41.  
  42.  
  43.  
  44.     // Instructions to generate quarter time data for object attributes
  45.     Team::Team(string newTeamName) {
  46.         TeamName = newTeamName;       // apply to generic horseName
  47.         firstInning = generateInningScore();
  48.         secondInning = firstInning + generateInningScore();
  49.         thirdInningr = secondInning + generateInningScore();
  50.         fourthInning = thirdInningr + generateInningScore();
  51.         fithInning = fourthInning + generateInningScore();
  52.         sixthInning = fithInning + generateInningScore();
  53.         seventhInning = sixthInning + generateInningScore();
  54.         eigthInning = seventhInning + generateInningScore();
  55.         ninthInning = eigthInning + generateInningScore();
  56.         tenthInning = ninthInning + generateInningScore();
  57.         eleventhInning = tenthInning + generateInningScore();
  58.         twelthInning = eleventhInning + generateInningScore();
  59.     }
  60. };
  61.  
  62.  
  63. // Functions to be used in sorting
  64. bool firstQuarterCompare(const Team & l, const Team & r) {
  65.  
  66.     return l.firstInning < r.firstInning;
  67. }
  68.  
  69. bool secondQuarterCompare(const Team & l, const Team & r) {
  70.  
  71.     return l.secondInning < r.secondInning;
  72. }
  73.  
  74. bool thirdQuarterCompare(const Team & l, const Team & r) {
  75.  
  76.     return l.thirdInningr < r.thirdInningr;
  77. }
  78.  
  79. bool fourthQuarterCompare(const Team & l, const Team & r) {
  80.  
  81.     return l.fourthInning < r.fourthInning;
  82. }
  83. bool fithQuarterCompare(const Team & l, const Team & r) {
  84.  
  85.     return l.fithInning < r.fithInning;
  86. }
  87. bool sixthQuarterCompare(const Team & l, const Team & r) {
  88.  
  89.     return l.sixthInning < r.sixthInning;
  90. }
  91. bool seventhQuarterCompare(const Team & l, const Team & r) {
  92.  
  93.     return l.seventhInning < r.seventhInning;
  94. }
  95. bool eigthQuarterCompare(const Team & l, const Team & r) {
  96.  
  97.     return l.eigthInning < r.eigthInning;
  98. }
  99. bool ninthQuarterCompare(const Team & l, const Team & r) {
  100.  
  101.     return l.eigthInning < r.eigthInning;
  102. }
  103. bool tenthQuarterCompare(const Team & l, const Team & r) {
  104.  
  105.     return l.eigthInning < r.eigthInning;
  106. }
  107. bool eleventhQuarterCompare(const Team & l, const Team & r) {
  108.  
  109.     return l.eigthInning < r.eigthInning;
  110. }
  111. bool twelthQuarterCompare(const Team & l, const Team & r) {
  112.  
  113.     return l.eigthInning < r.eigthInning;
  114. }
  115.  
  116.  
  117. int main() {
  118.  
  119.     int i;
  120.     srand(time(NULL));
  121.     vector<Team> teamsPlaying;
  122.     vector<Team>::iterator Iter;
  123.  
  124.     // Add each horse to the end of the vector "horsesRacing"
  125.  
  126.     teamsPlaying.push_back(Team("Always Dreaming"));
  127.     teamsPlaying.push_back(Team("Nyquist"));
  128.     //horsesRacing.push_back(Horse("American Pharoah"));
  129.     //horsesRacing.push_back(Horse("California Chrome"));
  130.  
  131.     Sleep(150);
  132.  
  133.     sort(teamsPlaying.begin(), teamsPlaying.end(), firstQuarterCompare);
  134.  
  135.     cout << endl;
  136.     cout << "After Quarter One, the standings are:" << endl;
  137.  
  138.     i = 1;
  139.  
  140.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  141.  
  142.         cout << i << ") " << Iter->TeamName << " at "
  143.             << Iter->firstInning << " score" << endl;
  144.         i++;
  145.  
  146.     }
  147.  
  148.     Sleep(3000);
  149.  
  150.     sort(teamsPlaying.begin(), teamsPlaying.end(), secondQuarterCompare);
  151.  
  152.     cout << endl;
  153.     cout << "After Quarter Two, the standings are:" << endl;
  154.  
  155.     i = 1;
  156.  
  157.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  158.  
  159.         cout << i << ") " << Iter->TeamName << " at "
  160.             << Iter->secondInning << " seconds" << endl;
  161.         i++;
  162.  
  163.     }
  164.  
  165.     Sleep(3000);
  166.  
  167.     sort(teamsPlaying.begin(), teamsPlaying.end(), thirdQuarterCompare);
  168.  
  169.     cout << endl;
  170.     cout << "After Quarter Three, the standings are:" << endl;
  171.  
  172.     i = 1;
  173.  
  174.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  175.  
  176.         cout << i << ") " << Iter->TeamName << " at "
  177.             << Iter->thirdInningr << " seconds" << endl;
  178.         i++;
  179.  
  180.     }
  181.  
  182.     Sleep(3000);
  183.  
  184.     sort(teamsPlaying.begin(), teamsPlaying.end(), fourthQuarterCompare);
  185.  
  186.     cout << endl;
  187.     cout << "After Quarter Four, the standings are:" << endl;
  188.  
  189.     i = 1;
  190.  
  191.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  192.  
  193.         cout << i << ") " << Iter->TeamName << " at "
  194.             << Iter->fourthInning << " seconds" << endl;
  195.         i++;
  196.  
  197.     }
  198.    
  199.     Sleep(3000);
  200.  
  201.     sort(teamsPlaying.begin(), teamsPlaying.end(), fithQuarterCompare);
  202.  
  203.     cout << endl;
  204.     cout << "After Quarter Five , the standings are:" << endl;
  205.  
  206.     i = 1;
  207.  
  208.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  209.  
  210.         cout << i << ") " << Iter->TeamName << " at "
  211.             << Iter->fithInning << " seconds" << endl;
  212.         i++;
  213.  
  214.     }
  215.  
  216.     Sleep(3000);
  217.  
  218.     sort(teamsPlaying.begin(), teamsPlaying.end(), sixthQuarterCompare);
  219.  
  220.     cout << endl;
  221.     cout << "After Quarter Six, the standings are:" << endl;
  222.  
  223.     i = 1;
  224.  
  225.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  226.  
  227.         cout << i << ") " << Iter->TeamName << " at "
  228.             << Iter->sixthInning << " seconds" << endl;
  229.         i++;
  230.  
  231.     }
  232.  
  233.     Sleep(3000);
  234.  
  235.     sort(teamsPlaying.begin(), teamsPlaying.end(), seventhQuarterCompare);
  236.  
  237.     cout << endl;
  238.     cout << "After Quarter Seven, the standings are:" << endl;
  239.  
  240.     i = 1;
  241.  
  242.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  243.  
  244.         cout << i << ") " << Iter->TeamName << " at "
  245.             << Iter->seventhInning << " seconds" << endl;
  246.         i++;
  247.  
  248.     }
  249.  
  250.     Sleep(3000);
  251.  
  252.     sort(teamsPlaying.begin(), teamsPlaying.end(), eigthQuarterCompare);
  253.  
  254.     cout << endl;
  255.     cout << "After Quarter Eight, the standings are:" << endl;
  256.  
  257.     i = 1;
  258.  
  259.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  260.  
  261.         cout << i << ") " << Iter->TeamName << " at "
  262.             << Iter->eigthInning << " seconds" << endl;
  263.         i++;
  264.  
  265.     }
  266.  
  267.     Sleep(3000);
  268.  
  269.     sort(teamsPlaying.begin(), teamsPlaying.end(), ninthQuarterCompare);
  270.  
  271.     cout << endl;
  272.     cout << "After Quarter Nine, the standings are:" << endl;
  273.  
  274.     i = 1;
  275.  
  276.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  277.  
  278.         cout << i << ") " << Iter->TeamName << " at "
  279.             << Iter->ninthInning << " seconds" << endl;
  280.         i++;
  281.  
  282.     }
  283.     if teamsPlaying.begin == teamsPlaying.end;
  284.     {
  285.  
  286.  
  287.  
  288.  
  289.     }
  290.     Sleep(3000);
  291.  
  292.     sort(teamsPlaying.begin(), teamsPlaying.end(), fithQuarterCompare);
  293.  
  294.     cout << endl;
  295.     cout << "After Quarter Four, the standings are:" << endl;
  296.  
  297.     i = 1;
  298.  
  299.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  300.  
  301.         cout << i << ") " << Iter->TeamName << " at "
  302.             << Iter->fithInning << " seconds" << endl;
  303.         i++;
  304.  
  305.     }
  306.  
  307.     Sleep(3000);
  308.  
  309.     sort(teamsPlaying.begin(), teamsPlaying.end(), fithQuarterCompare);
  310.  
  311.     cout << endl;
  312.     cout << "After Quarter Four, the standings are:" << endl;
  313.  
  314.     i = 1;
  315.  
  316.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  317.  
  318.         cout << i << ") " << Iter->TeamName << " at "
  319.             << Iter->fithInning << " seconds" << endl;
  320.         i++;
  321.  
  322.     }
  323.  
  324.     Sleep(3000);
  325.  
  326.     sort(teamsPlaying.begin(), teamsPlaying.end(), fithQuarterCompare);
  327.  
  328.     cout << endl;
  329.     cout << "After Quarter Four, the standings are:" << endl;
  330.  
  331.     i = 1;
  332.  
  333.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  334.  
  335.         cout << i << ") " << Iter->TeamName << " at "
  336.             << Iter->fithInning << " seconds" << endl;
  337.         i++;
  338.  
  339.     }
  340.  
  341.     Sleep(3000);
  342.  
  343.     sort(teamsPlaying.begin(), teamsPlaying.end(), fithQuarterCompare);
  344.  
  345.     cout << endl;
  346.     cout << "After Quarter Four, the standings are:" << endl;
  347.  
  348.     i = 1;
  349.  
  350.     for (Iter = teamsPlaying.begin(); Iter != teamsPlaying.end(); ++Iter) {
  351.  
  352.         cout << i << ") " << Iter->TeamName << " at "
  353.             << Iter->fithInning << " seconds" << endl;
  354.         i++;
  355.  
  356.     }
  357.  
  358.     cin >> i;
  359.  
  360.     return 0;
  361. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top