Skip to content

Commit 662eb5e

Browse files
author
Amador Quispe
committed
mouredev#36 - Java
1 parent 2d22a95 commit 662eb5e

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.amsoft.roadmap.example36;
2+
3+
4+
import java.util.Arrays;
5+
import java.util.Scanner;
6+
7+
8+
enum House {
9+
FRONTEND("🌐"),
10+
BACKEND("🔙"),
11+
MOBILE("📱"),
12+
DATA("💾");
13+
14+
private final String emoji;
15+
16+
House(String emoji) {
17+
this.emoji = emoji;
18+
}
19+
20+
public String getEmoji() {
21+
return emoji;
22+
}
23+
24+
}
25+
26+
record Question(String question, String[] answers) {
27+
}
28+
public class Example36 {
29+
public static void main(String[] args) {
30+
Scanner scanner = new Scanner(System.in);
31+
Question[] questions = {
32+
new Question("¿Qué lenguaje de programación prefieres?", new String[]{"JavaScript", "Java", "Kotlin", "Python"}),
33+
new Question("¿Qué tipo de proyecto te gustaría desarrollar?", new String[]{"Web", "Backend", "Mobile", "Big Data"}),
34+
new Question("¿Qué tipo de dispositivo prefieres?", new String[]{"PC", "Servidor", "Smartphone", "Servidor"}),
35+
new Question("¿Qué tipo de base de datos prefieres?", new String[]{"MongoDB", "MySQL", "SQLite", "PostgreSQL"}),
36+
new Question("¿Qué tipo de sistema operativo prefieres?", new String[]{"Windows", "Linux", "Android", "MacOS"}),
37+
new Question("¿Qué tipo de IDE prefieres?", new String[]{"Visual Studio Code", "IntelliJ IDEA", "Android Studio", "PyCharm"}),
38+
new Question("¿Qué tipo de framework prefieres?", new String[]{"React", "Spring", "Flutter", "Django"}),
39+
new Question("¿Qué tipo de control de versiones prefieres?", new String[]{"Git", "SVN", "Git", "Git"}),
40+
new Question("¿Qué tipo de metodología prefieres?", new String[]{"Agile", "Waterfall", "Scrum", "Kanban"}),
41+
new Question("¿Qué tipo de testing prefieres?", new String[]{"Unit", "Integration", "UI", "Performance"})
42+
};
43+
System.out.println("¡Bienvenido al Sombrero Seleccionador de Hogwarts!");
44+
System.out.println("Te haré unas preguntas y según tus respuestas, te asignaré a una de las cuatro casas de la escuela.");
45+
System.out.println("¡Vamos a empezar!");
46+
System.out.println("Por favor, introduce tu nombre:");
47+
String name = scanner.nextLine();
48+
System.out.println("¡Hola, " + name + "!");
49+
System.out.println("Por favor, responde a las siguientes preguntas con el número de la respuesta que prefieras:");
50+
int[] points = new int[House.values().length];
51+
for (Question question : questions) {
52+
System.out.println(question.question());
53+
for (int i = 0; i < question.answers().length; i++) {
54+
System.out.println((i + 1) + ". " + question.answers()[i]);
55+
}
56+
int answer = scanner.nextInt();
57+
if(answer < 1 || answer > question.answers().length) {
58+
System.out.println("Respuesta no válida. Por favor, introduce un número entre 1 y " + question.answers().length);
59+
continue;
60+
}
61+
points[answer - 1] += 1;
62+
}
63+
int maxPoints = points[0];
64+
int houseIndex = 0;
65+
boolean tie = false;
66+
System.out.println("¡El Sombrero Seleccionador ha terminado de analizar tus respuestas!");
67+
for (int i = 1; i < points.length; i++) {
68+
if (points[i] > maxPoints) {
69+
maxPoints = points[i];
70+
houseIndex = i;
71+
tie = false;
72+
} else if (points[i] == maxPoints) {
73+
tie = true;
74+
}
75+
}
76+
House house = House.values()[houseIndex];
77+
System.out.println("¡Enhorabuena, " + name + "!");
78+
if (tie) {
79+
System.out.println("¡La decisión ha sido complicada!");
80+
}
81+
System.out.println("¡Tu casa es " + house + " " + house.getEmoji() + "!");
82+
83+
scanner.close();
84+
85+
86+
87+
88+
89+
}
90+
}

0 commit comments

Comments
 (0)