Suppose we declare the field head in the Beetle class to be public instead of private. We could then replace the line return bug. Add Head();  in the take Turn () method of Beetle Game (line 18 of...


Suppose we declare the field head in the Beetle class to be public instead of private. We could then replace the line return bug. Add Head();  in the take Turn () method of Beetle Game (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?)


Figure 1–28



Dec 09, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here