Skip to content

Commit 22f6432

Browse files
committed
PruebasEntrega - Class De Logueo
1 parent ba0d563 commit 22f6432

File tree

4 files changed

+142
-41
lines changed

4 files changed

+142
-41
lines changed

Clase 6/index.js

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
/* let idProducto = "0xA51";
2-
let nombreProducto = "Arroz";
3-
let precio = 100;
4-
let stockProducto = 20; */
5-
6-
7-
//OBJETO
1+
//ARRAYS
82

93
/**
10-
* Producto
11-
* @param id type String
12-
* @param nombre type String
13-
* @param stock type number
14-
* @param precio type number
15-
*/
16-
17-
let producto = {
18-
id: "0x51Q",
19-
nombre: "Arroz",
20-
stock: 20,
21-
precio: 100
22-
}
23-
24-
console.table(producto.nombre);
25-
console.log(producto.precio);
4+
*
5+
*
6+
*
7+
*/

Entregas/Entrega2/index.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
1-
//SEGUNDA ENTREGA
2-
//Pide ingresar datos que van a un Array y luego con ese usuario habilita acceder a sisema
3-
let userdb=[]; //Crea natriz vacia "matriz"
1+
//PARA SEGUNDA ENTREGA
2+
//Pide ingresar datos que van a un Array y luego con ese usuario habilita acceder a sistema
3+
let userdb=[]; //Crea matriz vacia "userdb"
4+
let u; //Variable de pruebas
45

5-
let u;
6+
/**==========================
7+
* FUNCIONES QUE SE EJECUTAN:
8+
*===========================*/
69

710
registro();
811
login();
912

1013

11-
/**
12-
* FUNCION REGISTRO USUARIO
13-
*/
14+
/**===================================
15+
* FUNCION REGISTRO USUARIO CON ARRAY
16+
*====================================*/
1417
function registro (){
1518

1619
let head = ['Nombre', 'Apellido','Cedula','usuario','Password'];
20+
let dato;
1721
//let x = head.length; //Cuenta los datos a solicitar (Array "head")
1822

1923
// USANDO FOR..OF
2024
for (let d of head) {
2125
dato=prompt("Ingrese "+d+": ");
22-
if (dato ===null){
23-
alert("Debe ingresar usuario");
24-
d=d-1;}
25-
26-
else{
27-
userdb.push([d,dato])};
26+
if (dato === null){
27+
alert("Debe ingresar dato");
28+
d=--d;//Esto restaria uno para que vuelva a contar para repetir el prompt de "dato"
29+
} else{
30+
userdb.push([d,dato])};
2831
}
32+
2933
return userdb;
30-
31-
}
34+
}
3235

33-
/**
36+
/**====================
3437
* FUNCION LOGIN USUARIO
35-
*/
38+
*======================*/
3639
function login (){
3740
let user;let x=true;
3841
console.log(userdb);
@@ -48,7 +51,7 @@ function login (){
4851
if (indice !== -1 && user===userdb[3][1]) {
4952

5053
alert("BIENVENIDO AL SISTEMA ");
51-
console.log("EL USUARIO ES: "+userdb[3][1]);
54+
console.log("EL USUARIO ES: "+ userdb[3][1]);
5255
x=false;
5356
}
5457
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//PARA SEGUNDA ENTREGA
2+
//Pide ingresar datos que van a un Array y luego con ese usuario habilita acceder a sistema
3+
let userdb=[]; //Crea matriz vacia "userdb"
4+
let u; //Variable de pruebas
5+
6+
/**==========================
7+
* FUNCIONES QUE SE EJECUTAN:
8+
*===========================*/
9+
10+
registro();
11+
login();
12+
13+
14+
/**===================================
15+
* FUNCION REGISTRO USUARIO CON ARRAY
16+
*====================================*/
17+
function registro (){
18+
19+
let head = ['Nombre', 'Apellido','Cedula','usuario','Password'];
20+
let dato;
21+
//let x = head.length; //Cuenta los datos a solicitar (Array "head")
22+
23+
// USANDO FOR..OF
24+
for (let d of head) {
25+
dato=prompt("Ingrese "+d+": ");
26+
if (dato === null){
27+
alert("Debe ingresar dato");
28+
d=--d;//Esto restaria uno para que vuelva a contar para repetir el prompt de "dato"
29+
} else{
30+
userdb.push([d,dato])};
31+
}
32+
33+
return userdb;
34+
}
35+
36+
/**====================
37+
* FUNCION LOGIN USUARIO
38+
*======================*/
39+
function login (){
40+
let user;let x=true;
41+
console.log(userdb);
42+
while (x) {
43+
user=prompt("Ingrese un Usuario: ");
44+
45+
46+
if (user === null) {// Verificar si el input es nulo (el usuario canceló el prompt)
47+
alert("Ingrese opcion valida.");
48+
}else if (user !== "") {
49+
let indice = userdb.includes(user);//user es valor buscado en array userdb
50+
51+
if (indice !== -1 && user===userdb[3][1]) {
52+
53+
alert("BIENVENIDO AL SISTEMA ");
54+
console.log("EL USUARIO ES: "+ userdb[3][1]);
55+
x=false;
56+
}
57+
}
58+
}
59+
}
60+
61+

Entregas/PruebasEntrega/index.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
3+
4+
class User {
5+
constructor(nombre, apellido, cedula, usuario,pass){
6+
this.nombre= nombre;
7+
this.apellido= apellido;
8+
this.cedula= cedula;
9+
this.usuario= usuario;
10+
this.pass=pass ;
11+
}
12+
SetDatos (){
13+
this.nombre=prompt("Ingrese Nombre: ");
14+
this.apellido=prompt("Ingrese Apellido: ");
15+
this.cedula=prompt("Ingrese Cedula: ");
16+
this.usuario=prompt("Ingrese Usuario: ");
17+
this.pass=prompt("Ingrese Password: ");
18+
return;
19+
20+
}
21+
}
22+
23+
class Login {
24+
constructor(usuario,pass){
25+
this.usuario= usuario;
26+
this.pass=pass ;
27+
}
28+
login (){
29+
let x=true;
30+
while (x) {
31+
user=prompt("Ingrese un Usuario: ");
32+
33+
34+
if (usuario === null) {// Verificar si el input es nulo (el usuario canceló el prompt)
35+
alert("Ingrese opcion valida.");
36+
}else if (usuario !== "") {
37+
let indice = userdb.includes(usuario);//user es valor buscado en array userdb
38+
39+
if (indice !== -1 && user===userdb[3][1]) {
40+
41+
alert("BIENVENIDO AL SISTEMA ");
42+
console.log("EL USUARIO ES: "+ userdb[3][1]);
43+
x=false;
44+
}
45+
}
46+
}
47+
}
48+
}
49+
const u = new User();
50+
51+
u.SetDatos();
52+
53+
console.log(u);
54+
console.log("EL USUARIO ES: "+u.usuario);
55+

0 commit comments

Comments
 (0)