How do you create movie queue?

Hello guys, I am currently working on the movie netflix queue project.
I need help with some codes.
This is how far I got to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
int main()
{
  int choice;
  do
  { 
     cout << "1. Display Movie Queue " << endl;
     cout << "2. Add Movie to Queue " << endl;
     cout << "3. Edit Movie in Queue" << endl;
     cout << "4. Remove Movie from Queue " << endl;
     cout << "5. Search for Movie in Queue " << endl;
     cout << "6. Exit Program " << endl;
     cout << "Enter option : ";
     cin >> choice;
 if(choice == 1) // Checking if user selected option 1
     {
 	cout << "The movie queue is empty! Please add movies to the queue. " <<   endl;
     }

Right now, option 1 says "the movie is empty".
Here is the question.
How can I create a code for actual adding the movie to queue?
Any suggestion???
What do you know about data structures?
As 'Zhuge' mentioned, you can use data structures that hold data. However, if you don't know data structures, then you can use vectors (they're pretty simple).

http://www.cplusplus.com/reference/vector/vector/push_back/

You can do something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vector<string>myVec;
string movieName;

if (choice == 2)
{
  cout << "Enter Movie: ";                         // ask for moviename
  getline(cin, movieName);
  myVec.pushback(movieName);               // store moviename in vector

}
if (choice == 1)
{
  for (int i=0; i < myVec.size(); i++)        // iterates over entire vector and prints out all data
  {
     cout << myVec[i] << endl;
  }
}
I think you're expected to use some other data structure as a vector or array simply will not do.

As Zhuge implied, it's all about data structures; choosing and using the right one.
Last edited on
Topic archived. No new replies allowed.