From 8ed253b996eb15960f64b0b22e5ddc6023b230c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20Andre=CC=81s?= <102297884+vandresca@users.noreply.github.com> Date: Sun, 30 Jul 2023 11:43:43 +0200 Subject: [PATCH] Limpiar ficheros --- .../java/vandresca.java" | 39 ----- .../java/vandresca.java | 132 ----------------- .../java/vandresca.java" | 71 ---------- .../java/vandresca.java | 58 -------- .../java/vandresca.java | 134 ------------------ 5 files changed, 434 deletions(-) delete mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/vandresca.java" delete mode 100644 Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/java/vandresca.java delete mode 100644 "Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/java/vandresca.java" delete mode 100644 Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/java/vandresca.java delete mode 100644 Retos/Reto #6 - PIEDRA, PAPEL, TIJERA, LAGARTO, SPOCK [Media]/java/vandresca.java diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/vandresca.java" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/vandresca.java" deleted file mode 100644 index dbbc6d4a1f..0000000000 --- "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/java/vandresca.java" +++ /dev/null @@ -1,39 +0,0 @@ -import java.util.Scanner; -import java.util.stream.IntStream; - - -/** - Transformar un texto o una frase al lenguaje hacker "leet"(1337) - */ -public class vandresca { - - private static String[] normalAlphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", - "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", - "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", " "}; - - private static String[] leetAlphabet = {"4", "|3", "[", "|)", "3", "|=", "6", "/-/","|", "_/", - "|<", "1", "|v|", "|\\|", "0", "/>", "0,", "|2", "5", "7", "|_|", "\\/", "\\/\\/", "><","j", "2", - "O", "L" ,"R", "E", "A", "S", "b", "T", "B", "g", " "}; - - public static void main(String[] args) { - - System.out.println("Introduce un texto;"); - Scanner input = new Scanner(System.in); - String text = input.nextLine().toUpperCase(); - input.close(); - String output = ""; - for(int i=0; inormalAlphabet[i].equals(character.toString())) - .findFirst() - .orElse(-1); - return leetAlphabet[index]; - } -} diff --git a/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/java/vandresca.java b/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/java/vandresca.java deleted file mode 100644 index 548753526f..0000000000 --- a/Retos/Reto #2 - EL PARTIDO DE TENIS [Media]/java/vandresca.java +++ /dev/null @@ -1,132 +0,0 @@ -import java.util.Random; - -/** - * Escribe un programa que muestre un juego de tenis y quien - * lo ha ganado. - * El programa rebira una secuencia formada por: - * "P1" (Player 1) o "P2" (Player 2) segun quien gane cada juego - * - Las puntuaciones son: - * "Love" (cero), "15", "30", "40", "Deuce" (empate), "Advantage", ventaja - * - Ante la secuencia [P1, P1, P2, P2, P1, P2, P1, P1] el programa - * mostraría: - * 15 - Love - * 30 - Love - * 30 - 15 - * 30 - 30 - * 40 - 30 - * Deuce - * Advantage P1 - * Ha ganado P1 - * - Es posible controlar errores en la entrada de datos. - * - Consulta las reglas de juego si tienes dudas sobre el sistema de puntos. - */ -public class vandresca { - - private static Player player1; - - private static Player player2; - - public static void main(String[] args) { - init(); - while(!hasEnd()){ - setWinner(); - showScoreBoard(); - playGame(getWinner()); - } - } - - private static Boolean hasEnd(){ - return player1.isWinner() || player2.isWinner(); - } - - private static Boolean getDifferencePlayers(Player player1, Player player2){ - return (player1.getNumberPoints() - player2.getNumberPoints()) > 1; - } - - private static void setWinner(){ - if(player1.isMoreThanFORTY() && getDifferencePlayers(player1, player2)) player1.setWinner(); - if(player2.isMoreThanFORTY() && getDifferencePlayers(player2, player1)) player2.setWinner(); - } - - private static void init(){ - player1 = new Player(); - player2 = new Player(); - } - - private static Player getWinner(){ - Random rd = new Random(); - return (rd.nextBoolean())? player1 : player2; - } - - private static void playGame(Player winner){ - winner.addPoint(); - } - - private static void showScoreBoard(){ - if(isDeuce()) System.out.println("DEUCE"); - else if(isAdvantagePlayer1()) System.out.println("ADVANTAGE PLAYER 1"); - else if(isAdvantagePlayer2()) System.out.println("ADVANTAGE PLAYER 2"); - else if(player1.isWinner()) System.out.println("WIN PLAYER 1"); - else if(player2.isWinner()) System.out.println("WIN PLAYER 2"); - else System.out.println(player1.getTypePoint() + " - " + player2.getTypePoint()); - } - - private static Boolean isDeuce(){ - return player1.getNumberPoints()>= Player.TypePoint.FORTY.ordinal() && player1.getNumberPoints()== player2.getNumberPoints(); - } - - private static Boolean isAdvantagePlayer1(){ - return (player1.getNumberPoints()> Player.TypePoint.FORTY.ordinal()) && (player1.getNumberPoints() - player2.getNumberPoints()==1); - } - - private static Boolean isAdvantagePlayer2(){ - return (player2.getNumberPoints()> Player.TypePoint.FORTY.ordinal()) && (player2.getNumberPoints() - player1.getNumberPoints()==1); - } - -} - -public class Player { - private int points; - - private Boolean passFORTY; - private Boolean winner; - - public enum TypePoint { - LOVE, FIFTEEN, THIRTY, FORTY; - } - - public Player() { - this.points = 0; - this.passFORTY = false; - this.winner = false; - } - - public int getNumberPoints(){ - return this.points; - } - - public TypePoint getTypePoint(){ - if(this.points == 0) return TypePoint.LOVE; - if(this.points == 1) return TypePoint.FIFTEEN; - if(this.points == 2) return TypePoint.THIRTY; - return TypePoint.FORTY; - } - - public void addPoint(){ - this.points++; - } - - public Boolean isMoreThanFORTY(){ - return this.points > TypePoint.FORTY.ordinal(); - } - - public void setWinner(){ - this.winner = true; - } - - public Boolean isWinner(){ - return this.winner; - } -} - - diff --git "a/Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/java/vandresca.java" "b/Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/java/vandresca.java" deleted file mode 100644 index 51752c834e..0000000000 --- "a/Retos/Reto #3 - EL GENERADOR DE CONTRASE\303\221AS [Media]/java/vandresca.java" +++ /dev/null @@ -1,71 +0,0 @@ -import java.util.*; - -/** - * Programa que genere una contraseña en la que se pueda: - * - Elegir si tiene 8 o 16 carácteres - * - Elegir si se quiere que tenga mayúsculas - * - Elegir si se quiere que tenga números - * - Elegir si se quiere que tenga simbolos - */ -public class vandresca { - - private static final String LOWERCASE = "abcdefghijklmnopqrstuvwxyz"; - private static final String UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - private static final String NUMBERS = "0123456789"; - private static final String SYMBOLS = "!@#$%^&*()_+-=[]|,./?><"; - - - public static class Params{ - public Boolean hasLength16; - public Boolean hasUpperCase; - public Boolean hasNumbers; - public Boolean hasSymbols; - } - - public static void main(String[] args) { - Params params = new Params(); - params.hasLength16 = true; - params.hasUpperCase = true; - params.hasNumbers = true; - params.hasSymbols = true; - showPassword(generatePassword(params)); - } - - private static String generatePassword(Params params) { - String sourceChars = getSourceChars(params); - int length = (params.hasLength16)? 16 : 8; - String password = ""; - for(int i=0; i source = Arrays.asList(sourceChars.toString()); - Collections.shuffle(source); - return source.get(0); - } - - private static String randomChar(String sourceChars){ - Random rd = new Random(); - int randomInt = rd.nextInt(sourceChars.length()); - return String.valueOf(sourceChars.charAt(randomInt)); - } - - private static void showPassword(String password){ - System.out.println(password); - } -} - diff --git a/Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/java/vandresca.java b/Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/java/vandresca.java deleted file mode 100644 index eb02162c8d..0000000000 --- a/Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/java/vandresca.java +++ /dev/null @@ -1,58 +0,0 @@ -import java.util.InputMismatchException; -import java.util.Scanner; - -/* - * Escribe un programa que, dado un número, compruebe y muestre si es primo, - * fibonacci y par. - * Ejemplos: - * - Con el número 2, nos dirá: "2 es primo, fibonacci y es par" - * - Con el número 7, nos dirá: "7 es primo, no es fibonacci y es impar" - */ -public class vandresca { - - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - int input; - try{ - input = scanner.nextInt(); - System.out.println(makeMessage(input)); - }catch(InputMismatchException ime){ - - }finally{ - scanner.close(); - } - } - - private static String makeMessage(int input){ - StringBuilder message = new StringBuilder(); - message.append(String.valueOf(input)); - message.append(isPrime(input)); - message.append(isFibonnaci(input)); - message.append(isEven(input)); - return message.toString(); - } - - - private static String isPrime(int number){ - for(int i=2; i scorePlayer2){ - System.out.println("Ha ganado el jugador 1"); - }else if (scorePlayer1 < scorePlayer2){ - System.out.println("Ha ganado el jugador 2"); - }else{ - System.out.println("Ha habido un empate"); - } - System.out.printf("Jugador 1= %d <-> Jugador 2= %d", scorePlayer1, scorePlayer2); - } - - private static Boolean hasEnd(String input){ - return switch(input){ - case "F"->false; - default ->true; - }; - } - - private static Posibility randomOption(){ - Random random = new Random(); - return Posibility.getElement(random.nextInt(5)+1); - } - - private static Player playGame(){ - Posibility resultPlayer1 = randomOption(); - Posibility resultPlayer2 = randomOption(); - Player winner; - - if(resultPlayer1.equals(Posibility.ROCK)){ - if(resultPlayer2.equals(Posibility.LIZARD) || - resultPlayer2.equals(Posibility.PAPER) ){ - winner=Player.ONE; - }else{ - winner=Player.TWO; - } - }else if(resultPlayer1.equals(Posibility.PAPER)){ - if(resultPlayer2.equals(Posibility.ROCK) || - resultPlayer2.equals(Posibility.SPOCK) ){ - winner=Player.ONE; - }else{ - winner=Player.TWO; - } - }else if(resultPlayer1.equals(Posibility.SCISSORS)){ - if(resultPlayer2.equals(Posibility.PAPER) || - resultPlayer2.equals(Posibility.LIZARD) ){ - winner=Player.ONE; - }else{ - winner=Player.TWO; - } - }else if(resultPlayer1.equals(Posibility.LIZARD)){ - if(resultPlayer2.equals(Posibility.SPOCK) || - resultPlayer2.equals(Posibility.PAPER) ){ - winner=Player.ONE; - }else{ - winner=Player.TWO; - } - }else{ - if(resultPlayer2.equals(Posibility.SCISSORS) || - resultPlayer2.equals(Posibility.ROCK) ){ - winner=Player.ONE; - }else{ - winner=Player.TWO; - } - } - System.out.println(resultPlayer1 + " - "+ resultPlayer2+" => " + winner); - return winner; - } - -}