Skip to content

Instantly share code, notes, and snippets.

@khayyamsaleem
Created May 25, 2019 02:41
Show Gist options
  • Save khayyamsaleem/27c8a869cd9500cef6249d0bdafe9c49 to your computer and use it in GitHub Desktop.
Save khayyamsaleem/27c8a869cd9500cef6249d0bdafe9c49 to your computer and use it in GitHub Desktop.
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