Question: Hi so I'm having trouble solving this problem: In this exercise, we are going to construct the Celebrity Class. For the purpose of the Celebrity
Hi so I'm having trouble solving this problem:
In this exercise, we are going to construct the Celebrity Class.
For the purpose of the Celebrity Game, a Celebrity needs two instance variables: an answer and clue.
-
Create two these two instance variables in the Celebrity class.
-
Once youve created the instance variables, create the constructor. The constructor should take an answer and a clue as its parameters, in that order.
-
Next, create accessor and mutator methods to access and change the instance variables.
-
Finally, create a toString method that returns the celebritys name and the clue for the celebrity.
For example, if we initialized the Celebrity:
Celebrity bale = Celebrity("Christian Bale", "The lead actor in the most popular Batman movies")System.out.println(bale) would produce:
The Celebrity's name is: Christian Bale. The clue for this celebrity is: The lead actor in the most popular Batman movies
Use the CelebrityTester class to test that your methods and constructor are correct!
This is what I already have:
CelebrityTester.java
public class CelebrityTester { public static void main(String[] args) { Celebrity cel = new Celebrity("Big Bird", "Covered in yellow feathers"); //construct a Celebrity object System.out.println(cel); //test toString System.out.println("Celebrity clue: " + cel.getClue()); System.out.println("Celebrity name: " + cel.getAnswer()); //change the clue cel.setClue("Is 8 feet 2 inches tall"); System.out.println("Celebrity clue: " + cel.getClue()); //change the celebrity and the clue cel.setAnswer("Lionel Messi"); cel.setClue("The best short soccer player in the world."); System.out.println(cel); } }
Screenshot:

Celebrity.java
public class Celebrity { }
Screenshot:
Thanks..
M Run Code Check Code I STOP FILES Celebrity Tester.java Celebrity.java 1 2- public class CelebrityTester { 3 4- public static void main(String[] args) { 5 Celebrity cel = new Celebrity ("Big Bird", "Covered in yellow feath 6 System.out.println(cel); //test toString 7 System.out.println("Celebrity clue: + cel.getclue(); 8 System.out.println("Celebrity name: " + cel.getAnswer(); 9 1/change the clue 10 cel.setClue("Is 8 feet 2 inches tall"); 11 System.out.println("Celebrity clue: " + cel.getclue()); 12 13 1/change the celebrity and the clue 14 cel.setAnswer ("Lionel Messi"); 15 cel.setClue("The best short soccer player in the world."); 16 System.out.println(cel); 17 } 18 19 20 Run Code Check Code I STOP 1 public class Celebrity 2-{ 3 4 } 5 FILES D Celebrity Tester.java Celebrity.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
