For assignment, I made a simple C ++ program that uses a superclass (Student) and two subclasses ( CourseStudent and ResearchStudent ) to save a list of students and print their data, with various details shown for two different types of students (using method overrides display() from Student ).
My question is how the program collects information from the user about such things as the student’s name, identification number, device and payment information (for the student of the course) and research information (for research students):
My implementation has a request for user input and collection of this input, processed inside the classes themselves. The rationale for this was that each class knows what input data it needs, so it makes sense for me to know how to ask it (given what to ask through, and istream to collect input).
My lecturer says that the prompt and input should be processed in the main program, which seems to me more erratic, and it would be more difficult to expand the program to handle various types of students.
I take it as a compromise to create a helper class that processes the request and collects user input for each type Student , which can then be called by the main program. The advantage of this would be that there are not many of them in student classes (therefore they are cleaner), but they can also be associated with auxiliary classes if input functions are required. This also means that additional Student classes can be added without the need for major changes to the main program if auxiliary classes are provided for these new classes. Also, the auxiliary class can be replaced for an alternative language version without making any changes to the class itself.
What are the main advantages and disadvantages of three different user input options (fully encapsulated, helper class, or main program)?
source share