I'm learning the MVC pattern right now and I have a short question concerning models and view. I have the following model:
class Person {
private String name;
private int age;
}
Now I want my view to ask some input to create a new Person:
public void askPerson() {
System.out.println("Enter name:");
//read with System.in
System.out.println("Enter age:");
//read with System.in
}
What is now the correct way to create this model. Should I:
1) save the user input in variables in my view and get them in my controller through getters in order to create the model in the controller (getName(), getAge()) or
2) should I create the model in the view and return it as a result of askPerson()?
What is in general the best way to pass such data from the view to the controller?
Thank you!