-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNovela_historica.cpp
More file actions
91 lines (72 loc) · 2.11 KB
/
Novela_historica.cpp
File metadata and controls
91 lines (72 loc) · 2.11 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
#include "Novela_historica.h"
#include <iostream>
using namespace std;
Novela_historica::Novela_historica(string titulo, Escritor* escritor, int anio, int minutos, string _tema)
: Novela (titulo, escritor, anio, minutos, HISTORICA){
this->tema = recorrer_tema(_tema);
}
Novela_historica::~Novela_historica(){
delete[] tema;
}
char* Novela_historica::obtener_tema(){
return tema;
}
void Novela_historica::copiar_vector(int contador, char* aux, char* &arreglo){
for(int i = 0; i < contador; i++){
aux[i] = arreglo[i];
}
delete[]arreglo;
arreglo = aux;
}
void Novela_historica::almacenar_caracteres(char caracter, char * &arreglo, int &contador){
if(arreglo == nullptr){
contador++;
arreglo = new char[contador];
arreglo[0] = caracter;
}
else{
char* aux = nullptr;
aux = new char[contador + 1];
copiar_vector(contador, aux, arreglo);
aux[contador] = caracter;
contador++;
}
}
char* Novela_historica::recorrer_tema(string tema){
char* arreglo = nullptr;
int tamanio = (int)(tema).length();
int i = 0, contador = 0;
char caracter;
while(tema[i] >= tamanio){
caracter = tema[i];
almacenar_caracteres(caracter, arreglo, contador);
i++;
}
if(contador > 0){
char caracter = '\0';
almacenar_caracteres(caracter, arreglo, contador);
}
return arreglo;
}
void Novela_historica::mostrar_lectura(){
Lectura::mostrar_lectura();
if(this->tema == nullptr)
cout << "Tema desconocido" << endl;
else
cout << "Tema: " << tema << '\n' << endl;
}
string Novela_historica::obtener_tipo(){
return _HISTORICA;
}
int Novela_historica::imprimir_novela_genero(generos genero){
int contador = 0;
if (genero == HISTORICA){
contador += 1;
mostrar_lectura();
}
return contador;
}
bool Novela_historica::es_historica(){return true;}
bool Novela_historica::es_poema(){return false;}
bool Novela_historica::es_novela(){return false;}
bool Novela_historica::es_cuento(){return false;}