Question: There are some issues with my assignment code, my professor gave me an issue list, please help me fix my code my code: #include #include
There are some issues with my assignment code, my professor gave me an issue list, please help me fix my code
my code:
#include
// Default Static data static Movie::Movie():DEF_NAME("Mystery Movie"),DEF_SEATS(100), DEF_PRICE(11.99){} // default Constructors Movie::Movie(string movie_name_, int movie_seats_, double ticket_price_): DEF_NAME(movie_name_), DEF_SEATS(movie_seats_), DEF_PRICE(ticket_price_){} //Public Destructor Movie::~Movie() { cout << "Movie "<< movie_name_ << "object is no longer showing ..."<< endl; } //Public member functions string Movie::getmovie_name_() const { return movie_name_; } int Movie::getmovie_seats_() const { return movie_seats_; }; double Movie::getticket_price_() const { return movie_price_; } void Movie::setmovie_name_(string& name) { movie_name_ = name } void Movie::setmovie_seats_(int seats) { movie_seats_ = seats } void Movie::setticket_price_(double price) { ticket_price_ = price } // PurchaseTicket double Movie::PurchaseTicket(int tickets_request) { if (tickets_request > movie_seats_) { return -1; } else { getmovie_seats_ -= tickets_request; return (tickets_request * ticket_price_); }
}
void Movie::Display() { cout << setw(40) << left << movie_name_; cout << setw(20) << right << movie_seats_; cout << setw(20) << right << ticket_price_; } class MovieTicketMaster { public: static const int array_size = 32; private: string theater_name_; string theater_loc_; int movie_count_; Movie movie_list[array_size]; public: static const int movie_count_member; static const string theater_name_default; static const string theater_location_; MovieTicketMaster(); MovieTicketMaster(const string the_name, const string the_loc, const int movie_count); ~MovieTicketMaster(); string get_theater_name_() const; string get_theater_loc_() const; int get_movie_count_() const; void set_theater_name_(string the_name); void set_theater_loc_(string the_loc); void set_movie_count_(int movie_count); void init(); void run() const; void Menu() const; void ViewMovies() const; void SearchMovie() const; void FindMovie() const; void PurchaseTicket() const; }
// Public static data static MovieTicketMaster::MovieTicketMaster() :DEF_COUNT(0), DEF_THE_NAME("AMC"), DEF_LOC("My City") {} // default Constructors MovieTicketMaster::MovieTicketMaster(string theater_name_, string theater_loc_, int movie_count_) : DEF_THE_NAME(theater_name_), DEF_LOC(theater_loc_), DEF_COUNT(movie_count_) {} //Public Destructor MovieTicketMaster::~MovieTicketMaster() { cout << "Theater " << theater_name_ << "at" << theater_loc_ << " is currently closed." << endl; } //Public member functions string MovieTicketMaster::get_theater_name_() const { return theater_name_; } string MovieTicketMaster::get_theater_loc_() const { return string(); } string MovieTicketMaster::get_movie_loc_() const { return movie_loc_; } int MovieTicketMaster::get_movie_count_() const { return theater_loc_; } void MovieTicketMaster::set_theater_name_(string the_name) { theater_name_ = the_name } void MovieTicketMaster::set_theater_loc_(string the_loc) { theater_loc_ = the_loc } void MovieTicketMaster::set_movie_count_(int movie_count) { movie_count_ = int movie_count } void MovieTicketMaster::init() { string* p_name = name; int* p_seats = seats; double* p_price = price; //1 const int kSize = 8; string movie_name_[kSize] = { "Avatar","Titanic","star war","Avengers","Jurassic world","The Lion King", "Furious 7","Frozen" } int movie_seats_[kSize] = { 100, 32, 45, 71, 22, 61, 5, 19 } double ticket_price_[kSize]{ 10.99, 20.99, 15.99, 21.99, 12.00, 21.00, 30.00, 14.00 } Movie* p_movie_point = NULL; p_movie_point = movie_list; string* p_movie_name; p_movie_name = movie_name_; int* p_movie_seat; p_movie_seat = movie_seats_; double* p_ticket_price; p_ticket_price = ticket_price_; for (i = 0; i < kSize; i++) { p_movie_point->setmovie_name_(*p_movie_name); p_movie_point->setmovie_seats_(*p_movie_seat); p_movie_point->setticket_price_(*p_ticket_price); p_movie_point ++; } }
void MovieTicketMaster::run() const { int user_select; bool user_case = true; do { Menu(); cin >> user_select; switch (user_select) { case 1: ViewMovies(); break; case 2: SearchMovie(); break; case 3: PurchaseTicket(); break; case 4: cout<< "Bye " user_case = false; break; default: cout<<"error select "
} } while (user_case) }
void MovieTicketMaster::Menu() const { cout << "M O V I E T I C K E T M A S T E R " << endl; cout << "Theater: " << theater_name_ << " at " << theater_loc_ << endl; cout << "1)View all movies "; cout << "2)Search a movie "; cout << "3)Purchase a ticket "; cout << "4)Quit "; }
void MovieTicketMaster::ViewMovies() const { cout << setw(40) << left << "MOVIE TITLE" << setw(20) << right << "MOVIE SEATS" << setw(20) << right << "TICKET PRICE" << endl; for (int i = 0; i < kSize; i++) { Movie_list_[i]->Display(); }; } void MovieTicketMaster::SearchMovie() const { string movie_search; cout << "search movie first: " cin.ignore(); getline(cin, search_movie); Movie* p_moviename = FindMovie(movie_search); if (p_moviename = NULL) cout << "Can't found, sorry. "; else: p_moviename->Display; }
void MovieTicketMaster::FindMovie(string & movie_search) const { Movie* p_movie_point = NULL; p_movie_point = movie_list; for (i = 0; i < kSize; i++) { movie_name_ = p_movie_list->get_movie_name() if (movie_name_ = movie_search) { return p_movie_point; } else { p_movie_point = p_movie_point + 1; }
} return nullptr; }
void MovieTicketMaster::PurchaseTicket() const { string movie_search; cout << "search movie first: " cin.ignore(); getline(cin, search_movie); cout << "how many movie you want? " cin >> ticket_num; Movie* p_Movie = FindMovie(movie_search); if (p_moviename != NULL) { double cost = p_movie_list->Movie::PurchaseTicket(ticket_num); if (cost == 0) cout << "No tickets. "; else cout << "Total cost: " << cost << endl; } else cout << "Ticket not found "; }
int main() {
}
issue list:
- your program can't be compiled (Movie. h)
- missing static data for default values
- init,run ==> Init and Run.
- some functions must be private member functions per specs
- MovieTicketMaster default constructor did not initialize member data with default values
- Init ( ) must move p_movie_name, p_movie_seat, p_ticket_price after the assignments ( p_movie_name++, p_movie_seat++, p_ticket_price++) >>> I think this why your program did not work.
- Not using pointer syntax in ViewMovies >>> this is the main idea of this program.
- replace
p_movie_point = p_movie_point + 1;
by
p_movie++;
- missing main program
I try to fix some issues, but I am not sure my work is that right.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
