Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Map;
  3. import java.util.Scanner;
  4.  
  5. public class Heroes {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.         int n = Integer.parseInt(scan.nextLine());
  9.  
  10.         HashMap<String,HashMap<String,Integer>> heros = new HashMap<>();
  11.  
  12.         //heros.put("Bojo",new HashMap<>());
  13.         //heros.get("Bojo").put("Manna",100);
  14.         //heros.get("Bojo").put("HP",100);
  15.  
  16.         for (int i = 0; i < n; i++) {
  17.             String command = scan.nextLine();
  18.             String[] cmd =command.split(" ");
  19.             heros.put(cmd[0],new HashMap<>());
  20.             heros.get(cmd[0]).put("HP", Integer.valueOf(cmd[1]));
  21.             heros.get(cmd[0]).put("MP",Integer.valueOf(cmd[2]));
  22.  
  23.  
  24.         }
  25.  
  26.         while (true){
  27.             String command = scan.nextLine();
  28.             String[] commandParts =command.split("-");
  29.  
  30.  
  31.             if (commandParts[0].equals("CastSpell")) {
  32.                 if (heros.get(commandParts[1]).get("MP")>Integer.parseInt(commandParts[2]) ){
  33.  
  34.  
  35.                 }else{
  36.                     System.out.println(commandParts[1]+" does not have enough MP to cast "+commandParts[3]+"!");
  37.                 }
  38.  
  39.  
  40.             }if (commandParts[0].equals("TakeDamage")){
  41.  
  42.             }if (commandParts[0].equals("Recharge")){
  43.  
  44.             }if (commandParts[0].equals("Heal")){
  45.  
  46.             }if (commandParts[0].equals("End")){
  47.                 break;
  48.             }
  49.         }
  50.  
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement