CS163/CS164 Programming Assignment 9
Classes, constructors and more

Due Monday, Jul. 16th at 6:00pm
Late Tuesday, Jul. 17th at 8:00am

Overview

In this assignment you will finish the implementation of two classes in a stepwise manner:

Description

This program deals with Points, that are elements of a Cloud (a set of Points). Implement these classes in a step-wise (one method at the time) fashion: first you implement Point, and test it using the provided main method of Point, then implement Cloud, and test it using the provided main method of Cloud. It is a good idea to create more test cases in your mains. Put your name in a comment at the top of your Point and Cloud classes.

Point

A Point in a two dimensional plane has double x and double y coordinates. Because double comparisons cannot be based on exact equality, the Point class has a
   public static final double EPSILON = 1e-5;
The static final modifier indicates that the value epsilon is constant and shared by all Point objects. To access it, use Point.EPSILON. Compare this to e.g. the Math.PI constant in the class Math. The provided toString method produces a String (x,y), eg "(0.0,0.0)".

Stepwise implement the following methods:

The main method is provided and will do an initial test of your Point implementation. Add more tests to your main method.

Cloud

When you are happy with Point, move on to Cloud. Clouds have an ArrayList<Point> points, instance variable that will hold the points of the Cloud. The Cloud (Constructor) and toString method are provided, so we all print in the same format. Stepwise implement the following methods: Here is the result of running Cloud, when debug is OFF.

The main method, again, does an initial test of the Cloud implementation.

Submitting Your Assignment

Put your name in the Point and Cloud classes. If you used a debug flag, make sure you turn it to false before submitting.

Submit one file P9.jar, containing your Cloud.java and Point.java. To create a jar file in Eclipse, select Export from the File menu, then under wizards select Java / JAR as the wizard type. Choose the project (if necessary), uncheck Export generated class and check Export Java source files. See below: