In this lab, you will explore Eclipse. If you already use the Eclipse editor, this lab may provide you with more information.
All Eclipse applications are built as a project. If you choose to use Eclipse this semester, each lab and each PA that you complete will be in its own project and each project will have its own folder.
PointLab
: The return value of the toString
method should
consist of an open-parenthesis followed by the x-coordinate, followed
by a comma, then a space, then the y-coordinate followed by a
close-parenthesis. For example: "(1.0, 2.0)"
.
The equals
method should return true if the two
points have the same x position and y position.
Point
class, move on to the next step.One standard mechanism for distributing Java code is through .jar files. A .jar file is a compressed archive that can hold any number of Java classes in either source or binary form (as .java files or as .class files). For some projects in this course you will be provided with .jar files containing support code.
PointCode.jar
and select Build Path -> Add to Build
Path.
PointCode.jar
archive. All classes
included in that archive are now available within your project. In
this case there is only one
class: PointDisplay.
PointDemo
class to get a feel for what
it should do. Run the code to confirm that everything is
working as expected.
Checkstyle is a development tool that makes it easy to test Java code against a particular coding standard. Our Web-CAT submission system will analyze your programming assignments using Checkstyle to verify that they conform to the CS159 style guide. It will be in your best interest to use Checkstyle off-line so that you can avoid wasting your limited submissions. Checkstyle can be run from the command line, but today we will try it out using an Eclipse plug-in.
PointLab
project in
the "Package Explorer" tab and then select Properties -> Checkstyle. Click on the
check-box labeled "Checkstyle active for this project".
Point.java
file, right-click in the editor window
and select "validate". Many lines of code should now be marked in
yellow. Each of these marked lines contains a violation of the
style guidelines that would prevent you from successfully submitting
a programming assignment. Clicking on the yellow magnifying glasses
in the left margin will show you a description of the problem.
We'll fix these problems in the next part of the lab.
One of Eclipse's handiest features is the ability to automatically handle low-level code formatting. This dramatically reduces the effort involved in producing consistently formatted (and thus more readable) code. This auto-formatting feature will also help you write code that conforms to the course coding standards.
Point.java
file by selecting the entire file (CTRL-A) and then pressing SHIFT-CTRL-F.
Point
class. Eclipse will automatically generate a Javadoc template for
any method. You can either type /**[ENTER]
just above
the method, or select the method and press SHIFT-ALT-J.
Point.java
. (For submissions involving multiple files you'll need to create a zip archive containing all of your code. Since this lab only involves a single file, we can skip that step.)