Ordenando películas según su estreno ¡Practicando con AzulSchool! [ESP-ENG] | C++

in Develop Spanish2 years ago

¿Qué tal todo? Estoy de vuelta con más programación de la mano del curso gratuito de AzulSchool, este proyecto corresponde al 6/9 y actualmente llevo un 71% completado del curso, me falta poco para lograr la meta pero el tiempo se agota para el comienzo del nuevo semestre universitario y por tanto, menos tiempo disponible para dedicarlo a estos cursos tan geniales.

El proyecto de hoy se enfoca en crear un programa capaz de registrar peliculas y su fecha de estreno, permitiendo que sean ordenadas según su tiempo de haber sido estrenada y también de listar las películas que pertenecen a un mismo año, ingresado por teclado por el usuario. Para lograrlo empecé declarando 3 variables globales que fueron clave en el programa, siguiendo un patrón bastante similar al programa anterior. "char name_movie[20][50]" para los nombres de cada película, "int movie_years[20]" para los años de estreno, que decidí no hacer de tipo "array char" porque me facilita el ordenamiento el que el arreglo sea de tipo "int". Finalmente un contador de tipo int "movie_Counter", que servirá como variable de control para saber cuántas películas se han registrado.

Posteriormente están los prototipos de las funciones del programa, empezando por "validar_numero(char b[])" y "validar_nombre(char nombre[][50])" cuyo nombre ya da indicio de para qué sirven. Estos son filtros para que la entrada por teclado sea correcta y no haya errores fatales durante la ejecución. Sigue "interfaz_Colect(string accion)" que es una pequeña interfaz con un mensaje personalizado que se pasa por su parámetro de tipo string, esta función es reciclada de los anteriores proyectos. Sigue "movie_colecter", que parte de la base de la función con la que se recopilan los datos en el proyecto anterior, pero con modificaciones que la adaptan al enunciado. "order(bool Tnew_or_Fold)" se encarga de ordenar con el método burbuja los registros de películas, el booleano que tiene por parámetro dictamina si el ordenamiento pondrá las películas más nuevas primero o por otro lado serán las más viejas. La función "menu()" también es reciclada, lo que cambia en su estructura se refiera a las condiciones que se deben tomar en cuenta antes de mostrar las peliculas ordenadas, esto lo explicaré en breve. Finalmente "search_Year()" para buscar los registros de un año en concreto.

Entre las funciones de validación tomé de mis apuntes de antiguas asignaciones de la universidad, al igual que la última vez, pero en esta ocasión me enfoqué en tratar de evitar el problema que generaba la función de validación numérica, que enviaba muchas veces el mensaje de error. La función "movie_colecter()", como antes mencionaba, parte del código mencionado en el post anterior, sin embargo, puedo destacar que la validación referente al rango de años va de 1895 a 2100, porque la primera película o más bien video, fue transmitido en ese año, por tanto es incongruente que se registre una película que haya sido estrenada antes de ese año. Lo de 2100 ya fue por el principio de tratar de que un programa sea funcional a través de los años y aunque dudo que alguien dentro de tanto tiempo lo use, es una buena forma de poner en práctica esos consejos, para no olvidarlos, aunque quizás exageré un poco.

What's up? I'm back with more programming from the hand of the free AzulSchool course, this project corresponds to the 6/9 and currently I have 71% completed the course, I have little to achieve the goal but time is running out for the start of the new university semester and therefore less time available to devote to these courses so cool.

Today's project focuses on creating a program capable of recording movies and their release date, allowing them to be sorted according to their time of release and also to list the movies that belong to the same year, entered by keyboard by the user. To achieve this I started declaring 3 global variables that were key in the program, following a pattern quite similar to the previous program. The first one is "char name_movie[20][50]" for the names of each movie, "int movie_years[20]" for the years of release, which I decided not to make of type "array char" because it makes the ordering easier for me if the array is of type "int". Finally a counter of type "movie_Counter", which will serve as a control variable to know how many movies have been registered.

Then there are the prototypes of the program functions, starting with "validate_number(char b[])" and "validate_name(char name[][50])" whose name already gives an indication of what they are for. These are filters so that the keyboard input is correct and there are no fatal errors during execution. Follows "interface_Colect(string action)" which is a small interface with a custom message that is passed by its string parameter, this function is recycled from previous projects. Follows "movie_collector", which starts from the basis of the function with which the data is collected in the previous project, but with modifications that adapt it to the statement. "order(bool Tnew_or_Fold)" is in charge of ordering with the bubble method the movie records, the boolean that has by parameter dictates if the ordering will put the newest movies first or on the other hand will be the oldest ones. The function "menu()" is also recycled, what changes in its structure refers to the conditions that must be taken into account before showing the ordered movies, I will explain this shortly. Finally "search_Year()" to search the records of a specific year.

Among the validation functions I took from my notes from old university assignments, just like last time, but this time I focused on trying to avoid the problem generated by the numeric validation function, which often sent the error message. The function "movie_collector()", as I mentioned before, part of the code mentioned in the previous post, however, I can highlight that the validation regarding the range of years goes from 1895 to 2100, because the first movie or rather video, was broadcast in that year, therefore it is incongruous that a movie that has been released before that year is registered. The 2100 was already for the principle of trying to make a program functional through the years and although I doubt that anyone will use it in such a long time, it is a good way to put those tips into practice, so as not to forget them, although perhaps I exaggerated a little.


Portada post programacion, tech.png
EDITED WITH CANVA

Programación c++.png

image.png

From AzulSchool, by: Angel Sánchez

image.png

image.png

image.png

image.png

image.png

Programación c++.png

Para el ordenamiento decidí que ambos casos estuvieran en la misma función, enviando uno u otro según el booleano en el parámetro (como antes mencionaba). Partiendo del método burbuja se ordenan los años y al mismo tiempo se ordenan también los nombres en el otro arreglo, para que no terminen desincronizados, para los arreglos de tipo char me apoyé en la función "strncpy", que copia el contenido de un arreglo a otro. En la función "Show_Movies" partí de "Show_Students" del proyecto anterior, pero suprimí las partes de promedios individuales, notas mayores, menores y el promedio general. Dejando así, el nombre de la película y su año de estreno, que se mostraran ordenados si antes se llama a la función correspondiente, es decir, "order".

For the sorting I decided that both cases would be in the same function, sending one or the other according to the boolean in the parameter (as I mentioned before). Starting from the bubble method the years are sorted and at the same time the names in the other array are also sorted, so that they do not end up out of sync, for the char arrays I relied on the function "strncpy", which copies the contents of an array to another. In the function "Show_Movies" I started from "Show_Students" of the previous project, but I suppressed the parts of individual averages, major and minor notes and the general average. Leaving the name of the movie and its year of release, which will be displayed in order if the corresponding function, i.e. "order", is called first.

Programación c++.png

image.png

image.png

image.png

Programación c++.png

Para el menú encontramos un poco más de reciclaje, pues la plantilla la he usado ya en bastantes promedios, sin embargo, esta vez la validación incluye que el contador no debe ser "menor o igual a 1" para que se puedan mostrar las películas ordenadas, pues esto significaría que solo se han registrado 2 películas (conteo de 0 a 1). Quise ser un poco más estricto, limitando esta opción a que mínimo se hayan registrado 3 películas para poder mostrarlas ordenas y máximo 20 (conteo de 0 a 19). Este principio también se cumple si se trata de listar películas de un año en concreto. Las opciones van acorde a lo pedido en el enunciado, pero varié un poco las cosas con esa validación extra.

For the menu we found a little more recycling, as I have already used the template in many averages, however, this time the validation includes that the counter should not be "less than or equal to 1" to show the ordered movies, as this would mean that only 2 movies have been registered (count from 0 to 1). I wanted to be a bit stricter, limiting this option to a minimum of 3 movies to be able to show them sorted and a maximum of 20 (count from 0 to 19). This principle also applies if you want to list movies from a specific year. The options go according to the request in the statement, but I varied things a bit with this extra validation.

Programación c++.png

image.png

image.png

image.png

image.png

Programación c++.png

project6.gif
Gif made with Img2Go from an original recording made with VSDC Free Video Editor

Programación c++.png

¡Y bueno... Eso es todo por hoy! Este proyecto tuvo mucho reciclaje, pero es que realmente mucho de lo que necesitaba para hacerlo ya estaba listo de los anteriores proyectos. Cabe destacar que se suponía que esto estuviera publicado en la mañana... Pero tuve una llamada del trabajo que ameritó que fuese a corregir unas pequeñas fallas y para cuando volví, hubo un bajón de luz que duró un buen rato. Son cosas que pasan y pues toca sobrellevarlo, ¡Seguimos adelante para lograr la meta!

And well... That's all for today! This project had a lot of recycling, but it's just that really a lot of what I needed to do it was already ready from previous projects. It's worth noting that this was supposed to be posted in the morning.... But I had a call from work that made it necessary for me to go to correct some small errors and by the time I got back, there was a power outage that lasted a while. These are things that happen and we have to deal with it, we keep going forward to achieve the goal!

Programación c++.png


Redes actualizada.gif


Puedes seguirme por acá si lo deseas:
You can follow me here if you want:

Cuenta secundaria
(Dibujos, edición y juegos) | Secondary account (Drawings, editing and games)

Sort:  


The rewards earned on this comment will go directly to the people( @gabrielrr17 ) sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.

me alegra mucho que vayas excelente con el curso, espero puedas terminarlo creeme que te ayudara mucho para tu vida profesional y veo que te esmeras, aun no tengo conocimientos de programacion como tu y me cuesta entenderlo un poco pero si de peliculas asi que me intereso el post jajaja, sigue asi y veras que podras con ese curso y muchas cosas mas

Gracias @esteva1820, sí, estoy seguro de que ayudará bastante en el futuro el invertir en conocimiento. Saludos y muchas bendiciones!

Bien interesante, pero es muy profundo para mi. Pero me parece muy bueno para ti que hagas ese tipo de cursos, ya que te servirán para tu desarrollo profesional en el futuro. Gracias por compartir. Abrazos @gabrielr29

Graciaas por tan amable comentario, te deseo mucho éxito en tus proyectos!

Dear @gabrielr29,
May I ask you to review and support the Dev Marketing Proposal (https://peakd.com/me/proposals/232) we presented on Conference Day 1 at HiveFest?
The campaign aims to onboard new application developers to grow our ecosystem. If you missed the presentation, you can watch it on YouTube.
You cast your vote for the proposal on Peakd, Ecency,

Hive.blog / https://wallet.hive.blog/proposals
or using HiveSigner.

Thank you!

Congratulations @gabrielr29! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You distributed more than 11000 upvotes.
Your next target is to reach 12000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Support the HiveBuzz project. Vote for our proposal!