Static & Not Final Field: Accessed by every object, Changing Non-Static & Final Field: Accessed by object itself, Non-Changing Static & Final: Accessed by every object, Non-Changing Non-Static & Not Final Field: Accessed by object itself, Changing Read the following situation and decide how the variables should be defined. You have a class named HeartsPlayer A round of Hearts starts with every player having 13 cards Players then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep) Players then strategically play cards in order to have the lowest score At the end of the round, points are cumulatively totaled for each player. If one player’s total is greater than 100, the game ends and the player with the lowest score wins. 1. How should the following data fields be defined (with respect to final and static)? (a) playerPosition (These have values of North, South, East, or West) (b) directionOfPassing (c) totalScore (This would be the total score for each individual player)

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 3GZ
icon
Related questions
Question

Static & Not Final Field: Accessed by every object, Changing

Non-Static & Final Field: Accessed by object itself, Non-Changing

Static & Final: Accessed by every object, Non-Changing

Non-Static & Not Final Field: Accessed by object itself, Changing

Read the following situation and decide how the variables should be defined.


You have a class named HeartsPlayer
A round of Hearts starts with every player having 13 cards
Players then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep)
Players then strategically play cards in order to have the lowest score
At the end of the round, points are cumulatively totaled for each player.
If one player’s total is greater than 100, the game ends and the player with the lowest score wins.


1. How should the following data fields be defined (with respect to final and static)?
(a) playerPosition (These have values of North, South, East, or West)
(b) directionOfPassing
(c) totalScore (This would be the total score for each individual player)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,