Skip to content

Commit 6960c3b

Browse files
committed
last001
1 parent e803424 commit 6960c3b

File tree

1 file changed

+35
-47
lines changed

1 file changed

+35
-47
lines changed

Entregas/Entrega2/index.js

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ class User {
1818
pass: this.pass
1919
}
2020
}
21+
2122
ingresoDatos (){
2223
/**
23-
* USANDO PROMPT PARA INGRESO DE DATOS
24+
* USANDO PROMPT Y VARIABLES SIMPLES PARA INGRESO DE DATOS
2425
*/
2526
// this.nombre=prompt("Ingrese Nombre: ");
2627
// this.apellido=prompt("Ingrese Apellido: ");
@@ -35,7 +36,7 @@ class User {
3536
// pass: this.pass
3637
// }]
3738
/**
38-
* USANDO UN FOR..IN PARA INGRESO DE DATOS
39+
* USANDO OBJETO y FOR..IN PARA INGRESO DE DATOS
3940
*/
4041
const datosU={
4142
nombre: this.nombre,
@@ -51,54 +52,42 @@ class User {
5152
return this.datosU=datosU;
5253
}
5354

54-
// Método para obtener el nombre de usuario
55-
darUsuario() {
56-
return this.datosU.usuario;
57-
}
58-
59-
// Método para obtener la contraseña
60-
darPass() {
61-
return this.datosU.pass;
62-
}
63-
64-
6555
login (){
6656
let x=true; let y=true;
67-
console.log("DENTRO DEL LOGIN: "+ this.darUsuario());
68-
69-
if(this.datosU.usuario===null){
70-
alert("DEBE REGISTRAR USUARIO");
71-
this.ingresoDatos();
72-
}
73-
while (x) {
74-
console.log("USUARIO en WHILE(x): "+this.darPass());
75-
let user=prompt("INGRESE USUARIO O X PARA MENU: ");
76-
if(user ==="X" || user==="x"){
77-
x=false;
78-
y=false;
79-
break;
80-
} else if (user===this.datosU.usuario){
81-
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) A VALIDAR PASSWORD
82-
break;
83-
}else {alert("INGRESE USUARIO VALIDO")}
84-
}
85-
while (y) {
86-
let user=prompt("PASSWORD: ");
87-
if (user===this.datosU.pass){
88-
alert("Validacion correcta!! \n SIGA SIGA");
89-
x=false;
90-
y=false;
91-
break;
57+
console.log("DENTRO DEL LOGIN: "+ this.darUsuario());//LINEA PARA VERIFICACION EN CONSOLA
58+
if(this.datosU.usuario===null){
59+
alert("DEBE REGISTRAR USUARIO");
60+
this.ingresoDatos();
61+
}
62+
while (x) {
63+
console.log("USUARIO en WHILE(x): "+this.darPass());//LINEA PARA VERIFICACION EN CONSOLA
64+
let user=prompt("INGRESE USUARIO O X PARA SALIR: ");
65+
if(user ==="X" || user==="x"){
66+
x=false;
67+
y=false;
68+
break;
69+
} else if (user===this.datosU.usuario){
70+
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) A VALIDAR PASSWORD
71+
break;
72+
}else {alert("INGRESE USUARIO VALIDO O DEBE REGISTRARSE")}
73+
}
74+
while (y) {
75+
let user=prompt("PASSWORD: ");
76+
if (user===this.datosU.pass){
77+
alert("Validacion correcta!! \n SIGA SIGA");
78+
x=false;
79+
y=false;opcion=false;
80+
break;
9281
}else {alert("Clave INCORRECTA")}
93-
}
82+
}
9483
}
9584
}
9685

9786
/**
9887
* CODIGO
9988
*/
10089
let opcion=true;
101-
const u = new User();
90+
const u = new User();//INSTANCIO CLASE
10291

10392
while(opcion){
10493
let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n 2.SALIR\n\n"));
@@ -107,15 +96,14 @@ let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n
10796
u.ingresoDatos();//Pide registro de datos usuario
10897
break;
10998
case 1:
110-
u.login();//Pide Login usando datos ingresados
111-
opcion=false;
112-
break;
99+
u.login();//Pide Login usando datos ingresados
100+
break;
113101
case 2:
114-
opcion=false;
115-
break;
102+
opcion=false;
103+
break;
116104
default:
117-
alert("INGRSE VALOR VALIDO");
105+
alert("INGRSE VALOR VALIDO");
118106
break;
119107
}
120108
}
121-
alert("USTED SALIO DEL SISTEMA");
109+
alert("USTED ESTA SALIENDO DEL LOGIN");

0 commit comments

Comments
 (0)