Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cronometro;
- import java.util.*;
- public class Cronometro2 {
- // public static String[] embaralhar(String[]
- // ...vetores) {
- // List<String> items = new ArrayList<>();
- // for (String[] vetor : vetores) {
- // for (String posicao : vetor) {
- // items.add(posicao);
- // }
- // }
- // long seed = System.nanoTime();
- // Collections.shuffle(items, new Random(seed));
- //
- // return (String[]) items.toArray(new String[items.size()]);
- // }
- public static void main(String[] projeto) {
- Scanner digitação = new Scanner(System.in);
- long tempoTotal = 0;
- System.out.println("Qual puzzle você deseja treinar: skewb, 2x2, 3x3 ou megaminx?");
- String resposta = digitação.nextLine();
- for (int solvesCounter = 1; solvesCounter < 13; solvesCounter++) {
- if (resposta.contains("cubo")) {
- String[] moves1 = {"F", "B", "U", "D", "R", "L"};
- String[] moves2 = {" ", "' "};
- Random r = new Random();
- String s = "";
- String f = "";
- for (int i = 0; i < 26; i++) {
- do {
- f = moves1[r.nextInt(6)];
- } while (f == s);
- s = f;
- System.out.print(s);
- String u = moves2[r.nextInt(2)];
- System.out.print(u);
- }
- System.out.println();
- System.out.println("------------------------------------------------------------------------");
- } else if (resposta.contains("2x2")) {
- String[] moves1 = {"F", "U", "R"};
- String[] moves2 = {" ", "' "};
- Random r = new Random();
- String s = "";
- String f = "";
- for (int i = 0; i < 8; i++) {
- do {
- f = moves1[r.nextInt(3)];
- } while (f == s);
- s = f;
- System.out.print(s);
- String u = moves2[r.nextInt(2)];
- System.out.print(u);
- }
- System.out.println();
- System.out.println("------------------------------------------------------------------------");
- } else if (resposta.contains("skewb")) {
- String[] moves1 = {"B", "U", "R", "L"};
- String[] moves3 = {" ", "' "};
- Random r = new Random();
- String s = "";
- String f = "";
- for (int i = 0; i < 12; i++) {
- do {
- f = moves1[r.nextInt(4)];
- } while (f == s);
- s = f;
- System.out.print(s);
- String u = moves3[r.nextInt(2)];
- System.out.print(u);
- }
- System.out.println();
- System.out.println("------------------------------------------------------------------------");
- } else {
- System.out.println("------------------------------------------------------------------------");
- String[] moves1 = {"++", "--"};
- String[] moves2 = {"U", "U'"};
- Random r = new Random();
- for (int j = 0; j < 8; j++) {
- for (int i = 0; i < 11; i++) {
- if (i % 2 == 0) {
- System.out.print("R");
- } else {
- System.out.print("D");
- }
- String s = moves1[r.nextInt(2)];
- System.out.print(s + " ");
- if (i == 10) {
- String u = moves2[r.nextInt(2)];
- System.out.println(u);
- }
- }
- }
- System.out.println("------------------------------------------------------------------------");
- }
- System.out.println("Está pronto? Pressione Enter para começar a contagem de tempo!");
- String estouPronto = digitação.nextLine();
- long começo = System.currentTimeMillis();
- System.out.println("TEMPO CORRENDO! MONTA SAPORRA AÊEEEE"); //gambiarra para manter o programa em execução durante a solve;
- String prolongamentoDeExecução = digitação.nextLine(); //apenas para que usuário dê Enter e o programa continue para a próxima etapa;
- long segundos = (System.currentTimeMillis() - começo) / 1000;
- // long centesimoFinal = (System.currentTimeMillis() -(System.currentTimeMillis() - começo) / 1000) / 100;
- tempoTotal = tempoTotal + segundos;
- long minutoFinal = segundos / 60;
- segundos = segundos % 60;
- //System.out.println("Resolveu em: " + segundoFinal + "." + centesimoFinal + " segundos!");
- if (segundos == 1) {
- System.out.println("Resolveu em: 0" + segundos);
- } else if (segundos < 10) {
- System.out.println("Resolveu em: " + minutoFinal + ": 0" + segundos);
- } else {
- System.out.println("Resolveu em: " + minutoFinal + ": " + segundos);
- }
- System.out.println("------------------------------------------------------------------------");
- // solvesCounter++;
- //
- // if (solvesCounter == 1) {
- //
- // System.out.println("Você já resolveu seu cubo " + solvesCounter + " vez.");
- //
- // } else {
- //
- // System.out.println("Você já resolveu seu cubo " + solvesCounter + " vezes.");
- double media = tempoTotal / solvesCounter;
- double mediaMinuto = media / 60;
- double mediaSegundo = media % 60;
- int minuto = (int) mediaMinuto;
- int segundo = (int) mediaSegundo;
- if (mediaSegundo == 1) {
- System.out.println("Média: 0" + mediaSegundo);
- } else if (mediaSegundo < 10) {
- System.out.println("Sua média: " + minuto + ": 0" + segundo);
- System.out.println("------------------------------------------------------------------------");
- } else {
- System.out.println("Sua média: " + minuto + ": " + segundo);
- System.out.println("------------------------------------------------------------------------");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement