Question

Create a stadium class. The class header file content (.h file) can go in this question,...

Create a stadium class. The class header file content (.h file) can go in this question, the class implementation (.cpp file) can go in the following question, and the main.cpp content can go in the third question.

static data members:

  • starting seat number
  • next seat number

data members:

  • stadium name
  • name of home team
  • current opponent
  • seats sold (vector of seat numbers)

member functions:

  • custom constructor - take input of stadium name
  • default constructor
  • get next seat number (static)
  • change name of home team
  • change current opponent
  • sell seat (add next seat number to seat vector, increase next seat number)
  • print seats sold (print all seat numbers in seats sold vector on separate lines)
  • overload << operator - print "Welcome" message, stadium name and name of home team
  • overload == if current opponent is the same, return true, otherwise false

main.cpp:

  • get the stadium name from user
  • create stadium with user's stadium name
  • get home team from user
  • change home team for stadium
  • get current opponent from user
  • change current opponent for stadium
  • create loop to serve 1000 customers
  • for each customer:
    • use << overload for stadium to print info
    • get customer name (not a class data member, just local variable in main)
    • print customer name and next seat number
    • call sell seat function
  • at end, call print seats sold function

Homework Answers

Answer #1

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You.

Stadium.h

#ifndef STADIUM_H_
#define STADIUM_H_

#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Stadium{
private:
   static int startingSeatNumber;
   static int nextSeatNumber;

   string stadiumName;
   string nameOfHomeTeam;
   string currentOpponent;
   vector<int> seatSold;
public:
   Stadium(string stdName);
   Stadium();
   static int getNextSeatNumber();
   void changeHomeTeamName(string nameIn);
   void changeCurrentOpponent(string currOppo);
   void sellSeat();
   void printSoldSeat();
   friend ostream& operator<<(ostream& os, Stadium &obj);
   bool operator==(const Stadium & obj);
};

#endif /* STADIUM_H_ */

Stadium.cpp

#include "Stadium.h"
Stadium::Stadium(string stdName){
   stadiumName = stdName;
}

Stadium::Stadium(){
   stadiumName = "";
}

int Stadium::getNextSeatNumber(){
   return nextSeatNumber;
}

void Stadium::changeHomeTeamName(string nameIn){
   nameOfHomeTeam = nameIn;
}

void Stadium::changeCurrentOpponent(string currOppo){
   currentOpponent = currOppo;
}

void Stadium::sellSeat(){
   seatSold.push_back(nextSeatNumber);
   nextSeatNumber++;
}
void Stadium::printSoldSeat(){
   for(int i=0;i<seatSold.size();i++){
       cout<<seatSold[i]<<endl;
   }
}

bool Stadium::operator==(const Stadium & obj){
   return currentOpponent==obj.currentOpponent;
}
ostream& operator<<(ostream& os, Stadium &obj) {
   cout<<"***************************************"<<endl;
   cout<<"Welcome to "<<obj.stadiumName<<" Stadium, Home team is : "<<obj.nameOfHomeTeam<<endl;
   cout<<"***************************************"<<endl;
   return os;
}
int Stadium::nextSeatNumber = 1;
int Stadium::startingSeatNumber = 1;

main.cpp

#include <iostream>
#include <string>
#include <vector>
#include "Stadium.h"

using namespace std;

int main(int argc, char * argv[]){

   string stadiumName;
   cout<<"Enter Stadium name : ";
   cin>>stadiumName;

   Stadium myStadium(stadiumName);

   string homeTeam;
   cout<<"Enter Home team name : ";
   cin>>homeTeam;
   myStadium.changeHomeTeamName(homeTeam);

   string currentOppo;
   cout<<"Enter Current Opponent name : ";
   cin>>currentOppo;
   myStadium.changeCurrentOpponent(currentOppo);


   //serve 1000 customers
   for(int i=0;i<1000;i++){
       cout<<myStadium;
       string customerName;
       cout<<"Enter customer Name : ";
       cin>>customerName;
       cout<<"Customer name : "<<customerName<<" seat allocated is : "<<Stadium::getNextSeatNumber()<<endl;
       myStadium.sellSeat();
   }

   cout<<"\nTotal seat allocated is as below"<<endl;
   myStadium.printSoldSeat();
   return 0;
}

OUTPUT

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate class. In Worker...
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file....
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file. Both files must be in the same directory to compile. Display all dollar amounts using the DecimalFormat class. Create an account Ask the user for the type of account, the bank account number, the amount that they will deposit to start the account. Set interest earned to 0. Print the account information using an implicit or explicit call to toString Update an account Use...
Create a header file (lastname_employeerec.h) that defines an employee data structure (sEMPLOYEE) that can be linked...
Create a header file (lastname_employeerec.h) that defines an employee data structure (sEMPLOYEE) that can be linked onto a linked list. The data structure should have the following fields: a. First Name (firstName) b. Last Name (lastName) c. Employee ID (id) d. Start Year (startYear) e. Starting Salary (startSalary) f. Current Salary (currentSalary) g. next Create a library of functions that operate on this data structure. The source code for the functions should be in lastname_employeerec.c and the function prototypes should...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields,...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies a series of transactions to the accounts. Its main() method uses the CustomerAccounts class to manage a collection of CustomerAccount objects: reading customer accounts data & transactions, and obtaining a String showing the customer accounts data after the operations are complete. You will need to complete the readCustomerAccounts () and applyTransactions() methods in the CustomerAccounts class. First, please fill in your name in the...
Implement and demonstrate a disk-based buffer pool class based on the LRU buffer pool replacement strategy....
Implement and demonstrate a disk-based buffer pool class based on the LRU buffer pool replacement strategy. Disk blocks are numbered consecutively from the beginning of the file with the first block numbered as 0. Assume that blocks are 4096 bytes in size. Use the supplied C++ files to implement your LRU Buffer Pool based on the instructions below. • Implement a BufferBlock class using the supplied BufferBlockADT.h o Your Buffer Block must inherit BufferBlockADT or you will not get credit...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
I need this before the end of the day please :) In Java 10.13 Lab 10...
I need this before the end of the day please :) In Java 10.13 Lab 10 Lab 10 This program reads times of runners in a race from a file and puts them into an array. It then displays how many people ran the race, it lists all of the times, and if finds the average time and the fastest time. In BlueJ create a project called Lab10 Create a class called Main Delete what is in the class you...