Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto, 2002.

[Contents] [Next] [Previous]

Lab 1: Introduction to Lab. Environment and Object Orientation


CircleCell Class

The CircleCell Class is a subclass of Cell Class. It is a specialized cell which only handles circular shape cells. Thus, there should be some overrides in the class definition to make it more specialized.

The special classification of a CircleCell Class is as follows:

These definitions can be implemented in Java Language as follows :

File name: CircleCell.java

Class Fields :

Class Constructors:

Class Methods:

import java.lang.Math;
/**
* A SquareCell
*
* @author CPwJ
* @version 1.0 (2002)
*/

public class CircleCell extends Cell
{
private static final double RATIO = Math.PI; //ratio used in area calculation
private static final String CELLTYPE = "Circular"; //type of cell shape
/**
* CircleCell constructor
* @param x Cell X coordinate
* @param y Cell Y coordinate
* @param r Cell Radius
*/

public CircleCell(double x, double y, double r)
{
super(x,y,r);
}
/**
* Calculate the area of a Circular shape Cell
* @return the area of the Circular Cell
*/
public double area(
)
{
return RATIO*getR()*getR();
}
}

[Contents] [Next] [Previous]