nus-cs2103-AY2425S1 / forum

12 stars 0 forks source link

Confused about this question in the textbook regarding class-level members #863

Open RezwanAhmed123 opened 4 hours ago

RezwanAhmed123 commented 4 hours ago

image

Regarding this question, the only answer is (c), however, I am confused why (a) is also not considered. The totalScore should not be handled by the player object itself but im struggling to see why the Player CLASS itself cannot be modified to handle the total score for all the players. Unless this total score refers to the player only and not all players together?

Anvita2110 commented 3 hours ago

@RezwanAhmed123 , As per my understanding, the totalScore refers to that particular player only not for the players all together, hence it would vary from player to player. totalScore being the total score of an individual player(state of a specific object instance), it is better managed at instance level therefore, it cannot be a class level member.

@damithc Correct this if I am wrong.