How to turn it in: Follow the instructions for each problem,
and turn in the files electronically as instructed on the web
page.
1. [10 pts] Do the lab exercise on pp. 105-106, using Code Warrior. (The Circle class problem). There should be an application file (patterned after RectangleUser in Chapter 1) and a separate class file Circle.java. You only need to turn in the Circle.java file.
We have chosen this 2-file set-up (1) to give you experience designing a class separately from the application it happens to be needed for today, so that you will think more about re-usability of your classes and other applications that might use them and (2) to make sure you are comfortable with programs that use more than 1 class file.
Note : Please make sure that your code follows the following naming
conventions:
(You do not have to resubmit if you already submitted your homework.
This is only for people who have not previously submitted their
homework.)
Java file name : Circle.java
Constructor : Circle (double radius)
Accessors: public double calculateArea()
public double calculateCircumference()
public double calculateDiameter()
Mutators : public void setRadius(double)
public void setDiameter(double)
2. [5 pts] Do exercise 3, p. 111.
3. [5 pts] Describe the relationship we want among subclasses. For example, how do we know something should be a subclass of another class?
4. [5 pts] Why is encapsulation and information hiding important for
programs? How can we achieve these in Java?