Point - Circle - Cylinder
Now we enhance the Point and Circle classes and develop a
package for them so that we can import methods and variable
instances. We develop the Point class then extend it into the
Circle. Then we extend the Circle class to develop the Cylinder
class. This also serves to illustrate some differences between
packaging and using some features of a class, of ten called composition
and using inheritance to extend a class.
First we will redevelop the Point class, then we will develop the Circle class and then we will test them.
Now the code for Point.java should be copied into a new directory.
Now we want to test this class we've developed after making sure we use the
javac -d c:\jdk1.2.1\jre\classes Point.java
to create the package class.
Now you want to test this with TestPoint.java.
Now we are going to extend this Point class into a subclass
Now the code for Circle.java should be copied into a new directory.
You need to make sure to compile this in order to develop the package. Then you want to test this class with the following code, TestCircle.java.
Now we are going to take this even further by developing a Cylinder class by inheriting the Circle class. You want to copy the following code and call it Cylinder.java.
Because you are creating a package you need to make sure you use the compile command with the path and the -d.
Now you need to execute the TestCylinder.java application.
This makes use of a fairly elaborate system of packaging and inheritance.