Click here to Skip to main content
15,400,390 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
USE DEV C++

MENU TYPE FOLLOW INSTRUCTIONS

MACHINE PROBLEM

A new video store in your neighborhood is about to open. However, it does not have a program to keep track of its videos and customers. The store managers want someone to write a program for their system so that the video store can operate.

The program will require you to design 2 ADTs as described below:

[1] VIDEO ADT

Data

Operations

Video_ID (preferably int, auto-generated)

Movie Title

Genre

Production

Number of Copies



[1] Insert a new video

[2] Rent a video; that is, check out a video

[3] Return a video, or check in, a video

[4] Show the details of a particular video

[5] Display all videos in the store

[6] Check whether a particular video is in the store





[2] CUSTOMER PARENT ADT

Data

Operations

Customer_ID (preferably int, auto-generated)

Name

Address

[1] Add Customer

[2] Show the customer details

[3] Print list of all customers

[3] CUSTOMER-RENT CHILD ADT

Customer_ID (

Video_ID (of all rented videos of a customer)

[1] Rent a Video (Add to the video ids rented)

[2] Return a Video (Remove the video id from the list)

[3] Print list of all videos rented by each customer



The program will require you to maintain 3 text files with specifications below:

Text File

Requirements

[1] VIDEO Text File

[1] Will store the information about the Videos

[2] Should contain the following by default:

5 Horror Movies

5 Romance Movies

5 Sci-Fi Movies

5 Action Movies

5 Comedy Movies

**Must be authentic and true.**

[2] CUSTOMER Text File

[1] Will store the basic information about the Customers

[2] Should contain at least 10 customers by default

**Must be authentic and true.**

[3] CUSTOMER-RENT

[1] Will store all customers that RENT a VIDEO

[2] Will store all the Video_IDs of all rented videos

[3] Will delete Video_IDs and Customer_ID when videos are returned

NOTE: IF YOU FIND THE NEED TO ADD OR MAKE ALTERATIONS TO THE SPECIFICATIONS OF THE ADT AND TEXT FILES ABOVE, PLEASE DO SO. JUST MAKE SURE THAT YOU HAVE AN ACCEPTABLE LOGICAL REASON.

INSTRUCTIONS:

The program will have the following options/menus:
[1] New Video
[2] Rent a Video
[3] Return a Video
[4] Show Video Details
[5] Display all Videos
[6] Check Video Availability
[7] Customer Maintenance
[1] Add New Customer
[2] Show Customer Details
[3] List of Videos Rented by a Customer
[8] Exit Program

Follow the suggested screen dialogs below for each of the option above:


















OTHER REQUIREMENTS:

You must store your videos in a linked list when you retrieved them from the text file. They must also be stored in a linked list data structure during processing. Saving back to the text file will be done when the user chooses [8] Exit Program.
You must store you customers in a queue when you retrieved them from the text file. They must also be stored in a queue during processing. Saving back to the text file will be done when the user chooses [8] Exit Program.
Rented videos will be stored in a stack and will be saved in the CUSTOMER-RENT text file when the user chooses [8] Exit Program.
Use data structures, files, functions, ADTs, STLs and algorithms in your program.
Put necessary comments to your program.
Provide error messages whenever necessary.

What I have tried:

//As of now, these were the codes that we and my group mates have done:
//We are trying our best to make the program work in onlinegdb.com
#include <iostream>
#include <list>
#include <iterator>
using namespace std;

// Data Structure for storing movies
class movieList
{
public:
        int movieCode;
        string movieTitle;
        string movieGenre;
        int yearReleased;

        movieList(int movieCode, string movieTitle, string movieGenre, int yearReleased) {
                this->movieCode = movieCode;
                this->movieTitle = movieTitle;
                this->movieGenre = movieGenre;
                this->yearReleased = yearReleased;
        }
};

// class of movies list
class moviesLL
{
private:
        list<movieList> movies;   // list of movies having above DS

public:
        // constructor which will show up the menu and will work accordingly
        moviesLL() {
                int option = 5;
                do {
                        option = menu(); // taking the option user have input

                        switch(option) {
                                case 1:
                                        insertMovie();
                                        break;

                                case 2:
                                        deleteMovie();
                                        break;

                                case 3:
                                        appendMovie();
                                        break;

                                case 4:
                                        showMovieDetails();
                                        break;

                                case 5:
                                        printMovieList();
                                        break;

                                case 6:
                                        quitProgram();
                                        break;

                                default:
                                        cout << "\nInvalid Input........TRY AGAIN!!!";
                        }
                } while(option != 6);  // 6th option is for quitting the program
        }

// Menu having options for what user can do
        int menu() {
                cout << "\n\nMenu:";
                cout << "\n1. Insert new Movie";
                cout << "\n2. Rent a Movie";
                cout << "\n3. Return a Movie";
                cout << "\n4. Show a Movie details";
                cout << "\n5. Print Movies List";
                cout << "\n6. Quit the Program\n";

                cout << "\nEnter your Choice: ";
                int option;             cin >> option;

                return option;
        }

// Function to insert a movie in movies list
        void insertMovie() {
                cout << "\nEnter new Movie Code: ";
                int movieCode;  cin >> movieCode;

                cout << "\nEnter new Movie Title: ";
                string movieTitle;
                cin.ignore();
                getline(cin, movieTitle);

                cout << "\nEnter new Movie Genre: ";
                string movieGenre;
                cin.ignore(0);
                getline(cin, movieGenre);

                cout << "\nEnter new Movie Releasing Year: ";
                int yearReleased;       cin >> yearReleased;

// pushing an object of movieList DS created above in list of movies
                movies.push_back(movieList(movieCode, movieTitle, movieGenre, yearReleased));

                return;
        }

// Function to delete a movie i.e., when user rent a movie
        void deleteMovie() {
                cout << "\nEnter the Movie Code of movie you want: ";
                int movieCode;  cin >> movieCode;

                list<movieList> :: iterator it;
                bool movieFound = false;
                for(it = movies.begin(); it != movies.end(); it++) {
                        if(it->movieCode == movieCode) {
                                movieFound = true;
                                movies.erase(it);
                                cout << "\nMovie Rented :)";
                                break;
                        }
                }

                if(!movieFound) {
                        cout << "\nNo Movie found with that Movie Code!!!";
                }

                return;
        }

// Function to add a movie i.e., when user return the movie
        void appendMovie() {
                cout << "\nEnter details of Movie you want to return:";

                cout << "\nEnter your Movie Code: ";
                int movieCode;  cin >> movieCode;

                cout << "\nEnter your Movie Title: ";
                string movieTitle;
                cin.ignore();
                getline(cin, movieTitle);

                cout << "\nEnter your Movie Genre: ";
                string movieGenre;
                cin.ignore();
                getline(cin, movieGenre);

                cout << "\nEnter your Movie Releasing Year: ";
                int yearReleased;       cin >> yearReleased;

                movies.push_back(movieList(movieCode, movieTitle, movieGenre, yearReleased));

                return;
        }

// Function to show the details of movie user wants to see
        void showMovieDetails() {
                cout << "\nEnter the Movie Title you want to look for details:\n";
                string movieTitle;
                cin.ignore();
                getline(cin, movieTitle);

                list<movieList> :: iterator it;
                bool movieFound = false;
                for(it = movies.begin(); it != movies.end(); it++) {
                        if(it->movieTitle == movieTitle) {
                                movieFound = true;
                                cout << "\nMovie Details:";
                                cout << "\nMovie Code: " << it->movieCode;
                                cout << "\nMovie Title: " << it->movieTitle;
                                cout << "\nMovie Genre: " << it->movieGenre;
                                cout << "\nMovie Releasing Year: " << it->yearReleased;
                                break;
                        }
                }

                if(!movieFound) {
                        cout << "\nNo Movie found with that Title :(";
                }

                return;
        }

// Function to print details of all movies
        void printMovieList() {
                list<movieList> :: iterator it;
                bool movieFound = false;
                cout << "\nMovies Details:";
                for(it = movies.begin(); it != movies.end(); it++) {
                        movieFound = true;
                        cout << "\n\nMovie Code: " << it->movieCode;
                        cout << "\nMovie Title: " << it->movieTitle;
                        cout << "\nMovie Genre: " << it->movieGenre;
                        cout << "\nMovie Releasing Year: " << it->yearReleased;
                }

                if(!movieFound) {
                        cout << "\nSorry!! Currently, we're not having any movies in our store :(";
                }

                return;
        }

// Destructor
        void quitProgram() {
                movies.clear(); // clear will clear the complete movie list

                return;
        }
};




int main() {
        moviesLL m; // creating an object to call constructor

        return 0;
}
Posted
Updated 5-Jul-22 9:12am
v4
Comments
Richard MacCutchan 5-Jul-22 10:36am
   
Option 8 is for quitting the program. Option 7 (as I understand the requirements) has 3 sub-options concerned with Customer maintenance. You just add another switch block inside the option 7 case.

Compiling does not mean your code is right! :laugh:
Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send.

So now you enter the second stage of development (in reality it's the fourth or fifth, but you'll come to the earlier stages later): Testing and Debugging.

Start by looking at what it does do, and how that differs from what you wanted. This is important, because it give you information as to why it's doing it. For example, if a program is intended to let the user enter a number and it doubles it and prints the answer, then if the input / output was like this:
Input   Expected output    Actual output
  1            2                 1
  2            4                 4
  3            6                 9
  4            8                16
Then it's fairly obvious that the problem is with the bit which doubles it - it's not adding itself to itself, or multiplying it by 2, it's multiplying it by itself and returning the square of the input.
So with that, you can look at the code and it's obvious that it's somewhere here:
C++
int Double(int value)
   {
   return value * value;
   }

Once you have an idea what might be going wrong, start using the debugger to find out why. Put a breakpoint on the first line of the method, and run your app. When it reaches the breakpoint, the debugger will stop, and hand control over to you. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to).
Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. Did it do what you expect? If so, move on to the next line.
If not, why not? How does it differ?
Hopefully, that should help you locate which part of that code has a problem, and what the problem is.
This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. And like all skills, it only improves by use!
   
