Skip to content

Instantly share code, notes, and snippets.

@AdryDev92
Created November 16, 2016 18:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AdryDev92/625980251547e1d512abd7e96caaaa52 to your computer and use it in GitHub Desktop.
Save AdryDev92/625980251547e1d512abd7e96caaaa52 to your computer and use it in GitHub Desktop.
Calculadora CoC
import java.util.*;
public class Coc {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String tropa, hecho;
int total, cantidad;
String[] tropas = {"Barbaro","Arquera","Gigante","Mago","Dragón","Pekka","Esqueleto","Goblin","Globo","Sanadora"};
int[] costes = {200,400,3000,3500,33000,36000,3000,100,3500,10000};
System.out.println("#######################################");
System.out.println("### CALCULADORA DE CLASH OF CLANS ###");
System.out.println("#######################################");
System.out.println("### ###");
System.out.println("### Calcula tus costes ###");
System.out.println("### de tropas ###");
System.out.println("### ###");
System.out.println("#######################################");
do{
System.out.println("\nElige tropa:\n");
for (int i = 0; i < tropas.length; i++) {
System.out.println(tropas[i] + " | " + costes[i]);
}
tropa = input.nextLine();
System.out.println("\nElige cantidad:\n");
cantidad = input.nextInt();
switch (tropa) {
case "barbaro":
total = cantidad * 200;
System.out.println("Coste total: " + total + " de elixir");
break;
case "arquera":
total = cantidad * 400;
System.out.println("Coste total: " + total + " de elixir");
break;
case "gigante":
total = cantidad * 3000;
System.out.println("Coste total: " + total + " de elixir");
break;
case "mago":
total = cantidad * 3500;
System.out.println("Coste total: " + total + " de elixir");
break;
case "dragon":
total = cantidad * 33000;
System.out.println("Coste total: " + total + " de elixir");
break;
case "pekka":
total = cantidad * 36000;
System.out.println("Coste total: " + total + " de elixir");
break;
case "esqueleto":
total = cantidad * 3000;
System.out.println("Coste total: " + total + " de elixir");
break;
case "goblin":
total = cantidad * 100;
System.out.println("Coste total: " + total + " de elixir");
break;
case "globo":
total = cantidad * 3500;
System.out.println("Coste total: " + total + " de elixir");
break;
case "sanadora":
total = cantidad * 10000;
System.out.println("Coste total: " + total + " de elixir");
break;
default:
System.out.println("!Opción incorrecta!");
break;
}
}while(tropa != "hecho");
System.out.println("Suerte y a la batalla");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment