Created
May 25, 2019 02:41
-
-
Save khayyamsaleem/27c8a869cd9500cef6249d0bdafe9c49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.HashMap; | |
public class Pokemon { | |
String name, type; | |
int maxHP, currentHP; | |
HashMap<String, Integer> moves; | |
public Pokemon(String name, String type, int maxHP){ | |
this.name = name; | |
this.type = type; | |
this.maxHP = maxHP; | |
this.currentHP = maxHP; | |
this.moves = new HashMap<>(); | |
} | |
public void addMove(String name, int damage){ | |
this.moves.put(name, damage); | |
} | |
public String toString(){ | |
return String.format("Name: %s, Type: %s", name, type); | |
} | |
public static void main(String[] args){ | |
Pokemon p = new Pokemon("Mankey", "fighting", 200); | |
p.addMove("low kick", 10); | |
p.addMove("karate chop", 5); | |
System.out.println(p); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment