private
, Getters, Setters, and toString
Due Friday, December 15 at 11:59 PM
By the time you have completed this work, you should be able to:
toString
method in a class
Rectangle.java
Download the Rectangle.java
file, and open it in jGrasp (or a text editor of your choice).
You will need to define a constructor for this class
, along with a series of methods.
The comments in Rectangle.java
provide further details.
Note that there is no main method, so you cannot run this program directly.
RectangleTest.java
Download the RectangleTest.java
file, being sure to put it in the same folder/directory as your Rectangle.java
file from step 1.
RectangleTest.java
contains a bunch of tests for the methods you wrote in the previous step.
Use the instructions here to open RectangleTest.java
as a tests file, then compile and run the tests.
All the tests have been provided, and assuming you implemented your methods correctly in the previous step, they should all pass.
You do not need to save the compiled file. However, you should still complete this step, as this step makes sure that yor completed the previous step correctly.
RectangleMain.java
Download the RectangleMain.java
file, and open it in jGrasp (or a text editor of your choice).
You will have to complete the addSomethingToWidthHeight
method in this file.
The comments in RectangleMain.java
provide further details.
Example output from this program follows:
BEFORE: R1: Rectangle(3, 4) R2: Rectangle(5, 6) AFTER: R1: Rectangle(8, 9) R2: Rectangle(9, 10)
Log into Canvas, and go to the COMP 110 class. Click “Assignments” on the left pane, then click “Lab 5”. From here, you can upload your answers and your code. Specifically, you must turn in the following two files:
Rectangle.java
RectangleMain.java
In addition, if you collaborated with anyone else, be sure to download collaborators.txt
and write the names of the people you collaborated with in the file, one per line.
Please submit this file along with the other files.
You can turn in the assignment multiple times, but only the last version you submitted will be graded.