private
, Getters, Setters, toString
, and Memory RepresentationDue Friday, February 23 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)
A handout concerning memory representation and program outputs is distributed along with this lab. Complete the questions in the handout. You may physically turn in the handout on class Wednesday, or scan it / take high-quality pictures of it and submit it along with your code to Canvas.
Log into Canvas, and go to the COMP 110L class. Click “Assignments” on the left pane, then click “Lab 7”. From here, you can upload your answers and your code. Specifically, you must turn in the following two files:
Rectangle.java
RectangleMain.java
If you choose to digitally submit your handout, you must submit it in one of the following formats:
.png
.jpg
.gif
.pdf
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.