Amazon Interview Question
SDE-2sCountry: India
Interview Type: In-Person
I am thinking of using observer pattern for notifications....
main entities/classes:
ReminderMessage{public string message {get;set;} }
ReminderPopup {/* represents popup message contains OS info*/}
CalendarEntry{public DateTime time; public DateTime reminderTime; public ReminderMessage message;}
Calendar { private CalendarNotificationManager notificationManager; private SortedHashSet <CalendarEntry> entries;
public void AddEntry(CalendarEntry entry){}
public CalendarEntry [] GetEntries(DateTime calendarDate){}
}
class CalendarNotificationManager{
public void AddEntry(CalendarEntry entry){}
public void AddListener(NotificationListener listener);
protected void NotifyAll(){}
protected NotificationListener [] listeners;
}
public interface NotificationListener
{
public void Notify(ReminderMessage message){}
}
fill in the blanks and I would request the senior Devs to please comment
I am trying little bit if anybody want to add and correct it will be my pleasure.
- Anonymous September 01, 2014class EventStore {
Client client; // client handle stored when connection established with calender
list <event> myevents;
Addevent(id); // event identify by unique id
RemoveEvents(id);
Callbackfunction(id) {
occuredevent = getevent(id); // we can use hasing to get event from id
client.send( occuredevent);
}
};
class Event {
id;
Eventstore es;
AddAlarm();
RemoveAlarm();
notify() {
es.Callbackfunction(id);
}
};
class Alarm {
Event event;
startAlarm(e) {
event = e;
// start timer
}
TimerEnds() {
event.notify();
}
}
////////////////////////
client side
class Client {
EventStore ev;
EstablishConnection() {
ev = getEventStore()
ev.setclient(this)
}
AddEvent()
{
Event event = new Event;
event.details();
event.Addalarm();
ev.AddEvent(event);
}
void send(event) {
static Window w =NULL;
if( w = NULL) {
w = new Window;
}
w.display(event)
}
};