Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that defines a class Film with the following attributes / data values int id; // the unique id of the film

Write a C++ program that defines a class Film with the following attributes / data values

int id; // the unique id of the film

string name; // the film's name

string description; // the film's description

int runningTime; // the film's running time in minutes <= 180

FilmRating rating; // the film's rating, from the enum FilmRating

Also define the enum FilmRating; you can place the enum definition in the header file of Film;

enum FilmRating {G, PG, PG_13, NC_17, R, UNRATED};

The film class should be defined using a separate Film.h file for all declarations, e.g., attributes and method prototypes. The Film.cpp file will include the implementation of the methods.

Define the following methods for Film

A constructor that has the signature

Film (int id, string name, string description,

int runningTime, string rating);

This constructor should assign the parameters to the appropriate attributes of the class.

Note: you will need to convert the rating parameter to a FilmRating type.

A second constructor that has the signature

Film (int id, string name, string description,

int runningTime, FilmRating rating);

This constructor should assign the parameters to the appropriate attributes of the class.

Include a method print that will print the attributes of Film nicely. This should include the FilmRating attribute as a string;

Create getters and setters for all attributes except id; only a getter should be created for id;.

Note: Figure out a way to initialize id.

If you need helper functions (you will) determine their accessibility, i.e., are they private or public?

Define a Main Routine

Write a main routine that does the following:

Defines a vector of films

Reads a comma delimited file of data on a few films (at least 4)

Creates new Film objects from the data and adds them to the vector

Prints all the Films in the vector after reading all the data from the file.

Notes

Please do not have any user input in this program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

Describe the major regulations governing HRM practices.

Answered: 1 week ago

Question

Identify the elements of a long formal report.

Answered: 1 week ago