Try with starting some Learn C++ tutorial or some video tutorial.

some tips: use functions and classes with understandable names and install some IDE like Visual Studio.
   
This question seems to be a very popular Homework. There also seems to be a solution for a fee.
https://www.chegg.com/homework-help/questions-and-answers/new-video-store-neighborhood-open-however-program-keep-track-videos-customers-store-manage-q72115094
https://answerhappy.com/viewtopic.php?t=223120
https://www.numerade.com/ask/question/c-program-a-new-video-store-in-your-neighborhood-is-about-to-open-however-it-does-not-have-a-program-to-keep-track-of-its-videos-and-customers-the-store-managers-want-someone-to-write-a-prog-46828/
and now
https://www.codeproject.com/Questions/5336548/How-do-I-Modify-our-while-following-the-requiremen

If you are really serious about solving it yourself here are the first steps:

As usual, the first thing to do would be to analyze which objects are really needed and which methods and data they contain. However, the task assigner has already largely prepared the analysis.Data types would still make sense to choose.
// The program will require you to design 2 ADTs as described below :
// [1] VIDEO ADT
// [2] CUSTOMER ADT

There are obviously 2 main tasks for which data structures can initially be implemented separately from each other. The first data structure takes care of the movies, with the constraint that movies should be managed in a list. The list should also be saved in a file and reloaded. All operations related to movies can be grouped in one class.

