Eclipse Workshop
Itinerary
1. New Project
2. Perspectives, Views, etc.
3. Debugging
4. Scrapbook
5. Code Completion
6. Auto commenting
7. Ant etc.
Point
package geometry;
public class Point
{
private double x;
private double y;
/**
* Construct a point from its coordinates.
* @param x the x coordinate of the point
* @param y the y coordinate of the point
*/
public Point(double x, double y)
{
this.x = x;
this.y = y;
}
/**
* Construct the default point (0,0).
*/
public Point()
{
x = 0.0;
y = 0.0;
}
/**
* Return the x coordinate of this point.
* @return the x coordinate of this point
*/
public double getX()
{
return x;
}
/**
* Return the y coordinate of this point.
* @return the y coordinate of this point
*/
public double getY()
{
return y;
}
/**
* @return a string representation of a Point
*/
public String toString()
{
return "Point[" + x + ", " + y + "]";
}
}
Circle
package geometry;
public class Circle
{
private Point center;
private double radius;
/**
* Construct circle with given center point and radius.
* @param p the center of the circle
* @param r the radius of the circle
*/
public Circle(Point p, double r)
{
center = p;
radius = r;
}
/**
* Construct circle with given center coordinates and radius.
* @param x the x coordinate of the circle center
* @param y the y coordinate of the circle center
* @param r the radius of the circle
*/
public Circle(double x, double y, double r)
{
center = new Point(x,y);
radius = r;
}
/**
* Construct a default circle: a unit circle with center (0,0)
* and radius 1.
*/
public Circle()
{
center = new Point();
radius = 1;
}
/**
* Return radius of circle.
* @return radius of circle
*/
public double getRadius()
{
return radius;
}
/**
* Return center of circle.
* @return center of circle
*/
public Point getCenter()
{
return center;
}
/**
* @return a string representation of a Circle
*/
public String toString()
{
return "Circle[" + center + ", " + radius + "]";
}
}
Resources