Hi there,
Let's break the assignment down:
The assignment is to create a class named Film. A film is described by two textstrings named title and type. For example, DVD och Bluray. |
GRex2595 gave you a good start on the film class. The fact that his, basic, code doesn't mean much to you means you lack basic understanding of classes in C++. Please refer to following two pages for an explanation:
http://www.cplusplus.com/doc/tutorial/classes/
http://www.cplusplus.com/doc/tutorial/classes2/
There is to be a menu that handles the films. |
You already have a basis for that, but I would suggest giving this menu its own function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
void menu()
{
cout << "***MENY***\n" << endl;
cout << "[1] Film lista\n";
cout << "[2] Lägga till ny film\n";
cout << "[Q] Q för att avsluta\n";
cout << "Ange val:\n";
//get user input
//evaluate the input
}
int main()
{
menu(); //call menu function
}
|
Explanation of the things needed for this:
http://www.cplusplus.com/doc/tutorial/functions/
http://www.cplusplus.com/doc/tutorial/functions2/
http://www.cplusplus.com/doc/tutorial/basic_io/
There is going to be possible to register new films, print list of films, search for films and exit program. Create a vector that makes it possible to store the movies during running. |
You could go two ways here, the easiest to grasp is for each of these actionsto have its own function, for example:
1 2 3
|
void register_film(const film f, vector<film>& film_container);
void print_filmlist(const vector<film>& film_container);
film search_film(string filmname, const vector<film>& film_container);
|
The second way would be to create another class called filmlist, which contains member functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
class filmlist
{
public:
void register_film(const film& f)
{
container.push_back(f);
}
void print_filmlist(); //print every element of container to the screen
film search(const film& f); //search the film in the container and return it
private:
std::vector<film> container;
}
|
Between all these examples and links, I think you should have a decent base to get started.
Please do let us know if you encounter any further problems.
All the best,
NwN