Here is the homework question, I'm just totally unsure of where to go from here: In Python, write a class called Act that contains: an instance field of type int called num_members that denotes the number of members of the act (e.g. the number of musicians in a band), an instance field of type string called name for the act, an instance field of type string called kind for the kind of the act (band, comedian, magician, etc), an instance field of type string called stage for the stage the act will play on, a constructor that takes four arguments, one for each instance field, and sets the fields appropriately, a constructor that takes all arguments except the stage and sets stage to null or Nil (setting all other fields appropriately), getter methods for all fields, a setter method for all fields.
Once you have written this class, we need a nice way of representing it to the user. Add a method to the class Act that overrides the str method. This method should construct a string representation of the class that includes the values of all fields.
Here is what I have written thus far:
class Act:
def __init__(self, num_members, name, kind, stage = None):
self._num_members = num_members
self._name = name
self._kind = kind
self._stage = stage
def blablamethod():
def get_num_members(self):
return self._num_numbers
def get_name(self):
return self._name
def get_kind(self):
return self._kind
def get_stage(self):
return self._stage
def set_num_members(self, num_numbers):
self._num_numbers = num_numbers
def set_name(self, name):
self._name = name
def set_kind(self, kind):
self._kind = kind
def set_stage(self, stage):
self._stage = stage
num_members = property(get_num_members, set_num_members)
name = property(get_name, set_name)
kind = property(get_kind, set_kind)
stage = property(get_stage, set_stage)
def__str__(self):
string = "Number of members:" + str(self.num_members)
string += "/nName:" + self.name
string += "/nKind of act:" + self.kind
if self.stage:
string += "/nStage:" + self.stage
return string