This assignment is to be handwritten in pen. It does not need to be submitted electronically.
Due: Week of October 2nd 2000, beginning of your tutorial or lab.
The late policy for handwritten submissions differs from the late policy for electronic submissions. See your course information sheet for more details.
In contrast to part one in Assignment 1, which asks you to fill in the missing code for the comments that are given, for part one of Assignment 2 you must fill in the missing comments for the lines of code that are given.
The program for this part contains the following three java files,
which are available on the course web site:
Shapes.java
,
Rectangle.java
, and
Cylinder.java
.
You will need to add the missing comments to the main method of the
Shapes class. Lines that require you to add comments begin with
//
but do not contain any text. Print out the
Shapes.java
file and add your comments to the printout by
hand.
To determine what to write in the comments for a given method call,
first locate the definition of the method that is being called. To
describe the method call and the arguments that are being passed to
the method, use the same wording that has been used in the comments for
the definition of the method. Use the method call for
box.init(10,20,"red")
, which has been commented for you,
as an example.
For this part, you are required to update pictures of the memory model
as taught during your lectures. You are given a Java program which is
made up of the files
Warehouse.java
,
Supplier.java
, and
Item.java
.
You are also provided with a diagram of the memory model that results
after statement 4 in the main method has completed execution. Your task is
to update the memory model (only updates to the "Method Stack" and
"Object Space" are required) at the three stages that are described
below.
Since Strings are objects, they should be stored by reference and each String should correspond to a different object. To simplify the pictures of the memory model, we will cheat a little and store Strings directly instead, just as we store primitive types, such as integers.
Update the memory model diagram above to show the state of the diagram after statement 6 of the main() method finishes executing.
Update the memory model diagram above to show the state of the diagram after statement 2 of the addStock() method finishes executing the first time that it executes. This is initiated by the call in statement 7 of the main method.
Update the memory model diagram above to show the state of the diagram after statement 2 of the getSummary() method in the Supplier class finishes executing the first time that it executes. This is initiated by the call in statement 13 of the main method.
No electronic submission is required for this assignment. Be sure to completely fill out and attach the assignment cover sheet that is available on the course web site.
For part one, hand in a printout of Shapes.java
, with your
handwritten comments added in pen. Please make sure that your comments
are legible.
For part two, hand in a printout of this handout, with the three memory model diagrams updated by hand using pen. Be sure to clearly indicate values that have changed, by crossing out the old value, and clearly labelling the new value.