Overview · Learning Goals · Files Provided · How to Test · Specifications · Constraints · Checklist · Submission · Grading
In this lab you will implement two small Java classes that model objects and their relationship: Point and Circle. This lab focuses on class structure and core object-oriented programming fundamentals.
this(...)Circle has a Point)toString()Download all four files and place them in the same directory.
Point.javaCircle.java
These files contain Javadoc and TODO: comments. Complete the
TODOs while keeping the required method signatures intact.
PointTester.java
(basic checks for development and debugging)
CircleTester.java
(basic checks for development and debugging)
The testers check several specific parts of your implementation and can help you identify common problems while you work.
PointTester.java or
CircleTester.java.
They are provided for development and self-checking.
Compile your classes and the provided testers from the same directory. Run each tester as you work to check specific parts of your implementation.
javac Point.java Circle.java PointTester.java CircleTester.java
java PointTester
java CircleTester
Run the testers as you work. Any FAIL messages can help you identify problems in your implementation.
toString()
formats exactly.
this(...), the required
private validation helper, and required delegation must still be satisfied
even when all basic tests pass.
PointA Point represents a location in 2D space.
x coordinate (double) and a y coordinate (double)Point() initializes to (0.0, 0.0) and must delegate using this(...)Point(double x, double y)toString() must return exactly: (x, y)
Use PointTester.java to test constructors, getters, setters, and toString().
CircleA Circle is defined by a center point and a radius.
Point) and a radius (double)Circle() initializes to center (0.0, 0.0) and radius 1.0, and must delegate using this(...)Circle(Point center, double radius)Circle(double x, double y, double radius)toString() must return exactly:
Center: (x, y), Radius: r
Circle.toString() must obtain the center text by calling
Point.toString(). Do not manually rebuild (x, y).
Use CircleTester.java to check constructors, radius validation, setters, and required observable output.
main methods to Point or CirclePoint or Circlestatic instance variablesthis(...) to avoid duplicate initialization codePoint.java and Circle.java compile without errorsPoint() delegates using this(0.0, 0.0)Circle() delegates using this(...) rather than duplicating initializationCircle.toString() obtains its center text by calling center.toString()Navigate to your personal Google Drive folder for CS231 and open the Projects folder.
For this lab, upload:
Point.javaCircle.javathis(...)Circle → Point)