Java Reference
In-Depth Information
Purse[Dime,Nickel]
then after the call
a.transfer(b), a
is
Purse[Quarter,Dime,Nickel,Dime,Dime,Nickel]
and
b
is empty.
Exercise P7.5. Write a method for the
Purse
class
public boolean sameContents(Purse other)
that checks whether the other purse has the same coins in the same order.
Exercise P7.6. Write a method for the
Purse
class
public boolean sameCoins(Purse other)
that checks whether the other purse has the same coins, perhaps in a
different order. For example, the purses
Purse[Quarter,Dime,Nickel,Dime]
and
Purse[Nickel,Dime,Dime,Quarter]
should be considered equal.
You will probably need one or more helper methods.
Exercise P7.7. A
Polygon
is a closed curve made up from line segments
that join the polygon's corner points. Implement a class
Polygon
with
methods
public double perimeter()
and