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)
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images