Laboratorio 11
Laboratorio 11
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.
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.
- movie name
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.
- ask the Movies object to increment the watched count by 1 for a movie given its name
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
-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
* ***************************************************************/
#include <iostream>
#include "Movies.h"
// Function prototypes
/******************************************************************
* ***************************************************************/
void increment_watched(Movies &movies, std::string name) {
if (movies.increment_watched(name)) {
} else {
/******************************************************************
* and the name of the movie, the rating and the watched count
* ***************************************************************/
if (movies.add_movie(name,rating,watched)) {
} else {
int main() {
Movies my_movies;
my_movies.display();
add_movie(my_movies,"Cinderella", "PG",7); // OK
increment_watched(my_movies,"Big"); // OK
increment_watched(my_movies,"Ice Age"); // OK
return 0;
Sample run
--------------------------------
Cinderella added
===================================
Big, PG-13, 2
Cinderella, PG, 7
===================================
===================================
Big, PG-13, 2
Cinderella, PG, 7
===================================
===================================
Big, PG-13, 3
===================================