Jan-10-2021, 02:30 AM
(This post was last modified: Jan-10-2021, 02:30 AM by javesike1262.)
Hi I have got all the getters and setters for each property of the student class assignment which I have name, id number, date of birth and grade. How can I get the tostring to display it like this:
Name ID Number Date of Birth Grade LevelI have set like this
class Student: def __init__(self, x, y, z, a): self.__x = x # name self.__y = y # ID number self.__z = z # Date of birth self.__a = a # graduation yearI also put the getters and setters too and I need help. This is what I have so far:
def toString(self): return f'{self.__class__.__name__}({self.__x}, {self.__y})' name = Student("Javier", 31036, 10/26/2002, 12) print(name.get_x()) print(name.get_y()) name.toString() print(name.toString()) print(name.get_a())Here's what it prints
Javier 31036 Student(Javier, 31036) 0.00192115577673096135How can I get it to display like that and will I need to modify the toString?