Help a beginner with homework!

I am a real beginner that really want to learn and i am not asking you to do my assignment but only to refer me to what i should use.

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.

There is to be a menu that handles the films. There is going to be possible to register new films, print list of films, search for films and exit program.

And then it contains a tip, create a vector that makes it possible to store the movies during running.

well so far i have this but feel free to give me a new base line!


#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Film;

char Titel[30];
char Typ[20];


int main()
{
{
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";

}
{
char Film[10];
vector<Film> NyFilm;
}
while(true)
{



char Menyn;
cin >> Menyn;

if (Menyn == '1')
cout << "Här är listan\n";

else if (Menyn == '2')
{
cout << "Film titel:\n";
cout << "Film typ:\n";

}

if (Menyn == 'Q' || Menyn == 'q')
{
break;
}


}

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Film
{
public:
    Film();
    //other public methods including orhter constructors, accessors, andprocessors
private:
    //class variables and private methods
    //you should use strings rather than your own arrays of characters
};

Film::Film()
{
    //This is a default no-arguments constructor for your class
}

void Film::methodName()
{
    //This is a method of your class
}


Use code tags.
Hi

Thx for the reply but i really dont understand most of the things you wrote for me. I guess i have to try really hard and fins things in my book. :(
closed account (o3hC5Di1)
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
Thank you for the reply because it helped. I think the reason i don't understand some things is because it's in english and im learning in swedish

for example when you say "get user input" and "evaluate input" i don't know what you mean by that because i do not understand the words. Sorry if i am being a pain in the ass but could you explain what that means.


But so far i have this:


class Film

string Titel[30];
string Typ[20];

    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);


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";

   while(true)
{



    char Menyn;
    cin >> Menyn;

    if (Menyn == '1')
        cout << "Här är listan\n";

      else if (Menyn == '2')
        {
            cout << "Film titel:\n";


            cout << "Film typ:\n";

        }

    if (Menyn == 'Q' || Menyn == 'q')
        {
        break;
        }


   //get user input
   //evaluate the input
}
int main()
{
    {
    menu(); //call menu function
    }


}


Is it in the right so far?
Topic archived. No new replies allowed.