|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
Due Sep.28 (Fri): only hardcopy is needed.
01. class Glarkzle { 02. 03. int MAX_ORDER_SIZE = 25; 04. 05. int numFloobs; 06. String name; 07. 08. Glarkzle( int _numFloobs, String _name ) { 09. |
the environment: +--------+ ____ | | +--------+(Note that the contents of the labeled-box should be empty, since you haven't initialized the variable yet.)
the environment: The object bench (the “heap”) +--------+ ____ | *---|-------\ +--------+ \ +------------------------+ \ | | \------> | | | | | | | | +------------------------+
Note that in the last two items, both situations involve walking up to some particular String object, and asking it a question. In the first case the input happens to be an int, and in the second case it happens to be another String, but otherwise the general task is the same.
Due Oct.01 (Mon): You'll turn in three things (all stapled together):
A Treasure is a relatively simple class: every treasure has four attributes: a name, a description, a weight (in lbs), and an image-URL. Some examples might be:
name: a small nugget
description: Upon close inspection, the nugget glints of gold!
weight: 0.05 lbs
image-URL: “http://americanhistory.si.edu/dynamic/images/collections_large/98-4804_225px.jpg”name: a fancy pen
description: This pen can write in purple, green, and plaid.
weight: 0.1lbs
image-URL: “”name: chocolate egg
description: The size of an ostrich egg, but made entirely of dark chocolate.
weight: 35 lbs
image-URL: “”
Note: When comparing Strings, don't use ==. Instead, use the String method “equals”. We'll talk about why == isn't appropriate for comparing Strings later, but to convince yourself, you can type the following into BlueJ's Code Pad:
"hello" == ("hel".concat("lo")) "hello".equals( "hel".concat("lo")) |
Write a Treasure method boolean isLint(), which returns true if the “treasure” is lint. It suffices to check that its name (ignoring case) equals "lint" and that its weight is exactly 0.0.
(Optional, but will count for towards participation points:)
See http://ru-itec120.pbwiki.com/grue-data-2007spring
(password: “highlander”).
Read the instructions closely,
and then edit the wiki page and add at least two treasures to that page.
If you're curious about where this assignment might be headed, you can check out last semester's assignments The “gRUe” projects shown there are similar to what we'll be writing. (It will be several weeks before we get to part II of this homework, though.)
As usual, include javadoc code for each class you write.
Write these comments before writing the actual code;
the comments will help you focus on what the method does.
PIs have been instructed to not help you on a method,
if you don't have those comments already written.
Similarly, if you are requesting help on a method, and don't
have all other already-written methods called and tested from
your test method, you must do that before receiving later help.
Due Oct.03 (Wed): implementation (Java code) for all the above methods, including toPrettyString, isLint, and isHeavierThan. Turn in hardcopy as usual. Your code should use getters, but not access any fields directly2.
1So the primitive types you need to know are boolean, double, char, int (integers up to ±2 billion (approx)), long(integers up to ±10 quintillion (approx)). The primitive types which you don't need to know are float (single-precision floating-point), short (integers up to ±32767), and byte (integers up to ±128). ↩
2except for the constructor, and the getters themselves, of course. ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Oct.09 (Tue) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |