Question: In this activity, you will create the Celebrity subclass you designed earlier in the CustomCelebrity class. Define the instance variables for the CustomCelebrity subclass. Write

In this activity, you will create the Celebrity subclass you designed earlier in the CustomCelebrity class.

  1. Define the instance variables for the CustomCelebrity subclass.
  2. Write the constructor for your class.
  3. Override the getClue and/or the getAnswer method(s).
  4. Override the toString method.
  5. Write any other methods that your design has indicated will be required. Look over your design plan and make sure that you have implemented all required components. Check that your code compiles, making sure to test any methods you write.

public class Celebrity { public class Celebrity { /** * The clue to determine the celebrity */ private String clue; /** * The answer or name of the celebrity. */ private String answer; /** * Creates a Celebrity instance with the supplied answer and clue * @param answer * @param clue */ public Celebrity(String answer, String clue) { this.clue = clue; this.answer = answer; } /** * Supplies the clue for the celebrity * @return */ public String getClue() { return clue; } /** * Supplies the answer for the celebrity. * @return */ public String getAnswer() { return answer; } /** * Updates the clue to the provided String. * @param clue The new clue. */ public void setClue(String clue) { this.clue = clue; } /** * Updates the answer to the provided String. * @param answer The new answer. */ public void setAnswer(String answer) { this.answer = answer; } /** * Provides a String representation of the Celebrity. */ @Override public String toString() { String description = "The Celebrity's name is: " + answer + ". The clue for this celebrity is: " + clue; return description; } }

}

public class CustomCelebrityTester { public static void main(String[] args) { //Test that your CustomCelebity class works here! } }

public class CustomCelebrity extends Celebrity { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!