Java Reference
In-Depth Information
(Alternatively, write a graphical application that draws real bars.)
Your program should also be able to carry out the opposite conversion:
Translate bars into their ZIP code, reporting any errors in the input
format or a mismatch of the digits.
ANSWERS TO SELF-CHECK QUESTIONS
1. Look for nouns in the problem description.
2. Yes (
ChessBoard
) and no (
MovePiece
).
3. Some of its features deal with payments, others with coin values.
384
385
4. None of the coin operations require the
CashRegister
class.
5. If a class doesn't depend on another, it is not affected by interface changes
in the other class.
6. It is an accessorȌcalling
substring
doesn't modify the string on which
the method is invoked. In fact, all methods of the
String
class are
accessors.
7. NoȌ
translate
is a mutator.
8. It is a side effect; this kind of side effect is common in object-oriented
programming.
9. YesȌthe method affects the state of the
Scanner
parameter.
10. Then you don't have to worry about checking for invalid valuesȌit
becomes the caller's responsibility.
11. NoȌyou can take any action that is convenient for you.
12.
Math m = new Math(); y = m.sqrt(x)
;
13. In an object-oriented solution, the
main
method would construct objects of
classes
Game
,
Player
, and the like. Most methods would be instance
methods that depend on the state of these objects.