Rules of submission
This assignment must be submitted to the Moodle submission page for Homework 10 by 11:00 PM on Monday, 1 April.
Your submission must contain two classes
Point1080
and WritePoints
in the
edu.unca.cs.csci202
package.
Getting started
You should start with the Point1080
class
you turned in to Homework 8
or the one provided for Lab 11.
When you create your new WritePoints
class,
cut-and-paste your randomPoints
method into it.
The task
First, add a method toString
to your
Point1080
class.
You should get into the
habit of overriding the default
toString
whenever you write an interesting class.
In this case,
our toString
should return the convention tuple representation
of a point, such as "(202,255)"
.
Second, have the main
method of
WritePoints
ask the “user” for (1) the name
of a file to create and (2) the number of random points to write
to that file.
Read the file name first and then the number of points.
Also, read an entire line for the file name to allow
the inclusion of white space within the file name.
(A practice that has, in my opinion,
become too common.)
Do some input validation. If the “user” provides a bad file name or bad number, but sure that your program handles the exceptions Java will generate in these cases.
I suggest you use the FileWriter and PrintWriter in your application. There are examples of doing this in the textbook or all over the internet. You can even try the official Java tutorial on character stream I/O. See the CopyLine.java example for inspiration.