Now we are going to make the Crewmate class which will consist of keeping track of our tasks, "sus"ing people, or getting eliminated.
Create the Crewmate class that is also a Player
Create a new private state called in taskCounter
The constructor of the Crewmate takes a String Parameter for name.
super the name, true, false to the Player class.
The true communicates we are alive
The false communicates we are not the imposter
Instead of a parameter for these, we know they are true and hardcoded these in
In the constructor set the taskCounter to 0.
Write a method called void doTask()
If the crewmate is alive, increase the taskCounter by 1
If the crewmate is alive, print out "Name: Task taskCounter Complete"
We have just implemented the abstract method from player!
Write a method called void susPlayer(Player p)
If alive, print out "Name has 'sus'ed p.Name ..."
If Player p is an imposter
Print out "Name was correct!"
Then write this line: PlayerDriver.gameOver = PlayerDriver.CREWWIN; (Updates win status, this will mark as incorrect until you add my Driver class)
Else
Print out "Name was incorrect"
Write a method called void gotEliminated()
Set the isAlive status to false
Print out "Name has been eliminated"
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");
}
}
}
}