Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My program is complete and I have pasted it below. I keep getting the following error for line 29 of main_part2.cpp. Critical error detected c0000374

My program is complete and I have pasted it below. I keep getting the following error for line 29 of main_part2.cpp. Critical error detected c0000374 homework3.exe has triggered a breakpoint. Im thinking I may have a pointer issue or need a destructor? I have also attached the instructions for the assignement and the sample input below. (Sample input must be inputted word for word). Using Visual Studio and this is C++. Thanks!

***** main_part2.cpp

#include "guest.h" #include "auditorium.h" #include #pragma warning(disable:4996) // stop error code that popped up using namespace std;

int main() { Auditorium* auditorium; Guest* tempGuest; int row, col, rowNumb, columnNumb; char guestInfo[30]; // Ask a user to enter a number of rows for an auditorium seating cout > rowNumb; // Ask a user to enter a number of columns for an auditorium seating cout > columnNumb; // auditorium_seating auditorium = new Auditorium(rowNumb, columnNumb); cout > guestInfo; /* we will read line by line **/ while (strcmp(guestInfo, "Q") != 0) { cout > row; cout > col; // Checking if the row number and column number are valid // (exist in the theatre that we created.) if ((*auditorium).checkEdges(row, col) == false) { cout > guestInfo; } // end of while loop return 0; }

****** guest.h

#ifndef GUEST_H #define GUEST_H #include #define MAX 30

class Guest { private: char firstName[MAX]; char lastName[MAX];

public: Guest(); Guest(char *guestInfo); char *getLastName(); char *getFirstName(); char *toString(); };

#endif // #pragma once

****************guest.cpp

#include "guest.h" #include #include #pragma warning(disable:4996) // stop error code that popped up using namespace std;

Guest::Guest()

{ // must use strcpy to copy, as this is C style string in a character array strcpy(firstName, "--"); strcpy(lastName, "--");

}

Guest::Guest(char *guestInfo)

{ char temp[100]; strcpy(temp, guestInfo); char *token = strtok(temp, "-"); strcpy(firstName, token); token = strtok(NULL, "-"); strcpy(lastName, token);

}

char *Guest::getLastName() { return lastName; }

char *Guest::getFirstName() { return firstName; }

char *Guest::toString() { char *str = new char[5]; str[0] = firstName[0]; str[1] = '.'; str[2] = lastName[0]; str[3] = '.'; str[4] = '\0';

return str; }

***********auditorium.h

#include #include "guest.h"

class Auditorium {

private: Guest * *seating; int rowNumb, colNumb;

public: Auditorium(int rowNumb, int colNumb); char* toString(); bool checkEdges(int row, int col); bool assignAt(int row, int col, Guest *tempStudent); Guest* getGuestAt(int row, int col); }; #endif #pragma once

******************auditorium.cpp

#include "auditorium.h" #include using namespace std;

Auditorium::Auditorium(int rowNum, int colNum) { this->rowNumb = rowNum; this->colNumb = colNum; seating = new Guest*[rowNum]; for (int i = 0; i

char * Auditorium::toString()

{ char *str = new char[rowNumb * colNumb + rowNumb + 2]; int c = 0; cout

for (int i = 0; i

bool Auditorium::checkEdges(int row, int col) { return (row >= 0 && row = 0 && col

bool Auditorium::assignAt(int row, int col, Guest* tempStudent) { if (checkEdges(row, col)) { char *fName = seating[row][col].getFirstName(); char *lName = seating[row][col].getLastName(); if (strcmp(fName, "--") == 0 && strcmp(lName, "--") == 0) { seating[row][col] = *tempStudent; return true; } else { return false; } }

else { return false; } }

Guest *Auditorium::getGuestAt(int row, int col) { return *(seating + row) + col; }

image text in transcribed

image text in transcribed

Sample Output: (the inputs entered by a user are shown in bold)

Make sure that your program works at least with this scenario.

Please enter a number of rows for an auditorium seating.

3

Please enter a number of columns for an auditorium seating.

3

Please enter a guest information or enter "Q" to quit.

Mickey-Mouse

A guest information is read.

Mickey-Mouse

Please enter a row number where the guest wants to sit.

1

Please enter a column number where the guest wants to sit.

2

The seat at row 1 and column 2 is assigned to the guest M.M.

----------------

-.-.-.-.-.-.

-.-.-.-.M.M.

-.-.-.-.-.-.

Please enter a guest information or enter "Q" to quit.

Daisy-Duck

A guest information is read.

Daisy-Duck

Please enter a row number where the guest wants to sit.

2

Please enter a column number where the guest wants to sit.

0

The seat at row 2 and column 0 is assigned to the guest D.D.

----------------

-.-.-.-.-.-.

-.-.-.-.M.M.

D.D.-.-.-.-.

Please enter a guest information or enter "Q" to quit.

Clarabelle-Cow

A guest information is read.

Clarabelle-Cow

Please enter a row number where the guest wants to sit.

2

Please enter a column number where the guest wants to sit.

1

The seat at row 2 and column 1 is assigned to the guest C.C.

----------------

-.-.-.-.-.-.

-.-.-.-.M.M.

D.D.C.C.-.-.

Please enter a guest information or enter "Q" to quit.

Max-Goof

A guest information is read.

Max-Goof

Please enter a row number where the guest wants to sit.

0

Please enter a column number where the guest wants to sit.

0

The seat at row 0 and column 0 is assigned to the guest M.G.

----------------

M.G.-.-.-.-.

-.-.-.-.M.M.

D.D.C.C.-.-.

Please enter a guest information or enter "Q" to quit.

Horace-Horsecollar

A guest information is read.

Horace-Horsecollar

Please enter a row number where the guest wants to sit.

5

Please enter a column number where the guest wants to sit.

1

row or column number is not valid.

A guest Horace Horsecollar is not assigned a seat.

Please enter a guest information or enter "Q" to quit.

Sylvester-Shyster

A guest information is read.

Sylvester-Shyster

Please enter a row number where the guest wants to sit.

2

Please enter a column number where the guest wants to sit.

0

The seat at row 2 and column 0 is taken.

Please enter a guest information or enter "Q" to quit.

Snow-White

A guest information is read.

Snow-White

Please enter a row number where the guest wants to sit.

-1

Please enter a column number where the guest wants to sit.

0

row or column number is not valid.

A guest Snow White is not assigned a seat.

Please enter a guest information or enter "Q" to quit.

Jiminy-Criket

A guest information is read.

Jiminy-Criket

Please enter a row number where the guest wants to sit.

0

Please enter a column number where the guest wants to sit.

2

The seat at row 0 and column 2 is assigned to the guest J.C.

----------------

M.G.-.-.J.C.

-.-.-.-.M.M.

D.D.C.C.-.-.

Please enter a guest information or enter "Q" to quit.

Q

4. Part 2 Structs and Arrays (65 points) In this assignment, we will be making a program that reads in guests' information, and create a graduation ceremony seating with a number of rows and columns specified by a user. Then it will attempt to assign each guest to a seat in an auditorium. Use the file main _part2.cpp (attached at the end of this document) Include all the following requested code in new *.cpp and *h files, as needed Step 1. First, you need to create a class Guest. Create guest.cpp and guest h files. It should contain two variables, lastName (char [30]) and firstName (char [30]). Both should be private. In addition, the following functions should be defined. All of them are public Method Guest () Description of the Method Constructs a Guest object by assigning the default string" -- "to both instance variables, lastName and firstName Constructs a Guest object using the string containing guest's info. Use the strtok function to extract first name and last name, then assign them to each instance variable of the Guest class. An example of the ?nput str?ng is David-Johnson Guest (char* guestInfo) char* getLastName () It should return the instance variable lastName char* getFirstName () |It should return the instance variable firstName It should constructor a string containing the initial character of the first name, a period, the initial character of the last name, and a period, then it returns it. An example of such string for the guest David Johnson is D.J char* toString () Step 2. You will be creating a class called Auditorium Create auditorium.cpp and auditorium h files The class AuditoriumSeating will contain a 2-dimensional array called "seating" of Guest objects at its instance variable. The class Auditorium must include the following constructor and methods. (If your class does not contain any of the following methods, points will be deducted.) 4. Part 2 Structs and Arrays (65 points) In this assignment, we will be making a program that reads in guests' information, and create a graduation ceremony seating with a number of rows and columns specified by a user. Then it will attempt to assign each guest to a seat in an auditorium. Use the file main _part2.cpp (attached at the end of this document) Include all the following requested code in new *.cpp and *h files, as needed Step 1. First, you need to create a class Guest. Create guest.cpp and guest h files. It should contain two variables, lastName (char [30]) and firstName (char [30]). Both should be private. In addition, the following functions should be defined. All of them are public Method Guest () Description of the Method Constructs a Guest object by assigning the default string" -- "to both instance variables, lastName and firstName Constructs a Guest object using the string containing guest's info. Use the strtok function to extract first name and last name, then assign them to each instance variable of the Guest class. An example of the ?nput str?ng is David-Johnson Guest (char* guestInfo) char* getLastName () It should return the instance variable lastName char* getFirstName () |It should return the instance variable firstName It should constructor a string containing the initial character of the first name, a period, the initial character of the last name, and a period, then it returns it. An example of such string for the guest David Johnson is D.J char* toString () Step 2. You will be creating a class called Auditorium Create auditorium.cpp and auditorium h files The class AuditoriumSeating will contain a 2-dimensional array called "seating" of Guest objects at its instance variable. The class Auditorium must include the following constructor and methods. (If your class does not contain any of the following methods, points will be deducted.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago