0% found this document useful (0 votes)
11 views

Laboratorio 11

The document provides instructions for developing a movie tracking program with Movie and Movies classes. The Movies class should manage a collection of Movie objects, allowing the main program to add movies with a name, rating, and watched count, increment a movie's watched count, and display all movies. Errors should be displayed if trying to add a duplicate movie or increment a nonexistent movie's count. Sample main code and output is provided as an example.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Laboratorio 11

The document provides instructions for developing a movie tracking program with Movie and Movies classes. The Movies class should manage a collection of Movie objects, allowing the main program to add movies with a name, rating, and watched count, increment a movie's watched count, and display all movies. Errors should be displayed if trying to add a duplicate movie or increment a nonexistent movie's count. Sample main code and output is provided as an example.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Viernes 12 de mayo.

De a 2 personas: Subir el informe a más tardar 18 de mayo al Moodle a lo


largo del día. Solamente una persona lo sube a nombre de los 2. Nota válida para el segundo corte.

Presente un informe mostrando el código, así como pantallazos con los resultados, los
códigos obligatoriamente deben poder ser copiados y pegados.

Lenguaje C++. Incluya diagrama de flujos y pseudocódigo, realice debugging para hacer validación
paso a paso.

Para sustentar este laboratorio en clase, se debe escoger una de las 3 siguientes opciones.

1. Compilar el proyecto utilizando los computadores del laboratorio donde se realiza la


clase o en su propio computador portátil que usted debe llevar.
2. Compilarlo en un compilador web como por ejemplo replit, todo desde la nube.
3. Grabar un video de máximo 5 minutos explicando el proyecto, realizando pruebas de
ejecución de código, así como un ejemplo de depuración paso a paso.

Favor tener en cuenta los códigos adjuntos.

For this challenge you are to develop the foundation for a program for movie fanatics to
keep track of what movies they have watched and how many times they watched each
movie.

The program must support the following:

class Movie - models a movie which includes

- movie name

- movie rating (G, PG, PG-13, R)

- watched - the number of times the movie has been watched

class Movies - models a collection of movie objects

Obviously, Movies needs to know about Movie since it is a collection of Movie object
However, our main driver should only interact with the Movies class.

For example. a simple main should be able to

- create a Movies object


- ask the Movies object to add a movie by providing the movie name, rating and watched
count

- ask the Movies object to increment the watched count by 1 for a movie given its name

- ask the Movies object to display all of its movies

Additionally,

- if we try to add a movie whose name is already in the movies collection, we should
display this error to the user

- if we try to increment the watched count for a movie whose name is not in the movies
collection we should display this error to the user

I've provided a basic shell as a starting point for one possible solution that has fully
implemented

- Movie and main

You can choose to use my starting point or start from scratch.

Here is what your project files should look like:

-Movie.h - include file with the Movie class specification

-Movie.cpp - file with the Movie class implementation

-Movies.h - include file with the Movies class specification

-Movies.cpp - file with the Movies class implementation

-main.cpp - the main driver that creates a Movies object and adds and increments movies

Don't create a menu-driven system like we've done in the past -- just concentrate on getting
the program working. Once it is working, you can certainly provide a menu system for the
user

Here is a sample main and the output. Make sure you understand the program flow before
you start coding!

main.cpp

----------

/******************************************************************

* main.cpp

* Test the Movies project

* ***************************************************************/

#include <iostream>

#include "Movies.h"

// Function prototypes

void increment_watched(Movies &movies, std::string name);

void add_movie(Movies &movies, std::string name, std::string rating, int watched);

/******************************************************************

* increment_watched expects a reference to a Movies object

* and the name of the movie to increment the watched count

* If the watched count was incremented successfully it

* displays a success message

* otherwise the watched count could not be incremented

* because the name of the movie was not found

* ***************************************************************/
void increment_watched(Movies &movies, std::string name) {

if (movies.increment_watched(name)) {

std::cout << name << " watch incremented" << std::endl;

} else {

std::cout << name << " not found" << std::endl;

/******************************************************************

* add_movie expects a reference to a Movies object

* and the name of the movie, the rating and the watched count

* If the movie was successfully added to the movies object it

* displays a success message

* otherwise the movie was not added

* because the name of the movie was already in movies

* ***************************************************************/

void add_movie(Movies &movies, std::string name, std::string rating, int watched) {

if (movies.add_movie(name,rating,watched)) {

std::cout << name << " added" << std::endl;

} else {

std::cout << name << " already exists" << std::endl;

int main() {
Movies my_movies;

my_movies.display();

add_movie(my_movies, "Big", "PG-13",2); // OK

add_movie(my_movies,"Star Wars", "PG",5); // OK

add_movie(my_movies,"Cinderella", "PG",7); // OK

my_movies.display(); // Big, Star Wars, Cinderella

add_movie(my_movies,"Cinderella", "PG",7); // Already exists

add_movie(my_movies,"Ice Age", "PG",12); // OK

my_movies.display(); // Big, Star Wars, Cinderella, Ice Age

increment_watched(my_movies,"Big"); // OK

increment_watched(my_movies,"Ice Age"); // OK

my_movies.display(); // Big and Ice Age watched count incremented by 1

increment_watched(my_movies,"XXX"); // XXX not found

return 0;

Sample run

--------------------------------

Sorry, no movies to display


Big added

Star Wars added

Cinderella added

===================================

Big, PG-13, 2

Star Wars, PG, 5

Cinderella, PG, 7

===================================

Cinderella already exists

Ice Age added

===================================

Big, PG-13, 2

Star Wars, PG, 5

Cinderella, PG, 7

Ice Age, PG, 12

===================================

Big watch incremented

Ice Age watch incremented

===================================

Big, PG-13, 3

Star Wars, PG, 5


Cinderella, PG, 7

Ice Age, PG, 13

===================================

XXX not found

You might also like