Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
152 changes: 152 additions & 0 deletions jmarquez/ejercicio01/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
const players = {
9: {
name: 'Bruno Fernandes',
jersey: 9,
goals: 5,
speed: 6,
assits: 9,
'passing accuracy': 10,
'defensive involvements': 3,
},
11: {
name: 'Rasmus Hojlund',
jersey: 11,
goals: 12,
speed: 8,
assits: 2,
'passing accuracy': 6,
'defensive involvements': 2,
},
5: {
name: 'Harry Maguire',
jersey: 5,
goals: 1,
speed: 5,
assits: 1,
'passing accuracy': 7,
'defensive involvements': 9,
},
17: {
name: 'Alejandro Garnacho',
jersey: 17,
goals: 8,
speed: 7,
assits: 8,
'passing accuracy': 6,
'defensive involvements': 0,
},
7: {
name: 'Mason Mount',
jersey: 7,
goals: 2,
speed: 6,
assits: 4,
'passing accuracy': 8,
'defensive involvements': 1,
},
};

const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});

function Retry() {
readline.question(
'\nWhat do you want to do?\n1.- Return to main menu\n2.- Quit system\n',
n => {
if (n == 1) return menu();
if (n == 2) {
console.log('Thank you see you!, next time');
return readline.close();
}
}
);
}
function menu() {
readline.question(
'======WELCOME TO THE SYSTEM========\n Select an option\n1.- fastest player\n2.- top goal scorer\n3.- player with the most assists\n4.- player with the highest passing accuracy\n5.- player with the most defensive involvements\n6.- Info of player\n7.- Compare two players\n8.- Quit system\n',
n => {
if (n == 1) {
let top = 0;
let fastest = '';
for (const player in players) {
if (players[player]['speed'] >= top) {
top = players[player]['speed'];
fastest = `the fastest player is ${players[player]['name']} wtih ${players[player]['speed']} points of speed`;
}
}
console.log(fastest);
return Retry();
}

if (n == 2) {
let top = 0;
let scorer = '';
for (const player in players) {
if (players[player]['goals'] >= top) {
top = players[player]['goals'];
scorer = `the fastest player is ${players[player]['name']} wtih ${players[player]['goals']} goals`;
}
}
console.log(scorer);
return Retry();
}
if (n == 3) {
let top = 0;
let assits = '';
for (const player in players) {
if (players[player]['assits'] >= top) {
top = players[player]['assits'];
assits = `the fastest player is ${players[player]['name']} wtih ${players[player]['assits']} assits`;
}
}
console.log(assits);
return Retry();
}
if (n == 4) {
let top = 0;
let passing = '';
for (const player in players) {
if (players[player]['passing accuracy'] >= top) {
top = players[player]['passing accuracy'];
passing = `the fastest player is ${players[player]['name']} wtih ${players[player]['passing accuracy']} successfull passes`;
}
}
console.log(passing);
return Retry();
}
if (n == 5) {
let top = 0;
let defensive = '';
for (const player in players) {
if (players[player]['defensive involvements'] >= top) {
top = players[player]['defensive involvements'];
defensive = `the fastest player is ${players[player]['name']} wtih ${players[player]['defensive involvements']} defensive actions`;
}
}
console.log(defensive);
return Retry();
}
if (n == 6) {
readline.question("\nSelect the Player's jersey number\n", n => {
console.log(players[n]);
return Retry();
});
}
if (n == 7) {
readline.question('\nenter 2 players numbers\n', a => {
readline.question('second number\n', b => {
console.log(players[a], '\n', players[b]);
return Retry();
});
});
}
if (n == 8) {
console.log('Thank you!, see you next time.');
return readline.close();
}
}
);
}
menu();
68 changes: 68 additions & 0 deletions jmarquez/ejercicio02/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 2. A travel agency has a special offer for traveling in any season of 2024. Their destinations are:

// Winter: Andorra and Switzerland. In Andorra, there are skiing activities, and in Switzerland, there's a tour of the Swiss Alps.
// Summer: Spain and Portugal. In Spain, there are hiking and extreme sports activities. In Portugal, there are activities on the beaches.
// Spring: France and Italy. In France, there are extreme sports activities, and in Italy, there's a cultural and historical tour.
// Autumn: Belgium and Austria. In Belgium, there are hiking and extreme sports activities, and in Austria, there are cultural and historical activities.
// Note: Traveling in winter costs $100, in autumn $200, in spring $300, and in summer $400.
// Design a system that helps users choose their best destination according to their personal preferences and the season they want to travel in.
// 12. Important: With the information you have, you should ask the user the right questions and display on screen what their best destination would be.

// Clue: You could consider the user's budget

const seasons = [
{
winter: {
andorra: ['skiing activities'],
Switzerland: ['tour of the Swiss Alps'],
cost: 100,
},
summer: {
spain: ['hiking', 'extreme sports'],
Portugal: ['beaches'],
cost: 400,
},
spring: {
france: ['extreme sports'],
italy: ['cultural and historical tour'],
cost: 300,
},
autumn: {
belgium: ['hiking', 'extreme sports'],
austria: ['cultural and historical activities'],
cost: 200,
},
},
];
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});
function menu() {
readline.question(
'Welcome to the traveling destination service\nPlease enter your activitty interest\n',
act => {
let j = 0;
let countries = '';
let seasonList = '';

for (const i in seasons[0]) {
let interest = Object.values(seasons[0][i]);
let inter = Object.keys(seasons[0][i]);
if (interest[0].includes(act)) {
delete inter[2];
inter.forEach(e => {
if (seasons[0][i][e].includes(act)) countries += e + ' ';
});
seasonList += i + ' ';
}
j++;
}
console.log(
`Your activity ${act} is avaliable in the countries: ${countries} in the seasons: ${seasonList}`
);
return readline.close();
}
);
}
menu();
147 changes: 147 additions & 0 deletions jmarquez/ejercicio03/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
// The Valencia Hospital is developing an application to manage appointments. Design an algorithm for this application with the following features:

// It must have a login and validate the data; after the third failed attempt, it should be locked.
// The user can schedule an appointment for: General Medicine, Emergency Care, Clinical Analysis, Cardiology, Neurology, Nutrition, Physiotherapy, Traumatology, and Internal Medicine.
// There are 3 doctors for each specialty.
// The user can only book one appointment per specialist. An error message should be displayed if the user tries to choose two appointments with the same doctor or the same specialty. As a developer, you can choose the doctors' names.
// The maximum limit for appointments, in general, is 3.
// Upon selecting a specialty, it will display if the user prefers a morning or afternoon appointment and show available hours. As a developer, you can choose the hours.
// Display available specialists.
// The user can choose their preferred specialist.
// The basic process is: Login -> Choose specialty -> Choose doctor -> Choose time slot.
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});

const users = [
{
nam: 'jon',
pass: '123',
appointment: [],
},
{
nam: 'Kate Wong',
pass: '@PASSujhp',
appointment: [],
},
];

const specialities = [
{
speciality_name: 'General Medicine',
doctors: ['manuel', 'jose', 'fernando'],
hours: ['10:am', '2:00pm'],
},
{
speciality_name: 'Emergency Care',
doctors: ['charles xavier', 'walter white', 'zoiberg'],
hours: ['9:00am', '1:00pm'],
},
{
speciality_name: 'Clinical Analysis',
doctors: ['alberto', 'roberto', 'filiberto'],
hours: ['8:00am', '3:00pm'],
},
{
speciality_name: 'Cardiology',
doctors: ['maria', 'fernanda', 'rosio'],
hours: ['7:50am', '3:00pm'],
},
{
speciality_name: 'Neurology',
doctors: ['daniel', 'devorah', 'isole'],
hours: ['8:50am', '4:00pm'],
},
{
speciality_name: 'Nutrition',
doctors: ['francia', 'arturo', 'martina'],
hours: ['9:50am', '5:00pm'],
},
{
speciality_name: 'Physiotherapy',
doctors: ['luna', 'isabel', 'valentina'],
hours: ['10:50am', '6:00pm'],
},
{
speciality_name: 'Internal Medicine',
doctors: ['yesi', 'antonio', 'magdalena'],
hours: ['6:50am', '7:00pm'],
},
];

let logTry = 3;
let maximumAppointment = 0;

function login() {
readline.question('\n Insert you user: ', user => {
readline.question('\n Enter your password: ', pass => {
if (logTry === 1) {
console.log('\nSystem locked');
return readline.close();
}
const USER_AUTH = users.filter(
registeredUser => registeredUser.nam == user
);
const PASS_AUTH = USER_AUTH.filter(
registeredUser => registeredUser.pass == pass
);

if (USER_AUTH.length == 0 || PASS_AUTH.length == 0) {
logTry--;
console.log(`User or password not found, tries remaining: ${logTry}`);
return login();
}
delete USER_AUTH[0].pass;
menu(USER_AUTH[0]);
});
});
}

function menu(userData) {
if (maximumAppointment >= 3)
return console.log(
`Maximun limit of appoinments (${maximumAppointment}) reached`
);
readline.question('\nWelcome! Select the speciality please: ', str => {
chooseDoctor(specialities[str], userData);
});

specialities.forEach((index, value) => {
console.log(`\n${value}.- ${index.speciality_name} `);
});
}

function chooseDoctor(speciality, userData) {
readline.question(
`\nWelcome! Select the doctor for ${speciality.speciality_name} please: `,
str => {
const doctorName = speciality.doctors[str];
delete speciality.doctors[str];
if (userData.appointment.includes(doctorName)) {
console.log(
`You already are made appointment with the doctor ${doctorName}`
);
chooseDoctor(speciality, userData);
} else {
userData.appointment.push(doctorName);
maximumAppointment++;
console.log('appointment successfully!');
chooseHour(speciality);
}
}
);
speciality.doctors.forEach((name, index) => {
console.log(`\n${index}.- ${name}`);
});
}
function chooseHour(speciality) {
readline.question('\nChoose an avaliable hour:\n', hour => {
console.log(`Your appointment is set to ${speciality.hours[hour]}`);
return readline.close();
});
speciality.hours.forEach((name, index) => {
console.log(`\n${index}.- ${name}`);
});
}
login();
16 changes: 16 additions & 0 deletions jmarquez/ejercicio03/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ejercicio03",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon ./index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^3.0.2"
}
}
Loading