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
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
For this assignment, you'll create a Player class that captures information about players on a sports...
For this assignment, you'll create a Player class that captures information about players on a sports team. We'll keep it generic for this assignment, but taking what you learn with this assignment, you could create a class tailored to your favorite sport. Then, imagine using such a class to track the stats during a game. Player Class Requirements Your class should bet set up as follows: Named Player Is public to allow access from other object and assemblies Has a...
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 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...
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...
loanCreator.java: /* * Use constants when necessary, define with proper scope * * Create Person class...
loanCreator.java: /* * Use constants when necessary, define with proper scope * * Create Person class with data fields of firstName and lastName these fields can not change. * * Create Loan class with data fields of Person, loan Amount, term and interest rate * If term is not past in then default value is 36 * If interest is not past in then default value is 5.0 * * In Loan class create method to construct output String *...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of userids on the command line 2. For each userid, display the userid, PID, CPU time, and current command for each process owned by that userid Your output should look similar to this example: practice-script-a doug.jones User: doug.jones PID: 8748 TIME: 00:00:00 COMMAND: /usr/lib/systemd/systemd --user User: doug.jones PID: 8749 TIME: 00:00:00 COMMAND: (sd-pam)    User: doug.jones PID: 8750 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/5 User: doug.jones...
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...