Task: Extend class "User" to our needs
Completion requirements
The previously introduced class "User" is to be refactored (changed) to our needs. The template is our CSV import file:
Opened: Monday, 20 March 2023, 12:00 AM
Due: Tuesday, 21 March 2023, 11:00 PM
This Code is given:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
class User: # class definition header -> class classname: def __init__(self, name, password): # constructor = special method, which is used for creating object self.__name = name # private attributes "name" and "password" are initialized self.__password = password # double underscore "__" means private def changePassword(self, password): # method changePassword sets new value to attribute "password" self.__password = password def getPassword(self): # Getter method only get back value to attribute (here from "password") return self.__password user1 = User("Miller","Miller's PWD") # creates object "user1" (constructor is invoked implicitly) user1.changePassword("Miller's new PWD"); # Method "changePassword" of object "user1" is called (dot separator) print(user1.getPassword()) # Method "getPassword" returns the value of attribute "__password" |
The previously introduced class "User" is to be refactored (changed) to our needs. The template is our CSV import file:

(only for illustration purposes)
Add the following properties (attributes) to the class User:
surnamefirstnamedateOfBirthusername(later needed as login name)
with the corresponding get methods which are returning the values of the properties. (At this point of time the property schoolClass is not needed.)
The constructor assigns 3 passed strings to surname, firstname and dateOfBirth. It also assigns same string of surname to property username. Furthermore it assembles the initial password
from the first character of firstname + first character of surname + dateOfBirth.
Create two objects user1 and user2 and call method getPassword() and print its return value as a test.
Draw the new UML class and object diagrams!