Ahorcado en Java

October 7, 2022 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download Ahorcado en Java...

Description

 

import java.util.*; public class nave { static String [] blancos; public static String getPalabraSecreta(String [] lasPalabras){ String palSecreta; int ind; int indiceMayor = lasPalabras.length -1; int indiceMenor =0; ind = (int) (Math.floor(Math.random() * (indiceMayor - indiceMenor + 1)) + indiceMenor); return lasPalabras[ind]; } public static void mostrarBlancos(String palabra){ blancos=new String[palabra.length()]; for(int i=0; i< palabra.length(); i++){ System.out.print("_ " ); blancos[i]="_ "; } } public static String ingreseLetra(ArrayList ingreso){ String laLetra; Scanner sc = new Scanner(System.in); System.out.println("Ingrese letra: "); laLetra = sc.next(); while(laLetra.length()!= 1||ingreso.contains(laLetra.charAt(0))){ System.out.println("Ingrese letra: "); laLetra = sc.next(); } return laLetra; } // Este metodo debe completarlo public static boolean letraEnPalabraSecreta(String letra, String palSecreta ){ char [] letras=new char[palSecreta.length()]; char letraa=letra.charAt(0); for (int i = 0; i < letras.length; i++) letras[i] =palSecreta.charAt(i); for(int i=0;i
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF