// Arup Guha
// 2/17/2018
// Monster class that implements two interfaces!

import java.util.*;

public class Monster implements Scorable, Addable<Monster> {

	private String name;
	private ArrayList<String> moves;

	public Monster(String n) {
		name = n;
		moves = new ArrayList<String>();
	}

	public void addMove(String mymove) {
		moves.add(mymove);
	}

	// Just the number of moves this monster has.
	public int getScore() {
		return moves.size();
	}

	// Returns a string representation of a monster - it's name and all of its moves.
	public String toString() {

		// Tricky case - no moves.
		String res = name;
		if (moves.size() == 0) return res;

		// Add moves, comma separated.
		res = res +" can do ";
		for (int i=0; i<moves.size()-1; i++)
			res = res + moves.get(i)+ ",";

		// Last item doesn't have a comma after it.
		return res + moves.get(moves.size()-1);
	}

	// Returns this + other as a new monster.
	public Monster add(Monster other) {

		// Let's have some fun chopping the names apart and sewing them back together.
		int len1 = this.name.length();
		int len2 = other.name.length();
		String newname = name.substring(0, len1/2) + other.name.substring(0, len2/2) +
						 name.substring(len1/2) + other.name.substring(len2/2);

		// Create our hybrid monster.
		Monster mix = new Monster(newname);

		// Add in all moves from BOTH monsters.
		for (String s: moves)
			mix.addMove(s);
		for (String s: other.moves)
			mix.addMove(s);

		return mix;
	}
}