Skip to content

Commit 9628343

Browse files
committed
20240601_001
1 parent 1736dde commit 9628343

File tree

2 files changed

+136
-16
lines changed

2 files changed

+136
-16
lines changed

Entregas/Entrega2/index copy.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
/**
3+
* CLASE CON METODOS PARA REGISTRO Y ACCESO
4+
*/
5+
6+
class User {
7+
constructor(nombre, apellido, cedula, usuario,pass){
8+
this.nombre= nombre;
9+
this.apellido= apellido;
10+
this.cedula= cedula;
11+
this.usuario= usuario;
12+
this.pass=pass ;
13+
}
14+
ingresoDatos (){
15+
this.nombre=prompt("Ingrese Nombre: ");
16+
this.apellido=prompt("Ingrese Apellido: ");
17+
this.cedula=prompt("Ingrese Cedula: ");
18+
this.usuario=prompt("Ingrese Usuario: ");
19+
this.pass=prompt("Ingrese Password: ");
20+
this.datosU=[{
21+
nombre: this.nombre,
22+
apellido: this.apellido,
23+
cedula:this.cedula,
24+
usuario: this.usuario,
25+
pass: this.pass
26+
}]
27+
}
28+
}
29+
30+
class Login {
31+
u = new User();
32+
constructor(usuario,pass){
33+
this.usuario= usuario;
34+
this.pass=pass ;
35+
}
36+
login (){
37+
let x=true; let y=true;
38+
if(u.usuario===null){
39+
alert("DEBE REGISTRAR USUARIO");
40+
u.ingresoDatos();
41+
}
42+
while (x) {
43+
console.log(u.usuario);
44+
let user=prompt("INGRESE USUARIO O X PARA MENU: ");
45+
if(user ==="X" || user==="x"){
46+
x=false;
47+
y=false;
48+
break;
49+
} else if (user===u.usuario){
50+
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) DEL PASSWORD
51+
break;
52+
}else {alert("INGRESE USUARIO VALIDO")}
53+
54+
}
55+
while (y) {
56+
console.log(u.pass);
57+
let user=prompt("PASSWORD: ");
58+
if (user===u.pass){
59+
alert("Validacion correcta!! \n SIGA SIGA")
60+
break;
61+
}else {alert("Clave INCORRECTA")}
62+
63+
}
64+
}
65+
}
66+
67+
/**
68+
* CODIGO
69+
*/
70+
let opcion=true;
71+
const u = new User();
72+
while(opcion){
73+
let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n 2.SALIR\n\n"));
74+
switch (opt) {
75+
case 0:
76+
u.ingresoDatos();//Pide registro de datos usuario
77+
break;
78+
case 1:
79+
const l = new Login();
80+
l.login();//Pide Login usando datos ingresados
81+
break;
82+
case 2:
83+
opcion=false;
84+
break;
85+
default:
86+
alert("INGRSE VALOR VALIDO");
87+
break;
88+
}
89+
}
90+
alert("USTED SALIO DEL SISTEMA");

Entregas/Entrega2/index.js

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,29 @@ class User {
1010
this.cedula= cedula;
1111
this.usuario= usuario;
1212
this.pass=pass ;
13+
//this.datosU={};
14+
1315
}
1416
ingresoDatos (){
17+
const datosU={
18+
nombre: this.nombre,
19+
apellido: this.apellido,
20+
cedula:this.cedula,
21+
usuario: this.usuario,
22+
pass: this.pass
23+
};
24+
25+
for (const property in datosU) {
26+
27+
datosU[property] = prompt('Ingrese '+property+': ');
28+
}
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 (){
1536
this.nombre=prompt("Ingrese Nombre: ");
1637
this.apellido=prompt("Ingrese Apellido: ");
1738
this.cedula=prompt("Ingrese Cedula: ");
@@ -24,42 +45,49 @@ class User {
2445
usuario: this.usuario,
2546
pass: this.pass
2647
}]
48+
} */
49+
50+
2751
}
2852
}
2953

30-
class Login {
31-
u = new User();
54+
class Login extends User {
55+
//u = new User(); //INSTANCIO CLASE USER PARA PODER USAR FUNCIONES DE LA MISMA
56+
3257
constructor(usuario,pass){
33-
this.usuario= usuario;
34-
this.pass=pass ;
58+
super (usuario,pass);
59+
/* this.usuario= usuario;
60+
this.pass=pass ; */
3561
}
62+
3663
login (){
37-
let x=true; let y=true;
64+
let x=true; let y=true;
65+
console.log("En LOGIN: ");
66+
console.log(u.usuario);//PARA VER SI CAPTURÓ USUARIO
3867
if(u.usuario===null){
3968
alert("DEBE REGISTRAR USUARIO");
4069
u.ingresoDatos();
4170
}
4271
while (x) {
43-
console.log(u.usuario);
72+
console.log("While X: ");
73+
console.log(u.usuario);//PARA VER SI CAPTURÓ USUARIO
4474
let user=prompt("INGRESE USUARIO O X PARA MENU: ");
4575
if(user ==="X" || user==="x"){
4676
x=false;
4777
y=false;
4878
break;
49-
} else if (user===u.usuario){
50-
//NO HAY ACCIONES AQUI,SI VALIDA user, SALTA A BLOQUE WHILE(y) DEL PASSWORD
51-
break;
52-
}else {alert("INGRESE USUARIO VALIDO")}
53-
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")}
5483
}
5584
while (y) {
5685
console.log(u.pass);
5786
let user=prompt("PASSWORD: ");
58-
if (user===u.pass){
59-
alert("Validacion correcta!! \n SIGA SIGA")
60-
break;
61-
}else {alert("Clave INCORRECTA")}
62-
87+
if (user===u.pass){
88+
alert("Validacion correcta!! \n SIGA SIGA")
89+
break;
90+
}else {alert("Clave INCORRECTA")}
6391
}
6492
}
6593
}
@@ -76,6 +104,8 @@ let opt=parseInt(prompt ("INGRESE OPCION:\n 0. REGISTRO USUARIO\n 1.LOGIN\n
76104
u.ingresoDatos();//Pide registro de datos usuario
77105
break;
78106
case 1:
107+
console.log("EnSWITCH: ");
108+
console.log(u.usuario); //PARA VER SI CAPTURA USUARIO
79109
const l = new Login();
80110
l.login();//Pide Login usando datos ingresados
81111
break;

0 commit comments

Comments
 (0)