Suppose we declare the field head in the Beetle class to be public instead of private. We could then

Suppose we
declare the field head in the Beetle class to be public instead of private. We
could then replace the line return bug.addHead(); in the takeTurn() method of
BeetleGame (line 18 of Figure 1โ€“28) with: bug.head = true; return true; What
problem is caused by this violation of encapsulation? (Hint: What happens if the
first die roll of the game is a 2?)

Don't use plagiarized sources. Get Your Custom Essay on
Suppose we declare the field head in the Beetle class to be public instead of private. We could then
Just from $13/Page
Order Essay

Leave a Reply

Your email address will not be published.

*

*

*