CEL - The Celebrity Class: A Simple Version (Lesson)
The Celebrity Class: A Simple Version
Introduction
In this lab activity, you will create a new class, the Celebrity class. This will be a class that you design after answering a series of questions. Carefully consider the differences between a constructor and a method and how you will include both in the Celebrity class.
The Celebrity Class
Record the answers to the following questions on a sheet of paper. You will need the answers to complete the Lab Check Quiz.
- What is the purpose of a constructor in a class?
- Describe what you know about the heading of a constructor.
- What instance variables need to exist in the Celebrity class?
- Given the play method that was designed for the Game class in the last lab activity, what methods should exist in the Celebrity class?
- Based on your answers to the previous questions, complete the Celebrity class. Use the Celebrity.java file available in the CelebCode folder to help you get started.
- Write code to test your Celebrity class. Use the CelebrityTester.java file located in the CelebCode folder.
Lab content is from the College Board.
Check Your Understanding
Record the answer to the following question on a sheet of paper. You will need the answer to complete the Lab Check Quiz.
7. If your Celebrity class has more than one constructor, explain the difference between the constructors that you wrote. If you only wrote a single constructor, provide the code for an additional constructor that could be included in your class, and discuss how it differs from the constructor that you wrote.
IMAGES CREATED BY GAVS