
import java.util.function.*;
import java.util.*;

class Character {
	private String name;
	private int health;
	private Consumer<Character> attackMethod;
	public Character(String name) {
		this.name = name;
		this.health = 100; // born with maximum health
	}
	public String getName() { return name; }
	public void setAttackMethod(Consumer<Character> lambda) {
		attackMethod = lambda;
	}
	public int getHealth() { return health; }
	protected void decHealth(int blow) {
		health = Math.max(0, health - blow);
	}
	public String toString() {
		String result = name + ": health = " + health;
		return result;
	}

	public void attack(Character victim) {
		System.out.println(name + " is attacking " + victim.getName());
		attackMethod.accept(victim);
	}




}

public class Tournament {
	public static void main(String[] args) {
		Character dragon = new Character("Dragoo");
		Character knight = new Character("Dudley");
		dragon.setAttackMethod((c)->{
			System.out.println("a ball of fire flies through the air");
			c.decHealth(10);
		});

		knight.setAttackMethod((c)->{
			System.out.println("a sword slashes");
			c.decHealth(10);
		});

		for(int i = 0; i < 10; i++) {
			dragon.attack(knight);
			knight.attack(dragon);
		}
	}
}

