April 2019
Intermediate to advanced
360 pages
9h 17m
English
The StudentDashboard class extends the Observable class and has a single class variable, the unreadMessages int. There are three methods in this class: the constructor class and the setter (mutator) and getter (accessor) methods:
public class StudentDashboard extends Observable { private int unreadMessages; // constructor public StudentDashboard() { unreadMessages = 0; } public void setUnreadMessages(int messages) { unreadMessages = messages; /* Add methods here to notify observers of a change */ } public int getUnreadMessages() { return unreadMessages; }}
The ForumMonitor class implements the Observer interface. It includes a final UNREAD_ALERT_LEVEL variable that is used as an alert threshold. In our example, ...
Read now
Unlock full access