I am only allowed to use private members in the programming course I'm taking, and I was wondering if something like this is ok.
public class View {
private Model object_;
public View(Model object) {
object_ = object;
//blah blah blah
}
//blah blah blah
}
public class Controller {
private Model object_;
public Controller(Model object) {
object_ = object;
//blah blah blah
}
//blah blah blah
}
public class MainClass {
public static void main(String [ ] args) {
Model m = new Model();
Controller c = new Controller(m);
View v = new View(m);
//blah blah blah
}
}
The View and Controller classes both hold the same instance of the Model as private fields. Is this acceptable? It seems like it would violate the concept of private fields. I tried asking my professor, and he said it was ok, but I'm not sure if he understood my question, or if I understood his answer :)