-
Notifications
You must be signed in to change notification settings - Fork 0
/
Veggie.py
62 lines (50 loc) · 1.65 KB
/
Veggie.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from FieldInhabitant import FieldInhabitant
class Veggie(FieldInhabitant):
def __init__(self, name, symbol, points):
"""
Initializes a Veggie object.
:param name: The name of the veggie.
:type name: str
:param symbol: The symbol representing the veggie on the field.
:type symbol: str
:param points: The points value associated with the veggie.
:type points: int
"""
super().__init__(symbol) # Call to the superclass's constructor with symbol
self.__name = name # Private member variable
self.__points = points # Private member variable
def get_name(self):
"""
Retrieves the name of the veggie.
:return: The name of the veggie.
:rtype: str
"""
return self.__name
def set_name(self, value):
"""
Sets the name of the veggie.
:param value: The new name value.
:type value: str
"""
self.__name = value
def get_points(self):
"""
Retrieves the points value associated with the veggie.
:return: The points value.
:rtype: int
"""
return self.__points
def set_points(self, value):
"""
Sets the points value associated with the veggie.
:param value: The new points value.
:type value: int
"""
self.__points = value
def __str__(self):
"""
Returns a string representation of the veggie.
:return: A string containing veggie information.
:rtype: str
"""
return f"Symbol: {self._symbol}, Name: {self.__name}, Points: {self.__points}"