I would save the declarations for videos under video.h, the implementation under video.cpp.

For example, the video.h could look like this:
C++
// video.h

...

typedef  enum  { Horror, Romance, SciFi, Action, Comedy } GENRE;

typedef struct { 
	int video_id;   // auto - generated
	string title;
	GENRE genre;
	int release_year;
	int numcopys;
} Movie;

class Video {
private:  
	// Data
	list <Movie> MovieLst;
public:
	// Operations
	void Insert(Movie);              // New video
	bool Check_Out(int video_id);    // Rent a video
	void Check_In(int video_id);     // Return a video
	void ShowDetails(int video_id);  // Display videodata
	void ListAll();                  // Display all videos in the store
	int Search(string title);        // Check whether a particular video is in the store
	int Load(string file);           // Load Data from File
	int Save(string file);           // Save Data to File
};

Since the entire project consists of at least two administrations, there are some arguments against moving the program flow to one class. I would leave the menus and calling the methods in the main program.
The user input and the display of the menus can be postponed until the development of the classes is complete. For testing and debugging, I would start with simple test programs to be able to test methods without having to deal with user input.

C++
// Simple Test
int main() 
{
	Video  vt;			 // create the Video object
	Movie  tmp;   
	string title("Demo Title");

	// Input Data  
	tmp.video_id = 0;    // auto - generated, set to 0
	tmp.title = title;
	tmp.genre = SciFi;
	tmp.release_year = 2015; 
	tmp.numcopys = 1;

	// Operations
	vt.Insert(tmp);                       // Insert New video

	int video_id = vt.Search(title);      // Search Video

	bool chk = vt.Check_Out(video_id);    // Rent a video

	if (chk == true)
		cout << "Rented the Video " << title.c_str() << "\n";
	else
		cout << "Error: The Video " << title.c_str() << " was not found\n";

	int cnt = vt.Save("filmbase.dat");   // Save Data to File

	cout << "Saved " << cnt << " Datasets.\n";

	return 0;
}
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900