Dev - C++ - Lo pueden revisar por favor, no corre

 
Vista:
Imágen de perfil de Seb

Lo pueden revisar por favor, no corre

Publicado por Seb (9 intervenciones) el 31/05/2022 20:20:42
//SISTEMA DE ALQUILER
//sistema de alquiler

#include<conio.h>
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<stack>
#include<wchar.h>
#include<windows.h>
#include<locale.h>
#include<list>

#define USER "admin"
#define PASS "admin1"

using namespace std;

class contacto{
public :
string nombre;
string apellido;
string telefono;
string direccion;
string habitacion;
string fecha_ingreso;
string fecha_salida;

contacto(){

}

contacto agregar(){
contacto contacto;
cout<<"==============SISTEMA DE ALQUILER==============="<<endl;
cout<<"Nombre: ";
fflush(stdin);
getline(cin,contacto.nombre);
cout<<"Apellido: ";
fflush(stdin);
getline(cin,contacto.apellido);
cout<<"Telefono: ";
fflush(stdin);
getline(cin,contacto.telefono);
cout<<"Dirección: ";
fflush(stdin);
getline(cin,contacto.direccion);
cout<<"Habitacion: ";
fflush(stdin);
getline(cin,contacto.habitacion);
cout<<"Fecha de Ingreso: ";
fflush(stdin);
getline(cin,contacto.fecha_ingreso);
cout<<"Fecha de Salida: ";
fflush(stdin);
getline(cin,contacto.fecha_salida);
cout<<"=============================================="<<endl;

return contacto;

}

void imprimir(){
cout<<"================INFORMACION DEL HUESPED=================="<<endl;
cout<<"Nombre: "<<nombre<<endl;
cout<<"Apellido: "<<apellido<<endl;
cout<<"Teléfono: "<<telefono<<endl;
cout<<"Direccion: "<<direccion<<endl;
cout<<"Habitacion: "<<habitacion<<endl;
cout<<"Fecha de Ingreso: "<<fecha_ingreso<<endl;
cout<<"Fecha de Salida: "<<fecha_salida<<endl;
}
};
class Nodo{
public:
contacto dato;
Nodo *SigPtr;
Nodo (contacto n){
dato = n;
SigPtr = 0;
}
};

class Lista{
public:
Nodo *PrimeroPtr;
Nodo *UltimoPtr;
stack<contacto>papelera;

Lista(){
PrimeroPtr = UltimoPtr = 0;
}

~Lista(){
while (!EstaVacia()){
}
}

bool EstaVacia(){
return PrimeroPtr == 0;
}

void insertarFrentePrimera(contacto c){
Nodo *newPtr = new Nodo(c);

if (EstaVacia()){
PrimeroPtr = UltimoPtr = newPtr;
}else{
newPtr->SigPtr = PrimeroPtr;
PrimeroPtr = newPtr;
}
}

void insertarFrente (contacto c){
if (validar(c) == true){
getch();
}else{
Nodo *newPtr = new Nodo(c);

if (EstaVacia()){
PrimeroPtr = UltimoPtr = newPtr;
}else{
newPtr->SigPtr = PrimeroPtr;
PrimeroPtr = newPtr;
}
}
}

contacto editarContacto(string nombre){
Nodo *actualPtr;
contacto c =PrimeroPtr->dato;
contacto val, b;
int cont = 0;
actualPtr = PrimeroPtr;

while(actualPtr != 0&& cont == nombre){
if(actualPtr->dato.nombre == nombre){
b = actualPtr ->dato;
PrimeroPtr->dato = b;
actualPtr->dato = c;
cont = 1;
return b;
}else{
actualPtr = actualPtr->SigPtr;
}
actualPtr == 0;
}
if(cont > 0){

}else{
cout<<"El contacto no fue encontrado"<<endl;
}
}

contacto buscarcontacto (){
Nodo *actualPtr;
contacto val;
string nom;
string nombre,apellido,telefono, direccion,habitacion,fecha_ingreso,fecha_salida;
int cont = 0;
actualPtr = PrimeroPtr;

cout<<"Nombre del contacto que desea buscar: ";
fflush(stdin);
getline (cin,nom);

while(actualPtr != 0&& cont == 0){
if (actualPtr->dato.nombre == nom){

nombre = actualPtr ->dato.nombre;
apellido = actualPtr->dato.apellido;
telefono = actualPtr->dato.telefono;
direccion = actualPtr->dato.direccion;
habitacion = actualPtr->dato.habitacion;
fecha_ingreso = actualPtr->dato.fecha_ingreso;
fecha_salida = actualPtr->dato.fecha_salida;

val.nombre=nombre;
val.apellido=apellido;
val.telefono=telefono;
val.direccion=direccion;
val.habitacion=habitacion;
val.fecha_ingreso=fecha_ingreso;
val.fecha_salida=fecha_salida;

return val;
cont = 1;
}else{
actualPtr = actualPtr->SigPtr;
}
actualPtr == 0;
}
if(cont > 0){

}else{
cout<<"El contacto no fue encontrado"<<endl;
}
}

contacto eliminarContacto (){
Nodo *actualPtr;
contacto c =PrimeroPtr->dato;
contacto val, b;
int cont = 0;
actualPtr = PrimeroPtr;
string nom;
cout<<"Nombre del contacto que desea eliminar: ";
cin.ignore();
getline(cin,nom);

while(actualPtr != 0 && cont == 0){
if(actualPtr->dato.nombre == nom){
b = actualPtr->dato;
PrimeroPtr->dato = b;
actualPtr->dato= c;
return b;
cout<<"El contacto fue eliminado satisfactoriamente";

cont = 1;
}else{
actualPtr = actualPtr->SigPtr;
}
}
if(cont > 0){

}else{
cout<<"El contacto no fue encontrado"<<endl;
}
}

bool validar(contacto val){
Nodo *actualPtr;
int cont = 0;
actualPtr = PrimeroPtr;

while(actualPtr != 0&& cont == 0){
if (actualPtr->dato.nombre == val.nombre){
cout<<"El contacto ya existe, por lo tanto no se agrego"<<endl;
cont = 1;
return true;
}else{
actualPtr = actualPtr->SigPtr;
}
actualPtr == 0;
}
if(cont > 0){

}else{
return false;
}
}
void eliminarDefrente(){
Nodo *TempPtr = PrimeroPtr;
if (PrimeroPtr == 0){
}

if (PrimeroPtr->SigPtr == 0){
UltimoPtr = 0;
}
PrimeroPtr = PrimeroPtr->SigPtr;
delete TempPtr;
}

void imprimirLista(){
std :: ofstream PrimerArchivo("RegistroContacto.txt", std :: ios :: out);
contacto contacto;

Nodo *actualPtr;
actualPtr = PrimeroPtr;
PrimerArchivo<<actualPtr->dato.nombre<<","<<actualPtr->dato.apellido<<","<<actualPtr->dato.telefono<<","<<actualPtr->dato.direccion<<","<<actualPtr->dato.habitacion<<","<<actualPtr->dato.fecha_ingreso<<","<<actualPtr->dato.fecha_salida;

while (actualPtr->SigPtr != 0){
actualPtr = actualPtr->SigPtr;
PrimerArchivo<<actualPtr->dato.nombre<<","<<actualPtr->dato.apellido<<","<<actualPtr->dato.telefono<<","<<actualPtr->dato.direccion<<","<<actualPtr->dato.habitacion<<","<<actualPtr->dato.fecha_ingreso<<","<<actualPtr->dato.fecha_salida;
}
}
void imprimir(){
Nodo *actualPtr;
actualPtr = PrimeroPtr;
actualPtr->dato.imprimir();

while (actualPtr->SigPtr!=0){
actualPtr = actualPtr->SigPtr;
actualPtr->dato.imprimir();
}
}
};
void insertarFrente (Lista &list){
system("cls");
cout<<"--Ingresando--"<<endl;
contacto c;
list.insertarFrente(c.agregar());
list.imprimirLista();
getch();
}
void editarContacto(Lista &list){
string nom;
contacto aux;
int cont=0;
int opc = 0;
string nombre,apellido,telefono,direccion,habitacion,fecha_ingreso,fecha_salida;
std :: ofstream PrimerArchivo("RegistroContacto.txt", std :: ios :: out);

system("cls");
list.imprimir();

cout<<"\t\nNombre del contacto a editar: ";
cin.ignore();
getline (cin,nom);
aux = list.editarContacto(nom);
cout<<endl;

cout<<"==========DATOS DEL CONTACTO============="<<endl;
cout<<"===================================="<<endl;
cout<<"1.Nombre: "<<aux.nombre<<endl;
cout<<"2.Apellido: "<<aux.apellido<<endl;
cout<<"3.telefono: "<<aux.telefono<<endl;
cout<<"4.direccion: "<<aux.direccion<<endl;
cout<<"5.habitacion: "<<aux.habitacion<<endl;
cout<<"6.fecha de ingreso: "<<aux.fecha_ingreso<<endl;
cout<<"7.fecha de salida: "<<aux.fecha_salida<<endl;
cout<<"====================================="<<endl;
cout<<endl;
cout<<"Opción a editar: ";
cin>>opc;
cout<<endl;
if (opc == 1){
cout<<"Ingrese el nuevo nombre: ";
cin.ignore();
getline (cin,nombre);
aux.nombre.clear();
aux.nombre=nombre;
}
if(opc == 2){
cout<<"Ingrese el nuevo apellido: ";
cin.ignore();
getline (cin,nombre);
aux.nombre.clear();
aux.nombre=nombre;
}
if(opc == 3){
cout<<"Ingrese el nuevo telefono: ";
cin.ignore();
getline (cin,telefono);
aux.telefono.clear();
aux.telefono=telefono;
}
if(opc == 4){
cout<<"Ingrese la nueva direccion: ";
cin.ignore();
getline (cin,direccion);
aux.direccion.clear();
aux.direccion=direccion;
}
if(opc == 5){
cout<<"Ingrese la nueva habitacion: ";
cin.ignore();
getline (cin,habitacion);
aux.habitacion.clear();
aux.habitacion=habitacion;
}
if(opc == 6){
cout<<"Ingrese la nueva fecha de ingreso: ";
cin.ignore();
getline (cin,fecha_ingreso);
aux.fecha_ingreso.clear();
aux.fecha_ingreso=fecha_ingreso;
}
if(opc == 7){
cout<<"Ingrese la nueva fecha de salida: ";
cin.ignore();
getline (cin,fecha_salida);
aux.fecha_salida.clear();
aux.fecha_salida=fecha_salida;
}

cont++;
list.eliminarDefrente();
list.insertarFrente(aux);
PrimerArchivo.clear();
list.imprimirLista();
}

void buscarcontacto(Lista &list){
system("cls");
list.buscarcontacto().imprimir();
getch();
getch();
}

void eliminarContacto(Lista &lista){
system("cls");
list.eliminarDeFrente();
list.imprimirLista();
getch();
getch();
}

void actualizar(Lista &list){
contacto c;
ifstream archivo("RegistroContacto.txt");

int aux=0;
while (archivo) {
string Lineadetexto;
if (!getline(archivo, Lineadetexto)) break;
istringstream StreamLineadetexto( Lineadetexto);

while (StreamLineadetexto)
{
string cadena;
if (!getline(StreamLineadetexto, cadena, ','))
break;

if(aux==0){
c.nombre=cadena;
}
if(aux==1){
c.apellido=cadena;
}
if(aux==2){
c.telefono=cadena;
}
if(aux==3){
c.direccion=cadena;
}
if(aux==4){
c.habitacion=cadena;
}
if(aux==5){
c.fecha_ingreso=cadena;
}
if(aux==6){
c.fecha_salida=cadena;
}
aux++;
}
list.insertarFrentePrimera(c);
aux=0;
}
if (!archivo.eof())
{
cout<<"El contacto no fue encontrado"<<endl;
}
}

void borrarArchivocontacto(Lista &list){
std :: ofstream PrimerArchivo("RegistroContacto.txt", std :: ios :: out);
PrimerArchivo.clear();
while(!list.PrimeroPtr->SigPtr==0){
list.eliminarDefrente();
}
list.eliminarDefrente();
system("cls");
cout<<"Todos los contactos fueron eliminados satisfactoriamente!"<<endl;
getch();
getch();
}

void mostrarDirectorio(Lista &list){
system("cls");
cout<<"=========ELEMENTOS DE LA LISTA=========="<<endl;
if(list.PrimeroPtr==0){
cout<<"No hay contacto en la agenda!"<<endl;
}
else{
list.imprimir();
}
getch();
}

int main(){


Lista lista = Lista();
actualizar(lista);

system("cls");
setlocale(LC_ALL,"");
int op;

string usuario, password;
int contador = 0;
bool ingresa = false;

do{
system("cls");
cout<<"\t==============BIENVENIDO============="<<endl;
cout<<"--------------------------------------------"<<endl;
cout<<"============= INICIE SECCIÓN==============="<<endl;
cout<<"-------------------------------------------"<<endl;
cout<<"\n\tUSUARIO: "<<endl;
getline(cin, usuario);
cout<<"\n\tPASSWORD: "<<endl;
char caracter;
caracter = getch();
password = "";

while (caracter !=13){
if(caracter !=8){
password.push_back(caracter);
cout<<"*";


}else{
if(password.length() > 0){
cout<< "\b \b";
password = password.substr(0, password.length() - 1);
}


caracter = getch();
}

}

}
if( usuario == USER && password == PASS) {
ingresa = true;
}else {
cout<<"\nEL USUARIO Y/O PASSWORD SON INCORRECTOS "<<endl;
cin.get();
contador++;
}

}while(ingresa == fasle && contador < 3);

if(ingresa == false){
cout<<"USTED NO PUDO INGRESAR AL SISTEMA "<<endl;
exit(0);
}else {
system("cls");

cout<<"--------------------------------------------------"<<endl;
cout<<"============INICIO SECCION CON EXITO=============="<<endl;
cout<<"--------------------------------------------------"<<endl;

cin.get();
do{
system("cls");
cout<<"==============SISTEMA DE ALQUILER==============="<<endl;
cout<<"--------------------------------------------------"<<endl;
cout<<"=============MENU PRINCIPAL==============="<<endl;
cout<<"1.agregar cliente"<<endl;
cout<<"2.Editar Cliente"<<endl;
cout<<"3.Buscar cliente"<<endl;
cout<<"4.Eliminar cliente"<<endl;
cout<<"5.Mostrar Directorio en general"<<endl;
cout<<"6.Salir"<<endl;
cout<<"--------------------------------------------------"<<endl;<<endl;
cout<<"Opción: ";
cin>>op;

switch(op){
case 1:
insertarFrente(lista);
system("pause");
break;
case 2:
editarContacto(lista);
system("pause");
break;
case 3:
buscarContacto(lista);
system("pause");
case 4:
eliminarContacto(lista);
system("pause");
break;
case 5:
mostrarDirectorio(lista);
system("pause");
case 6:
exit(1);
break;
}
system("cls");
}while(op!=6);

}
cin.get();
return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de kevin

comment: Lo pueden revisar por favor, no corre

Publicado por kevin (59 intervenciones) el 31/05/2022 22:39:24
Dime que es bait
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Seb

comment: Lo pueden revisar por favor, no corre

Publicado por Seb (9 intervenciones) el 01/06/2022 16:12:26
Desearia que fuera asi, pero es mi proyecto final :/
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar