Answer:
class PlayListEntry:
def __init__(self):
self._title = ''
self._artist = ''
self._play_count = 0
@property
def get_title(self):
return self._title
@get_title.setter
def set_title(self, title):
self._title = title
@property
def get_artist(self):
return self._artist
@get_artist.setter
def set_artist(self, artist):
self._artist = artist
@property
def get_play_count(self):
return self._play_count
@get_play_count.setter
def set_play_count(self, play_count):
self._play_count = play_count
Explanation:
The above code is written in Python Programming Language. A class called PlayListEntry is defined with getter and setter methods. In this solution, the property decorator was used to define the getter methods and the setter method uses setter attribute of the getter method.
Notice that the instance variables of the class is preceded by an underscore. This is because I want the attributes of the class to be private. By making attributes of a class private, I mean that you cannot have a direct access to the attributes of the class. This concept an implementation of object oriented programming called Encapsulation.