-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
159 lines (130 loc) · 4.53 KB
/
main.cpp
File metadata and controls
159 lines (130 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <iostream>
#include<fstream>
#include<typeinfo>
#include "Video.cpp"
#include "Serie.cpp"
#include "Pelicula.cpp"
using namespace std;
int main(){
bool bandera = true;
int respuesta;
int cont;
Video *videos[3];
videos[0] = new Pelicula(1,"Rapidos y Furiosos 74",120,"Carreras",5);
videos[1] = new Serie(2,"The boys",20,"Superheroes",4,"1.El comienzo",1);
videos[2] = new Pelicula(3,"The Batman",160,"Superheroes",4);
while(bandera){
cout<<"1.Buscar videos por genero o calificacion" <<endl;
cout<<"2.Buscar series por calificacion"<<endl;
cout<<"3.Buscar peliculas por calificacion"<<endl;
cout<<"4.Calificar un video"<<endl;
cout<<"0.Salir"<<endl;
cin>>respuesta;
try{
if(respuesta < 0 || respuesta > 4){
throw respuesta;
}
}
catch(int r){
cout<<r<<" no es una respuesta valida"<<endl;
}
switch(respuesta){
case 1 :
cout<<"Buscar videos por calificacion o genero?"<<endl;
cout<<"1.calificacion 2.genero"<<endl;
cin>>respuesta;
if(respuesta == 1){
cout<<"Que calificacion desea buscar? "<<endl;
cout<<"Rango: 1-5"<<endl;
cin>>respuesta;
cout<<""<<endl;
for(int i=0;i<3;i++){
Video *actual = videos[i];
if(actual->getCalificacion() == respuesta){
actual->Mostrar();
}
}
}
else if(respuesta == 2){
string genero;
cout<<"Escriba el genero a buscar tal y como aparece: "<<endl;
cout<<"Carreras Superheroes"<<endl;
cin>>genero;
cout<<""<<endl;
for(int i=0;i<3;i++){
Video *actual = videos[i];
if (actual->getGenero() == genero){
actual->Mostrar();
}
}
}
break;
case 2 :
cout<<"Seleccione la calificacion a buscar: "<<endl;
cout<<"Rango: 1-5"<<endl;
cin>>respuesta;
try{
if(respuesta < 1 || respuesta > 5){
throw respuesta;
}
}
catch(int r){
cout<<r<<" no es una respuesta valida"<<endl;
}
for(int i=0;i<3;i++){
Video *actual = videos[i];
if(actual->getCalificacion() == respuesta && actual->tipo() == 1 ){
actual->Mostrar();
}
}
cout<<" "<<endl;
break;
case 3 :
cout<<"Seleccione la calificacion a buscar: "<<endl;
cout<<"Rango: 1-5"<<endl;
cin>>respuesta;
try{
if(respuesta < 1 || respuesta > 5){
throw respuesta;
}
}
catch(int r){
cout<<r<<" no es una respuesta valida"<<endl;
}
for(int i=0;i<3;i++){
Video *actual = videos[i];
if(actual->getCalificacion() == respuesta && actual->tipo() == 2){
actual->Mostrar();
}
}
cout<<" "<<endl;
break;
case 4 :
{
int titulo;
cout<<"Seleccione el titulo a calificar: "<<endl;
for(int i=0;i<3;i++){
Video *actual = videos[i];
string nombre = actual->getNombre();
cout<<i+1<<". "<<nombre<<endl;
}
cin>>titulo;
cout<<"Cuantas estrellas le da? "<<endl;
cout<<"Rango: 1 - 5"<<endl;
cin>>respuesta;
Video v1(0,"",0,"",videos[titulo-1]->getCalificacion());
int nueva = v1+respuesta;
videos[titulo-1]->setCalificacion(nueva);
cout<<"Se actualizo la calificacion! "<<endl;
cout<<" "<<endl;
videos[titulo-1]->Mostrar();
cout<<" "<<endl;
break;
}
case 0 :
bandera = false;
break;
}
}
return 0;
}