Question: Consider the class given below. CLEARLY answer the questions that follow: public class InnocentTownsperson { private boolean isAlive; private boolean isCollegeStudent; private boolean isTavernKeeper; private
Consider the class given below. CLEARLY answer the questions that follow: public class InnocentTownsperson { private boolean isAlive; private boolean isCollegeStudent; private boolean isTavernKeeper; private long timeLeftToLive; public InnocentTownsperson (boolean isCollegeStudent, long timeLeftToLive) { isAlive = true; this.isCollegeStudent = isCollegeStudent; this.isTavernKeeper = !isCollegeStudent; this.timeLeftToLive = timeLeftToLive; } public boolean isAlive() { return isAlive; } public boolean isCollegeStudent() { return isCollegeStudent; } public void becomeZombie() { isAlive = false; isCollegeStudent = false; isTavernKeeper = false; timeLeftToLive = 0; } public long getTimeLeftToLive() { return timeLeftToLive; } } What is the name of this class? What are the attributes of this class? For each attribute, give the data type. What are the behaviors of this class? Write the code fragment to carry out the following tasks:
- Create the InnocentTownsperson object (make up any data required)
- Using the InnocentTownsperson you created, print out a message stating whether or not this person is a college student
- Make the person into a zombie
Step by Step Solution
3.58 Rating (158 Votes )
There are 3 Steps involved in it
Name of the class InnocentTownsperson Attributes isAlive boolean isCollegeStudent boole... View full answer
Get step-by-step solutions from verified subject matter experts
