OOP2

Controller.java

1
import java.util.Observable;
2
3
abstract class Controller {
4
		private View m_view;
5
		public View view() {
6
				if(m_view == null) // If null, throw exception:
7
						throw new NullPointerException("No view was given.");
8
				else
9
						return m_view;
10
		}
11
		public void setView(View view) {
12
				m_view = view;
13
		}
14
15
		private Observable m_model;
16
		public Observable model() {
17
				if(m_model == null) // If null, throw exception:
18
						throw new NullPointerException("No model was given.");
19
				else
20
						return m_model;
21
		}
22
		public void setModel(Observable model) {
23
				m_model = model;
24
		}
25
}		
26