Created
February 10, 2013 03:06
-
-
Save lucaspolo/4748201 to your computer and use it in GitHub Desktop.
Falta do que fazer, brincar um poquinho de Genius em Java. :-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.lucaspolo.genius; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Scanner; | |
public class Genius { | |
private static Scanner scanner; | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
scanner = new Scanner(System.in); | |
List<Integer> numeros = new ArrayList<>(); | |
while(true) { | |
limpaTela(); | |
System.out.println("Digite um numero de cada vez e pressione enter..."); | |
for(int i=0; i < numeros.size(); i++) { | |
int numeroDigitado = scanner.nextInt(); | |
if(numeroDigitado != numeros.get(i)) { | |
System.out.println("ERROU!!! Tente novamente"); | |
System.exit(0); | |
} | |
} | |
int numeroAleatorio = (int)(Math.random() * 5); | |
System.out.printf("Novo numero: %d\n", numeroAleatorio); | |
System.out.print("Digite ele: "); | |
int numeroDigitado = scanner.nextInt(); | |
if(numeroDigitado != numeroAleatorio) { | |
System.out.println("ERROU!!! Tente novamente"); | |
System.exit(0); | |
} | |
numeros.add(numeroDigitado); | |
} | |
} | |
public static void limpaTela() { | |
for(int i = 0; i < 24; i ++) System.out.println(" "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment