Crewmate

Now we are going to make the Crewmate class which will consist of keeping track of our tasks, "sus"ing people, or getting eliminated.

  1. Create the Crewmate class that is also a Player

  2. Create a new private state called in taskCounter

  3. The constructor of the Crewmate takes a String Parameter for name.

    1. super the name, true, false to the Player class.

    2. The true communicates we are alive

    3. The false communicates we are not the imposter

    4. Instead of a parameter for these, we know they are true and hardcoded these in

    5. In the constructor set the taskCounter to 0.

  4. Write a method called void doTask()

    1. If the crewmate is alive, increase the taskCounter by 1

    2. If the crewmate is alive, print out "Name: Task taskCounter Complete"

    3. We have just implemented the abstract method from player!

  5. Write a method called void susPlayer(Player p)

    1. If alive, print out "Name has 'sus'ed p.Name ..."

    2. If Player p is an imposter

      1. Print out "Name was correct!"

      2. Then write this line: PlayerDriver.gameOver = PlayerDriver.CREWWIN; (Updates win status, this will mark as incorrect until you add my Driver class)

    3. Else

      1. Print out "Name was incorrect"

  6. Write a method called void gotEliminated()

    1. Set the isAlive status to false

    2. Print out "Name has been eliminated"

Mr. Wile's Crewmate Class ****WARNING ONLY IF NEEDED****


public class Crewmate extends Player{

private int taskCounter = 0;

public Crewmate(String n) {

super(n, true, false);

}


public void doTask() {

if(getIsAlive()) {

taskCounter++;

System.out.println(getName() + ": Task " + taskCounter + " Complete");

}

}

public void gotEliminated() {

setIsAlive(false);

System.out.println(getName() + " has been eliminated");

}

public void susPlayer(Player p) {

if(getIsAlive()) {

System.out.println(getName() + " has 'sus'ed " + p.getName() + "...");

if(p.getIsImposter()) {

System.out.println(getName() + " was correct");

PlayerDriver.gameOver = PlayerDriver.CREWWIN;

}

else {

System.out.println(getName() + " was incorrect");

}

}

}


}