Hello everyone, I have a little question regarding a project for my class. We are making a tower defense game with ants and zombies objects for our project. My question is with this piece of code provided to us.

  /**
     * Callback invoked when the player attempts to recruit an ant.
     * @param antType Type of ant to recruit
     * @return true if the player may recruit the ant, false if not.
     */
    public boolean recruitAnt(String antType);

This is code from an interface file that was prvoided to us. I have no idea what "Callback invoked" means and how to turn String antType into the object of ant. So far I have an abstract base class Ant from which to create other ants.

package proj4;

public abstract class Ant {

    private int life;
    private String desc;
    private int cost;

    public Ant(int cost, int life, String desc){
        this.life = life;
        this.desc = desc;
        this.cost = cost;
    }

    public void takeDamage(int amount, Zombie z){
        life -= amount;
    }

    public void takeDamage(int amount){
        life -= amount;
    }

    public int getLife() {
        return life;
    }

    public String getDesc(){
        return desc;
    }

    public int getCost(){
        return cost;
    }

    public abstract void attack(Game g);

}

If anyone could give me pointers on what I'm supposed to do I would very much appreciate it. Thank you

I think you can safely ignore "callback" for now, just concentrate on writing the method.
Ant is an abstract class, so you will have to create one or more subclasses of Ant, each corresponding to a different type of ant. There also seems to be a String (called antType) that identifies each type of ant (ie which sub-class of Ant).
Presumably a player can only recruit certain type(s) of Ant, so you need to check the antType against som kind of data in the player that says what kind of Ant they can recruit.
I'm guessing a bithere, because I don't have the complete project spec in front of me, and wouldn't have the time to read it all even if I did!

Yes seems like I didnt have to do anything really special. I just made a bunch of if statements to check whether the string corresponds with a certain ant. But thanks again JamesCherrill! Youre always a big help!

This question has already been answered. Start a new discussion instead.