Skip to content

Commit 70d54c2

Browse files
committed
202406050-LoginANDANDO
1 parent 9628343 commit 70d54c2

File tree

2 files changed

+59
-65
lines changed

2 files changed

+59
-65
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class Login {
5757
let user=prompt("PASSWORD: ");
5858
if (user===u.pass){
5959
alert("Validacion correcta!! \n SIGA SIGA")
60-
break;
60+
y=false;
61+
6162
}else {alert("Clave INCORRECTA")}
6263

6364
}

Entregas/Entrega2/index.js

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,79 @@ class User {
1010
this.cedula= cedula;
1111
this.usuario= usuario;
1212
this.pass=pass ;
13-
//this.datosU={};
14-
15-
}
16-
ingresoDatos (){
17-
const datosU={
13+
this.datosU={
1814
nombre: this.nombre,
1915
apellido: this.apellido,
2016
cedula:this.cedula,
2117
usuario: this.usuario,
2218
pass: this.pass
23-
};
24-
25-
for (const property in datosU) {
26-
27-
datosU[property] = prompt('Ingrese '+property+': ');
2819
}
29-
console.log(datosU);
30-
return Object.entries(datosU);
31-
/**
32-
* ESTE ES EL CODIGO QUE TENGO FUNCIONANDO, QUIERO HACERLO ANDAR PERO CON EL FOR
33-
*/
34-
35-
/* ingresoDatos (){
36-
this.nombre=prompt("Ingrese Nombre: ");
37-
this.apellido=prompt("Ingrese Apellido: ");
38-
this.cedula=prompt("Ingrese Cedula: ");
39-
this.usuario=prompt("Ingrese Usuario: ");
40-
this.pass=prompt("Ingrese Password: ");
41-
this.datosU=[{
42-
nombre: this.nombre,
43-
apellido: this.apellido,
44-
cedula:this.cedula,
45-
usuario: this.usuario,
46-
pass: this.pass
47-
}]
48-
} */
49-
20+
}
21+
ingresoDatos (){
22+
// this.nombre=prompt("Ingrese Nombre: ");
23+
// this.apellido=prompt("Ingrese Apellido: ");
24+
// this.cedula=prompt("Ingrese Cedula: ");
25+
// this.usuario=prompt("Ingrese Usuario: ");
26+
// this.pass=prompt("Ingrese Password: ");
27+
// this.datosU=[{
28+
// nombre: this.nombre,
29+
// apellido: this.apellido,
30+
// cedula:this.cedula,
31+
// usuario: this.usuario,
32+
// pass: this.pass
33+
// }]
34+
const datosU={
35+
nombre: this.nombre,
36+
apellido: this.apellido,
37+
cedula:this.cedula,
38+
usuario: this.usuario,
39+
pass: this.pass
40+
}
41+
for (const property in datosU) {
42+
datosU[property] = prompt('Ingrese '+property+': ');
43+
}
44+
console.log(datosU);
45+
return this.datosU=datosU;
46+
}
47+
48+
// Método para obtener el nombre de usuario
49+
darUsuario() {
50+
return this.datosU.usuario;
51+
}
5052

51-
}
52-
}
53+
// Método para obtener la contraseña
54+
darPass() {
55+
return this.pass;
56+
}
57+
5358

54-
class Login extends User {
55-
//u = new User(); //INSTANCIO CLASE USER PARA PODER USAR FUNCIONES DE LA MISMA
59+
login (){
60+
let x=true; let y=true;
61+
console.log("DENTRO DEL LOGIN: "+ this.datosU.usuario);
5662

57-
constructor(usuario,pass){
58-
super (usuario,pass);
59-
/* this.usuario= usuario;
60-
this.pass=pass ; */
61-
}
62-
63-
login (){
64-
let x=true; let y=true;
65-
console.log("En LOGIN: ");
66-
console.log(u.usuario);//PARA VER SI CAPTURÓ USUARIO
67-
if(u.usuario===null){
63+
if(this.datosU.usuario===null){
6864
alert("DEBE REGISTRAR USUARIO");
69-
u.ingresoDatos();
65+
this.ingresoDatos();
7066
}
7167
while (x) {
72-
console.log("While X: ");
73-
console.log(u.usuario);//PARA VER SI CAPTURÓ USUARIO
68+
console.log("USUARIO en WHILE(x): "+this.datosU.pass);
7469
let user=prompt("INGRESE USUARIO O X PARA MENU: ");
75-
if(user ==="X" || user==="x"){
76-
x=false;
77-
y=false;
78-
break;
79-
} else if (user===u.usuario){
80-
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) DEL PASSWORD
81-
break;
82-
}else {alert("INGRESE USUARIO VALIDO")}
70+
if(user ==="X" || user==="x"){
71+
x=false;
72+
y=false;
73+
break;
74+
} else if (user===this.datosU.usuario){
75+
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) A VALIDAR PASSWORD
76+
break;
77+
}else {alert("INGRESE USUARIO VALIDO")}
8378
}
8479
while (y) {
85-
console.log(u.pass);
80+
console.log("PASS en el WHILE(y): "+this.datosU.pass);
8681
let user=prompt("PASSWORD: ");
87-
if (user===u.pass){
82+
if (user===this.datosU.pass){
8883
alert("Validacion correcta!! \n SIGA SIGA")
8984
break;
90-
}else {alert("Clave INCORRECTA")}
85+
}else {alert("Clave INCORRECTA")}
9186
}
9287
}
9388
}
@@ -97,17 +92,15 @@ class Login extends User {
9792
*/
9893
let opcion=true;
9994
const u = new User();
95+
10096
while(opcion){
10197
let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n 2.SALIR\n\n"));
10298
switch (opt) {
10399
case 0:
104100
u.ingresoDatos();//Pide registro de datos usuario
105101
break;
106102
case 1:
107-
console.log("EnSWITCH: ");
108-
console.log(u.usuario); //PARA VER SI CAPTURA USUARIO
109-
const l = new Login();
110-
l.login();//Pide Login usando datos ingresados
103+
u.login();//Pide Login usando datos ingresados
111104
break;
112105
case 2:
113106
opcion=false;

0 commit comments

Comments
 (0)