Advertisement
jtentor

Corrección TP1E05_Mendoza

May 3rd, 2020
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. class Libro
  8. {
  9. private:
  10.     string titulo,autor,editorial;
  11.     int   fecha;
  12.     float precio;
  13.  
  14. public:
  15.     Libro(string, string, string, int, float);
  16.     string getTitulo();
  17.     void Agregar();
  18.     void Mostrar();
  19. };
  20.  
  21. Libro::Libro(string titulo, string autor, string editorial, int fecha, float precio)
  22. {
  23.     this->titulo = titulo;
  24.     this->autor = autor;
  25.     this->editorial = editorial;
  26.     this->fecha = fecha;
  27.     this ->precio = precio;
  28. }
  29.  
  30. string Libro::getTitulo() {
  31.     return this->titulo;
  32. }
  33. void Libro::Agregar()
  34. {
  35.  
  36. }
  37.  
  38. void Libro::Mostrar()
  39. {
  40.  
  41. }
  42.  
  43.  
  44. int main()
  45. {
  46.  
  47.     string titulo, autor, editorial;
  48.     int fecha, i, opcion;
  49.     float precio;
  50.     char eleccion;
  51.  
  52.     vector <Libro> libros;
  53.  
  54.     /*Libro libro = Libro("sabado","roma","arbol",2,2.32);
  55.     libro.Mostrar();*/
  56.  
  57.  
  58.     do
  59.     {
  60.         cout << "1_ CARGAR LIBRO\n";
  61.         cout << "2_ MOSTRAR LIBROS REGISTRADOS\n";
  62.         cout << "3_ SALIR\n";
  63.         cin >> opcion;
  64.  
  65.         switch (opcion)
  66.         {
  67.             case 1:
  68.                 do
  69.                 {
  70.  
  71.                     cout << "Ingrese Titulo\n";
  72.                     cin >> titulo;
  73.                     cout << "Ingrese Autor\n";
  74.                     cin >> autor;
  75.                     cout << "Ingrese Editorial\n";
  76.                     cin >> editorial;
  77.                     cout << "Ingrese Año de Publicación\n";
  78.                     cin >> fecha;
  79.                     cout << "Ingrese precio\n";
  80.                     cin >> precio;
  81.  
  82.                     Libro libro = Libro(titulo, autor, editorial, fecha, precio);
  83.                     libros.push_back(libro);
  84.  
  85.                     cout << "Desea seguir registrando libros? s/n\n";
  86.                     cin >> eleccion;
  87.                 } while ((eleccion == 's') || (eleccion == 'S'));
  88.                 break;
  89.  
  90.             case 2:
  91.                 for(Libro x : libros) {
  92.                     std::cout << x.getTitulo() << std::endl;
  93.                 }
  94.                 break;
  95.             default:
  96.                 break;
  97.         }
  98.     } while (opcion != 3);
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement