Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto,
2002.
Lab 1: Introduction to Lab. Environment and Object Orientation
A cell is an area assumed will be served by an RBS. The cell is the area description of how to cover a certain shape of area. Among them, three types of area shapes will be defined. In order to treat any types of cell in the same way, there should be a general classification for cell that can be defined in Cell Class.
The general classification of a Cell Class is as follows:
These definitions can be implemented in Java Language as follows :
File name: Cell.java
Class Fields :
Class Constructors:
Class Methods:
import java.lang.Math; // Required by Math.sqrt() static method call in the class definition /** * Abstract class Cell - Defines signatures of a cell * * @author: CPwJ * @version: 1.0 (2002) */ public abstract class Cell { // instance variables //Information about a cell (x,y coordinate and r cell radius) private double x,y,r; /** * Cell constructor */ public Cell() { x=0; y=0; r=0; } /** * Cell constructor * @param x Cell X Location * @param y Cell Y Location * @param r Cell radius */ public Cell(double x, double y, double r) { this.x=x; this.y=y; this.r=r; } /** * Get x coordinate of the cell * @return Cell X Location */ public double getX() { return this.x; } /** * Get y coordinate of the cell * @return Cell Y Location */ public double getY() { return this.y; } /** * Get radius of the cell * @return Cell Radius */ public double getR() { return this.r; } /** * Check whether a point is covered by the cell * @param x The x point of access coordinate * @param y The y point of access coordinate * @return True/False */ public boolean coverage(double x, double y) { if ( distance(x,y) > this.r) { return false; } else { return true; } } /** * Calculate the distance of a point to the cell centre * @param x The x point of access coordinate * @param y The y point of access coordinate * @return Distance to the cell centre */ public double distance(double x, double y) { return Math.sqrt((x-this.x)*(x-this.x) + (y-this.y)*(y-this.y)); } /** * Calculate the area of the cell * @return Cell Area */ public abstract double area(); //Leave this to be constructed by sub classes /** * Represent the Cell content information * @return String cell information */ public String toString() { return ("Cell location at x="+ x +",y=" + y +" serving area= "+area()); } } |