Skip to content

Instantly share code, notes, and snippets.

@JaimeMenendez
Last active March 5, 2022 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JaimeMenendez/b571d73c15f268dcdf8ece57309f42c8 to your computer and use it in GitHub Desktop.
Save JaimeMenendez/b571d73c15f268dcdf8ece57309f42c8 to your computer and use it in GitHub Desktop.
const tipoP = [
{ pago: "Tarjeta" },
{ pago: "Transferencia bancaria" },
{ pago: "Criptomonedas" },
{ pago: "Teléfono móvil" },
];
const tipoH = [
{ habitacion: "Sencilla", precio: 31 },
{ habitacion: "Doble", precio: 62 },
{ habitacion: "Triple", precio: 93 },
{ habitacion: "Quat", precio: 120 },
];
class Reserva {
constructor(habitacion, usuario, dias, tipoPago, pagado) {
this.habitacion = habitacion;
this.usuario = usuario;
this.dias = dias;
this.tipoPago = tipoPago;
this.pagado = pagado;
this.importe = dias * habitacion.precio;
}
informacionUsu = function () {
if (this.pagado === false) {
return `El cliente con DNI: ${this.usuario.dni}, ${this.usuario.apellido}, ${this.usuario.nombre}, aun tiene que pagar`;
} else {
return `El cliente con DNI: ${this.usuario.dni}, ${this.usuario.apellido}, ${this.usuario.nombre}, ha pagado mediante ${this.tipoPago}`;
}
};
informacionHab = function () {
return `ha reservado la habitacion ${this.habitacion.numero} ${this.habitacion.tipoH}, durante ${this.dias} dias a un precio de ${this.importe}€`;
};
}
class Usuario {
constructor(dni, nombre, apellido) {
this.dni = dni;
this.nombre = nombre;
this.apellido = apellido;
}
}
class Habitacion {
constructor(numero, tipoH, precio) {
this.numero = numero;
this.tipoH = tipoH;
this.precio = precio;
}
}
const usuario = new Usuario("55447701F", "Pepe", "Gomez");
const habitacion = new Habitacion(1, tipoH[1].habitacion, tipoH[1].precio);
const reserva = new Reserva(habitacion, usuario, 14, tipoP[1].pago, true);
console.log(reserva.informacionUsu());
console.log(reserva.informacionHab());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment