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
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here