Skip to content

Commit a348dae

Browse files
committed
20240609_01
1 parent a2a9fcb commit a348dae

File tree

2 files changed

+55
-79
lines changed

2 files changed

+55
-79
lines changed

Entregas/Entrega2.zip

-3.64 KB
Binary file not shown.

Entregas/PruebasEntrega/index.js

Lines changed: 55 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,11 @@ class User {
1818
pass: this.pass
1919
}
2020
}
21-
ingresoDatos (){
22-
/**
23-
* USANDO PROMPT PARA INGRESO DE DATOS
24-
*/
25-
// this.nombre=prompt("Ingrese Nombre: ");
26-
// this.apellido=prompt("Ingrese Apellido: ");
27-
// this.cedula=prompt("Ingrese Cedula: ");
28-
// this.usuario=prompt("Ingrese Usuario: ");
29-
// this.pass=prompt("Ingrese Password: ");
30-
// this.datosU=[{
31-
// nombre: this.nombre,
32-
// apellido: this.apellido,
33-
// cedula:this.cedula,
34-
// usuario: this.usuario,
35-
// pass: this.pass
36-
// }]
3721
/**
38-
* USANDO UN FOR..IN PARA INGRESO DE DATOS
22+
* USANDO OBJETO y FOR..IN PARA INGRESO DE DATOS
3923
*/
24+
ingresoDatos (){
25+
4026
const datosU={
4127
nombre: this.nombre,
4228
apellido: this.apellido,
@@ -50,87 +36,77 @@ class User {
5036
console.log(datosU);
5137
return this.datosU=datosU;
5238
}
53-
54-
// Método para obtener el nombre de usuario
55-
darUsuario() {
56-
57-
console.log("DENTRO DE darUsuario(): "+this.datosU.usuario);
58-
return this.datosU.usuario;
59-
}
60-
61-
// Método para obtener la contraseña
62-
darPass() {
63-
return this.datosU.pass;
64-
}
65-
66-
}
67-
68-
/**
69-
* CLASE LOGUIN QUE EXTIENDE DE USER
70-
*/
71-
72-
class Login extends User{
73-
74-
constructor(usuario,pass){
75-
super(usuario,pass);
76-
this.usuario=usuario;
77-
}
39+
listarUsuario(){
40+
const datosU=[{
41+
nombre: this.nombre,
42+
apellido: this.apellido,
43+
cedula:this.cedula,
44+
usuario: this.usuario,
45+
pass: this.pass
46+
}];
47+
datosU.forEach((elemento) => {
48+
console.log(elemento.nombre);
49+
});
7850

79-
login(){
51+
return this.datosU=datosU;
52+
}
53+
54+
login (){
8055
let x=true; let y=true;
81-
console.log("DENTRO DEL LOGIN: "+ this.usuario);
82-
83-
if(this.datosU.usuario===null){
84-
alert("DEBE REGISTRAR USUARIO");
85-
this.ingresoDatos();
86-
}
87-
while (x) {
88-
console.log("USUARIO en WHILE(x): "+this.darPass());
89-
let user=prompt("INGRESE USUARIO O X PARA MENU: ");
90-
if(user ==="X" || user==="x"){
91-
x=false;
92-
y=false;
93-
break;
94-
} else if (user===this.datosU.usuario){
95-
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) A VALIDAR PASSWORD
96-
break;
97-
}else {alert("INGRESE USUARIO VALIDO")}
98-
}
99-
while (y) {
100-
let user=prompt("PASSWORD: ");
101-
if (user===this.datosU.pass){
102-
alert("Validacion correcta!! \n SIGA SIGA");
103-
x=false;
104-
y=false;
105-
break;
56+
57+
console.log("DENTRO DEL LOGIN: "+ this.datosU.usuario);//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.datosU.pass);//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;
10681
}else {alert("Clave INCORRECTA")}
107-
}
82+
}
10883
}
10984
}
11085

11186
/**
11287
* CODIGO
11388
*/
11489
let opcion=true;
115-
const u = new User();
116-
const l = new Login();
90+
const u = new User();//INSTANCIO CLASE
11791

11892
while(opcion){
119-
let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n 2.SALIR\n\n"));
93+
let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n 2.LISTAR USUARIO\n 3.SALIR\n\n"));
12094
switch (opt) {
12195
case 0:
12296
u.ingresoDatos();//Pide registro de datos usuario
12397
break;
12498
case 1:
125-
l.login();//Pide Login usando datos ingresados
126-
opcion=false;
127-
break;
99+
u.login();//Pide Login usando datos ingresados
100+
break;
128101
case 2:
129-
opcion=false;
130-
break;
102+
u.listarUsuario();
103+
break;
104+
case 3:
105+
opcion=false;
106+
break;
131107
default:
132-
alert("INGRSE VALOR VALIDO");
108+
alert("INGRSE VALOR VALIDO");
133109
break;
134110
}
135111
}
136-
alert("USTED SALIO DEL SISTEMA");
112+
alert("USTED ESTA SALIENDO DEL LOGIN");

0 commit comments

Comments
 (0)