10 minute LPs
30 minute design question: Design an alarm clock
My approach was as follows:
Make a C++ alarm clock class and an event super class with alarm and reminder sub classes
The C++ alarm clock class will instantiate and own a timer thread and an interface thread.
Will also have a hashmap of string, vector<event> .
The interface thread owns the standard input and waits for commands to come in, such as add, delete, toggle.
The timer thread polls at the start of every minute whether the current time is in the hashmap and then signals all of the alarms/reminders
associated with that time
My design allows minute granularity.
I had some extra logic/data structures for enabling the toggling feature.
Could someone let me know if I got to a reasonable answer or not? I don't even know if they were intending for me to use multithreading.
5 minute thought question: