class TitForTat extends Prisoner {

    private String startingMove;
    private String opponentsMove;
   
    public TitForTat(String startingMove) {
        super(startingMove.equals("COOPERATE") ? "nice_tit_for_tat" : "nasty_tit_for_tat");
        this.startingMove = startingMove;
        this.opponentsMove = "";
   }

    public String move() {
        // If the variable contains the empty string, then this is the opponent's first move, 
        // and so this prisoner picks his/her starting move
        // Otherwise, s/he copies the opponent's previous move.
        if (opponentsMove.equals("")) { 
            return startingMove;
        }
        return opponentsMove;
    }

    public void memoriseHistory(String opponentsMove) {
        this.opponentsMove = opponentsMove;
    }

    public void forgetHistory() {
        opponentsMove = "";
    }
    
}
