So I'm currently doing an exercise for OOP, where I'm designing a database for a classroom of students. So basically I just have two objects "Student" and "Classroom" with specific behaviours like adding a student or removing a student, etc... For context related to my question, the "Student" class has 5 attributes to it being: - Student ID - Student social security number - Student's name - Date of birth - City of birth Note: every parameters name in the screenshot is also mentioned in this order (ID is excluded)
The main thing I want to ask here is: I'm trying to implement this new behaviour in the Student class where I can update a student's credentials (Student's ID can not be changed). I know that sometimes, we only need to update a few information like their name and birthday or sometimes all of their credentials (except the ID)
At first, I thought I can declare all of the parameters and set a default value for them so any credentials that need not be updated can be left blank (as in not inputted when calling this method). However, I then realise that it was not that simple since I have a case where I need to update the security number and birthdate, but not their name or birthplace. So calling the method as
student1.UpdateInfo("new security number", "new birthdate")
student1.UpdateInfo("new security number", "new birthdate")
would not work, since the
"new birthdate"
"new birthdate"
is understood as the input for the parameter
hoten_new
hoten_new
Another solution that I came up with this is to overload this method with all of the possible combinations, but then that would mean I need to have (2^4 - 1)
UpdateInfo
UpdateInfo
methods with different parameters.
I need some suggestions on what to do here in this case. Code is not written in english so please excuse the inconvenience