Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main.cpp
- #include <cstdlib>
- #include <fstream>
- #include <iostream>
- #include "Miembro.h"
- #include "Alumno.h"
- #include "Profesor.h"
- #include "CListaT.h"
- #include "GestorReferencias.h"
- #include <cstdlib>
- using namespace std;
- int main(int argc, char** argv) {
- ifstream archIn("Miembros.csv", ios::in);
- if (!archIn) {
- cerr << "No se puede abrir el archivo archIn" << endl;
- exit(1);
- }
- ifstream archIn2("libros.csv", ios::in);
- if (!archIn2) {
- cerr << "No se puede abrir el archivo archIn" << endl;
- exit(1);
- }
- GestorReferencias objGestor;
- objGestor.leeDatos(archIn);
- int codM;
- while(1){
- archIn2 >> codM;
- if (archIn2.eof()) break;
- archIn2.get();
- objGestor.ActualizarCampos(codM, archIn2);
- }
- ofstream archOut("reporte.txt", ios::out);
- if (!archOut){
- cerr << "No se pudo crear el archivo " << endl;
- exit(1);
- }
- objGestor.imprimirReporte(archOut);
- return 0;
- }
- //CLISTAT.h
- #ifndef CLISTAT_H
- #define CLISTAT_H
- #include "CNodoT.h"
- #include <iostream>
- template <typename TDATO>
- class CListaT {
- private:
- CNodoT<TDATO>* lista;
- CNodoT<TDATO>* it;
- public:
- CListaT() {
- lista = NULL, it = NULL;
- }
- void insertar(TDATO&);
- void imprimir();
- void imprimir(std::ostream&);
- void eliminar();
- void eliminar(int);
- TDATO get_it();
- void reset_it();
- };
- template <typename TDATO>
- TDATO CListaT<TDATO>::get_it(){
- //Este método retornará el dato actual y avanzará el puntero al siguiente nodo
- if (it==NULL) return NULL; //Si la lista esta vacia o estamos al final.
- CNodoT<TDATO>* nodoActual = it;
- it = it->sig;
- return nodoActual->dato;
- }
- template <typename TDATO>
- void CListaT<TDATO>::reset_it(){
- //Este método reiniciará el iterador interno y lo colocará al inicio de la lista
- it = lista;
- }
- template <typename TDATO>
- void CListaT<TDATO>::imprimir() {
- CNodoT<TDATO> *nodoRec = this->lista;
- int i = 0;
- while (nodoRec != NULL) {
- //std::cout << ++i << ") " << std::endl;
- nodoRec->dato->imprimirDatos(std::cout);
- nodoRec = nodoRec->sig;
- }
- }
- template <typename TDATO>
- void CListaT<TDATO>::imprimir(std::ostream& out) {
- CNodoT<TDATO> *nodoRec = this->lista;
- int i = 0;
- while (nodoRec != NULL) {
- //out << ++i << ") " << nodoRec->dato << std::endl;
- nodoRec->dato->citar(out);
- nodoRec = nodoRec->sig;
- }
- }
- template <typename TDATO>
- void CListaT<TDATO>::eliminar(int codigo) {
- CNodoT<TDATO> *nodoRec = this->lista, *nodoAnt = NULL;
- while (nodoRec != NULL) {
- if ((*nodoRec->dato) == codigo)
- break;
- nodoAnt = nodoRec;
- nodoRec = nodoRec->sig;
- }
- if (nodoRec != NULL) {
- if (nodoAnt != NULL) { //Si no es el primer elemento
- nodoAnt->sig = nodoRec->sig;
- nodoRec->sig = NULL;
- delete nodoRec->dato;
- delete nodoRec;
- } else { //Si es el primer elemento
- delete nodoRec->dato;
- this->lista = nodoRec->sig;
- delete nodoRec;
- }
- }
- }
- template <typename TDATO>
- void CListaT<TDATO>::eliminar() {
- CNodoT<TDATO> *nodoRec = this->lista, *nodoAnt = NULL;
- while (nodoRec != NULL) {
- delete nodoRec->dato;
- nodoAnt = nodoRec;
- nodoRec = nodoRec->sig;
- delete nodoAnt;
- }
- this->lista = nodoRec;
- }
- template <typename TDATO>
- void CListaT<TDATO>::insertar(TDATO& _dato) {
- //Inserta ordenadamente
- CNodoT<TDATO> *nodoRec, *nodoAnt = NULL, *nodoNuevo;
- nodoRec = this->lista;
- nodoNuevo = new CNodoT<TDATO>;
- nodoNuevo->dato = _dato;
- //Se recorre hasta encontrar la posición para insertar:
- while (nodoRec != NULL) {
- if (*(nodoRec->dato) > *(nodoNuevo->dato))
- break;
- nodoAnt = nodoRec;
- nodoRec = nodoRec->sig;
- }
- //Inserción del nuevo dato:
- nodoNuevo->sig = nodoRec;
- if (nodoAnt != NULL) //Cuando sí habían datos
- nodoAnt->sig = nodoNuevo;
- else //Cuando la lista estaba vacía
- this->lista = nodoNuevo;
- }
- #endif /* CLISTAT_H */
- //CNODOT.H
- #ifndef CNODOT_H
- #define CNODOT_H
- #include <cstdlib>
- template <typename TDATO> class CListaT;
- template <typename TDATO>
- class CNodoT {
- private:
- TDATO dato;
- CNodoT<TDATO> * sig;
- public:
- CNodoT() {
- sig = NULL;
- }
- friend class CListaT<TDATO>;
- };
- #endif /* CNODOT_H */
- //CLISTALIB.H
- #ifndef CLISTATLIB_H
- #define CLISTATLIB_H
- #include "CNodoTlib.h"
- #include <iostream>
- template <typename TDATO>
- class CListaTlib {
- private:
- CNodoTlib<TDATO>* lista;
- CNodoTlib<TDATO>* it;
- public:
- CListaTlib() {
- lista = NULL, it = NULL;
- }
- void insertar(TDATO&);
- void imprimir();
- void imprimir(std::ostream&);
- void eliminar();
- void eliminar(int);
- TDATO get_it();
- void reset_it();
- };
- template <typename TDATO>
- TDATO CListaTlib<TDATO>::get_it(){
- //Este método retornará el dato actual y avanzará el puntero al siguiente nodo
- if (it==NULL) return NULL; //Si la lista esta vacia o estamos al final.
- CNodoTlib<TDATO>* nodoActual = it;
- it = it->sig;
- return nodoActual->dato;
- }
- template <typename TDATO>
- void CListaTlib<TDATO>::reset_it(){
- //Este método reiniciará el iterador interno y lo colocará al inicio de la lista
- it = lista;
- }
- template <typename TDATO>
- void CListaTlib<TDATO>::imprimir() {
- CNodoTlib<TDATO> *nodoRec = this->lista;
- int i = 0;
- while (nodoRec != NULL) {
- //std::cout << ++i << ") " << std::endl;
- nodoRec->dato.L_imprimirDatos(std::cout);
- nodoRec = nodoRec->sig;
- }
- }
- template <typename TDATO>
- void CListaTlib<TDATO>::imprimir(std::ostream& out) {
- CNodoTlib<TDATO> *nodoRec = this->lista;
- int i = 0;
- while (nodoRec != NULL) {
- //out << ++i << ") " << nodoRec->dato << std::endl;
- nodoRec->dato.L_imprimirDatos(out);
- nodoRec = nodoRec->sig;
- }
- }
- template <typename TDATO>
- void CListaTlib<TDATO>::eliminar(int codigo) {
- CNodoTlib<TDATO> *nodoRec = this->lista, *nodoAnt = NULL;
- while (nodoRec != NULL) {
- if ((*nodoRec->dato) == codigo)
- break;
- nodoAnt = nodoRec;
- nodoRec = nodoRec->sig;
- }
- if (nodoRec != NULL) {
- if (nodoAnt != NULL) { //Si no es el primer elemento
- nodoAnt->sig = nodoRec->sig;
- nodoRec->sig = NULL;
- delete nodoRec->dato;
- delete nodoRec;
- } else{ //Si es el primer elemento
- delete nodoRec->dato;
- this->lista = nodoRec->sig;
- delete nodoRec;
- }
- }
- }
- template <typename TDATO>
- void CListaTlib<TDATO>::eliminar() {
- CNodoTlib<TDATO> *nodoRec = this->lista, *nodoAnt = NULL;
- while (nodoRec != NULL) {
- delete nodoRec->dato;
- nodoAnt = nodoRec;
- nodoRec = nodoRec->sig;
- delete nodoAnt;
- }
- this->lista = nodoRec;
- }
- template <typename TDATO>
- void CListaTlib<TDATO>::insertar(TDATO& _dato) {
- //Inserta ordenadamente
- CNodoTlib<TDATO> *nodoRec, *nodoAnt = NULL, *nodoNuevo;
- nodoRec = this->lista;
- nodoNuevo = new CNodoTlib<TDATO>;
- nodoNuevo->dato = _dato;
- //Se recorre hasta encontrar la posición para insertar:
- while (nodoRec != NULL) {
- if ((nodoRec->dato) > (nodoNuevo->dato))
- break;
- nodoAnt = nodoRec;
- nodoRec = nodoRec->sig;
- }
- //Inserción del nuevo dato:
- nodoNuevo->sig = nodoRec;
- if (nodoAnt != NULL) //Cuando sí habían datos
- nodoAnt->sig = nodoNuevo;
- else //Cuando la lista estaba vacía
- this->lista = nodoNuevo;
- }
- #endif /* CLISTATLIB_H */
- //CNODOTLIB.H
- #ifndef CNODOTLIB_H
- #define CNODOTLIB_H
- #include <cstdlib>
- template <typename TDATO> class CListaTlib;
- template <typename TDATO>
- class CNodoTlib {
- private:
- TDATO dato;
- CNodoTlib<TDATO> * sig;
- public:
- CNodoTlib() {
- sig = NULL;
- }
- friend class CListaTlib<TDATO>;
- };
- #endif /* CNODOTLIB_H */
- //GestorReferencia.h
- #ifndef GESTORREFERENCIAS_H
- #define GESTORREFERENCIAS_H
- #include "CListaT.h"
- #include "Miembro.h"
- class GestorReferencias {
- private:
- CListaT<Miembro*> lstMiembros;
- public:
- GestorReferencias();
- void leeDatos(std::istream &);
- void imprimirLista();
- void eliminarElemento(int);
- void eliminarLista();
- void ActualizarCampos(int, std::istream &);
- void imprimirReporte(std::ostream &);
- ~GestorReferencias();
- };
- #endif /* GESTORREFERENCIAS_H */
- //GestorReferencia.cpp
- #include "GestorReferencias.h"
- #include "Alumno.h"
- #include "Profesor.h"
- GestorReferencias::GestorReferencias() {
- //this->lstPapers = NULL;
- //this->lstPapers = new CListaT<Paper*>;
- }
- GestorReferencias::~GestorReferencias() {
- this->lstMiembros.eliminar();
- }
- void GestorReferencias::leeDatos(std::istream& in) {
- char tipo;
- Miembro * lstMiembro[100];
- //Paper * auxPaper;
- //CListaT<Paper*> lstPapers;
- //this->lstPapers = CListaT<Paper*> *lstPapers;
- int num = 0;
- while (1) {
- if (in.eof()) break;
- if (in.peek() == EOF) break;
- in >> tipo;
- in.get();
- if (tipo == 'A') {
- lstMiembro[num] = new Alumno;
- //auxPaper = new ConferencePaper;
- }else if(tipo == 'P') {
- lstMiembro[num] = new Profesor;
- //auxPaper = new JournalPaper;
- }
- lstMiembro[num]->leerDatos(in);
- //auxPaper->leerDatos(in);
- this->lstMiembros.insertar(lstMiembro[num]);
- num++;
- }
- }
- void GestorReferencias::imprimirLista() {
- this->lstMiembros.imprimir();
- }
- void GestorReferencias::eliminarLista() {
- this->lstMiembros.eliminar();
- }
- void GestorReferencias::eliminarElemento(int id_paper){
- this->lstMiembros.eliminar(id_paper);
- }
- void GestorReferencias::ActualizarCampos(int cod, std::istream& in){
- /*Miembro *nodoRec = this->lstMiembros;
- while(nodoRec!=NULL){
- if(nodoRec->getCodigo() == cod)
- break;
- nodoRec = nodoRec->;
- }
- Libro* newLibro = new Libro;
- newLibro->L_leerDatos(in);
- (nodoRec->listaDeLibro)->LB_insertar(newLibro);*/
- Miembro* auxP;
- this->lstMiembros.reset_it();
- while(1){
- auxP = this->lstMiembros.get_it();
- if (auxP == NULL) return;
- if (auxP->getCodigo() == cod)
- break;
- }
- Libro* newLibro = new Libro;
- newLibro->L_leerDatos(in);
- auxP->insertarLibro(*newLibro);
- this->lstMiembros.reset_it();
- }
- void GestorReferencias::imprimirReporte(std::ostream & archOut){
- Miembro* auxP;
- this->lstMiembros.reset_it();
- while(1){
- auxP = this->lstMiembros.get_it();
- if (auxP == NULL) return;
- auxP->imprimirDatos(archOut);
- auxP->imprimirLibro(archOut);
- }
- this->lstMiembros.reset_it();
- }
- //Miembro.h
- #ifndef MIEMBRO_H
- #define MIEMBRO_H
- #include <fstream>
- #include "Libro.h"
- #include "CListaT.h"
- #include "CListaTlib.h"
- class Miembro{
- protected:
- char* nombre;
- int codigo;
- char* distrito;
- CListaTlib<Libro> lstLibros;
- public:
- Miembro();
- Miembro(const char*, int, const char*);
- virtual ~Miembro();
- virtual void imprimirDatos(std::ostream&) = 0;
- virtual void leerDatos(std::istream&)=0;
- void SetDistrito(const char*);
- char* GetDistrito() const;
- void setCodigo(int);
- int getCodigo() const ;
- void setNombre(const char*);
- char* getNombre() const ;
- bool operator< (const Miembro&);
- bool operator> (const Miembro&);
- bool operator==(const Miembro&);
- bool operator==(int);
- void insertarLibro(Libro&);
- void imprimirLibro(std::ostream&);
- };
- #endif /* MIEMBRO_H */
- //Miembro.cpp
- #include <iostream>
- #include <string.h>
- #include "Miembro.h"
- #include "CListaT.h"
- using namespace std;
- Miembro::Miembro() {
- codigo = 0;
- nombre = NULL;
- distrito = NULL;
- }
- Miembro::Miembro(const char* _nombre, int _codigo, const char* _distrito) {
- nombre = new char[strlen(_nombre)+1];
- strcpy(nombre, _nombre);
- codigo = _codigo;
- distrito = new char[strlen(_distrito)+1];
- strcpy(distrito, _distrito);
- }
- Miembro::~Miembro(){
- cout << "Destructor miembro.." << endl;
- if (nombre) delete [] nombre;
- if (distrito) delete [] distrito;
- }
- void Miembro::leerDatos(std::istream& in){
- char auxStr[100], distAux[100];
- int id;
- in.getline(auxStr, 100, ',');
- in >> id;
- in.get(); //Sacamos la siguiente coma
- in.getline(distAux, 100, ',');
- setCodigo(id);
- setNombre(auxStr);
- SetDistrito(distAux);
- }
- void Miembro::setCodigo(int codigo) {
- this->codigo = codigo;
- }
- int Miembro::getCodigo() const {
- return codigo;
- }
- void Miembro::setNombre(const char* nombre) {
- this->nombre = new char[strlen(nombre)+1];
- strcpy(this->nombre, nombre);
- }
- char* Miembro::getNombre() const {
- char* aux = new char[strlen(this->nombre)+1];
- strcpy(aux, this->nombre);
- return aux;
- }
- void Miembro::SetDistrito(const char* distrito){
- this->distrito = new char[strlen(distrito)+1];
- strcpy(this->distrito, distrito);
- }
- char* Miembro::GetDistrito() const {
- char* aux = new char[strlen(this->distrito)+1];
- strcpy(aux, this->distrito);
- return aux;
- }
- bool Miembro::operator<(const Miembro& objMiembro) {
- return this->codigo < objMiembro.codigo;
- }
- bool Miembro::operator>(const Miembro& objMiembro) {
- return not (*this < objMiembro);
- }
- bool Miembro::operator==(const Miembro& objMiembro) {
- return (this->codigo == objMiembro.codigo);
- }
- bool Miembro::operator ==(int codigo){
- return (this->codigo == codigo);
- }
- void Miembro::insertarLibro(Libro& objLib){
- this->lstLibros.insertar(objLib);
- }
- void Miembro::imprimirLibro(std::ostream& archOut){
- this->lstLibros.imprimir(archOut);
- }
- //Alumno.h
- #ifndef ALUMNO_H
- #define ALUMNO_H
- #include "Miembro.h"
- class Alumno : public Miembro {
- private:
- int escala;
- char* especialidad;
- char* facultad;
- public:
- Alumno();
- Alumno(const char*, int,const char*, int, const char*, const char*);
- ~Alumno();
- void imprimirDatos(std::ostream&);
- void leerDatos(std::istream&);
- void setEspecialidad(const char*);
- char* getEspecialidad() const;
- void setEscala(int);
- int getEscala() const;
- void SetFacultad(char*);
- char* GetFacultad() const;
- };
- #endif /* ALUMNO_H */
- //Alumno.cpp
- #include <string.h>
- #include <fstream>
- #include <iostream>
- #include "Alumno.h"
- using namespace std;
- Alumno::Alumno():
- Miembro() {
- escala = 0;
- especialidad = NULL;
- facultad = NULL;
- }
- Alumno::Alumno(const char* _nombre, int _edad, const char* _distrito, int _escala, const char* _especialidad,const char* _facultad ):
- Miembro(_nombre, _edad, _distrito){
- escala = _escala;
- especialidad = new char[strlen(_especialidad)+1];
- strcpy(especialidad, _especialidad);
- facultad = new char[strlen(_facultad)+1];
- strcpy(facultad, _facultad);
- }
- void Alumno::leerDatos(std::istream& in) {
- Miembro::leerDatos(in);
- int escala; char auxEsp[100], fac[100];
- in >> escala;
- in.get();
- in.getline(auxEsp, 100, ',');
- in.getline(fac, 100, '\n');
- this->setEscala(escala);
- this->setEspecialidad(auxEsp);
- this->SetFacultad(fac);
- }
- void Alumno::imprimirDatos(std::ostream& out){
- out << "Codigo del Alumno: " << codigo << endl;
- out << "Nombre del Alumno: " << nombre << endl;
- out << "Escala de pago: " << escala << endl;
- out << "Especialidad: " << especialidad << endl;
- }
- Alumno::~Alumno(){
- if (especialidad) delete [] especialidad;
- if (facultad) delete [] facultad;
- }
- void Alumno::setEspecialidad(const char* especialidad) {
- this->especialidad = new char[strlen(especialidad)+1];
- strcpy(this->especialidad, especialidad);
- }
- char* Alumno::getEspecialidad() const {
- char* aux = new char[strlen(this->especialidad)+1];
- strcpy(aux, this->especialidad);
- return aux;
- }
- void Alumno::setEscala(int escala) {
- this->escala = escala;
- }
- int Alumno::getEscala() const {
- return escala;
- }
- void Alumno::SetFacultad(char* s){
- this->facultad = new char[strlen(s)+1];
- strcpy(this->facultad, s);
- }
- char* Alumno::GetFacultad() const {
- char* aux = new char[strlen(this->facultad)+1];
- strcpy(aux, this->facultad);
- return aux;
- }
- //Profesor.h
- #ifndef PROFESOR_H
- #define PROFESOR_H
- #include "Miembro.h"
- class Profesor : public Miembro {
- private:
- char* categoria;
- char* dedicacion;
- char* seccion;
- char* grado;
- public:
- Profesor();
- Profesor(const char*, int, const char*, const char*, const char*, const char*, const char*);
- ~Profesor();
- void imprimirDatos(std::ostream&);
- void leerDatos(std::istream&);
- void setDedicacion(const char*);
- char* getDedicacion() const;
- void setCategoria(const char*);
- char* getCategoria() const;
- void SetGrado(char*);
- char* GetGrado() const;
- void SetSeccion(char*);
- char* GetSeccion() const;
- };
- #endif /* PROFESOR_H */
- //Profesor.cpp
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include "Profesor.h"
- using namespace std;
- Profesor::Profesor() :
- Miembro() {
- categoria = NULL;
- dedicacion = NULL;
- seccion = NULL;
- grado = NULL;
- }
- Profesor::Profesor(const char* _nombre, int _edad, const char* _distrito, const char* _categoria, const char* _dedicacion, const char* _seccion, const char* _grado) :
- Miembro(_nombre, _edad, _distrito) {
- categoria = new char[strlen(_categoria) + 1];
- strcpy(categoria, _categoria);
- dedicacion = new char[strlen(_dedicacion) + 1];
- strcpy(dedicacion, _dedicacion);
- seccion = new char[strlen(_seccion) + 1];
- strcpy(dedicacion, _seccion);
- grado = new char[strlen(_dedicacion) + 1];
- strcpy(dedicacion, _grado);
- }
- Profesor::~Profesor() {
- if (categoria) delete [] categoria;
- if (dedicacion) delete [] dedicacion;
- if (seccion) delete [] seccion;
- if (grado) delete [] grado;
- }
- void Profesor::imprimirDatos(std::ostream& out) {
- out << "Codigo del Profesor : " << codigo << endl;
- out << "Nombre del Profesor: " << nombre << endl;
- out << "Categoria: " << categoria << endl;
- out << "Dedicacion: " << dedicacion << endl;
- }
- void Profesor::leerDatos(std::istream& in) {
- Miembro::leerDatos(in);
- char cat[100], ded[100], sec[100], grado[100];
- in.getline(cat,100,',');
- in.getline(ded,100,',');
- in.getline(sec,100,',');
- in.getline(grado,100,'\n');
- setCategoria(cat);
- setDedicacion(ded);
- SetSeccion(sec);
- SetGrado(grado);
- }
- void Profesor::setDedicacion(const char* dedicacion) {
- this->dedicacion = new char[strlen(dedicacion) + 1];
- strcpy(this->dedicacion, dedicacion);
- }
- char* Profesor::getDedicacion() const {
- char* aux = new char[strlen(this->dedicacion) + 1];
- strcpy(aux, this->dedicacion);
- return aux;
- }
- void Profesor::setCategoria(const char* categoria) {
- this->categoria = new char[strlen(categoria) + 1];
- strcpy(this->categoria, categoria);
- }
- char* Profesor::getCategoria() const {
- char* aux = new char[strlen(this->categoria) + 1];
- strcpy(aux, this->categoria);
- return aux;
- }
- void Profesor::SetSeccion(char* s) {
- this->seccion = new char[strlen(s) + 1];
- strcpy(this->seccion, s);
- }
- char* Profesor::GetSeccion() const {
- char* aux = new char[strlen(this->seccion) + 1];
- strcpy(aux, this->seccion);
- return aux;
- }
- void Profesor::SetGrado(char* s) {
- this->grado = new char[strlen(s) + 1];
- strcpy(this->grado, s);
- }
- char* Profesor::GetGrado() const {
- char* aux = new char[strlen(this->grado) + 1];
- strcpy(aux, this->grado);
- return aux;
- }
- //Libro.h
- #include <iostream>
- using namespace std;
- #ifndef LIBRO_H
- #define LIBRO_H
- class Libro {
- private:
- int codigo;
- char* titulo;
- char* autor;
- char* pais;
- public:
- Libro();
- ~Libro();
- void SetCodigo(int);
- int GetCodigo() const;
- void SetTitulo(const char*);
- char* GetTitulo()const;
- void SetAutor(const char*);
- char* GetAutor() const;
- void SetPais(const char*);
- char* GetPais() const;
- bool operator>(Libro&);
- void L_leerDatos(std::istream&);
- void L_imprimirDatos(std::ostream&);
- };
- #endif /* LIBRO_H */
- //Libro.cpp
- #include "Libro.h"
- #include <iostream>
- #include <cstring>
- #include <cstdlib>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- Libro::Libro() {
- codigo = 0;
- titulo = NULL;
- autor = NULL;
- pais = NULL;
- }
- Libro::~Libro(){
- if (titulo) delete[] titulo;
- if (autor) delete[] autor;
- if (pais) delete[] pais;
- }
- void Libro::SetAutor(const char* s) {
- this->autor = new char[strlen(s)+1];
- strcpy(this->autor, s);
- }
- char* Libro::GetAutor() const{
- char* aux = new char[strlen(this->autor) + 1];
- strcpy(aux, this->autor);
- return aux;
- }
- int Libro::GetCodigo() const {
- return this->codigo;
- }
- void Libro::SetCodigo(int codigo) {
- this->codigo = codigo;
- }
- void Libro::SetPais(const char* s) {
- this->pais = new char[strlen(s)+1];
- strcpy(this->pais, s);
- }
- char* Libro::GetPais() const {
- char* aux = new char[strlen(this->pais) + 1];
- strcpy(aux, this->pais);
- return aux;
- }
- void Libro::SetTitulo(const char* s) {
- this->titulo = new char[strlen(s)+1];
- strcpy(this->titulo, s);
- }
- char* Libro::GetTitulo() const {
- char* aux = new char[strlen(this->titulo) + 1];
- strcpy(aux, this->titulo);
- return aux;
- }
- void Libro::L_leerDatos(std::istream& in) {
- int codigo;
- char titulo[100], autor[100], pais[100];
- in >> codigo;
- in.get();
- in.getline(titulo,100,',');
- in.getline(autor,100,',');
- in.getline(pais,100,'\n');
- SetCodigo(codigo);
- SetTitulo(titulo);
- SetAutor(autor);
- SetPais(pais);
- }
- void Libro::L_imprimirDatos(std::ostream& out) {
- out << left << setw(10) << this->codigo;
- out << left << setw(30) << this->titulo;
- out << left << setw(40) << this->autor;
- out << this->pais << endl;
- }
- bool Libro::operator >(Libro& otherL){
- return this->codigo > otherL.codigo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement