Purpose:
These exercises will help you digest the material we've discussed in the ShortCourse sessions. You want to do them quickly, but with enough thought that you would be willing to discuss them in class.
-
Tuesday - First Week Take Home Exerise:
Person classImplement a Person class that holds three properties of a person: Name, Occupation, and City of residence. Do you need to provide constructors, assignment operators, and destructor? -
Wednesday - First Week Take Home Exercise:
Person class ExtendedExtend your person class to hold an arbitrary number of named properties (hint - use one of the STL Containers). Now, define an inheritance hierarchy that has person as it's base and has derived classes: SWDev, MLBallPlayer, Financial Advisor. Define methods doWork() and doPlay() in the Person class; and each derived class defines in an appropriate way. Put these classes in a package with test stub that illustrates how the classes work. -
Thursday - First Week Take Home Exercise:
SoapySDRUsing UML diagrams as documentation, reverse-engineer the SoapySDR RTL-SDR driver. Identify those classes which are always required and those which we may implement later to accelerate streaming transfers or to exercise more features of our hardware. -
Thursday - First Week In-class Exercise:
Revise Soldier Hierarchy
Using the CompoundObjects code:- Rename C to Equipment and add a container and function to add equipment (strings).
- Rename B to AbstractSoldier and make it an abstract class with virtual function salute() and non-virtual function showEquipment().
- Rename D to Private and override salute().
- Write code in main() to exercise the modified class hierarchy.
-
Thursday - First Week In-class Exercise:
Duplicates
- Starting with your Person class with properties Name, Job, and City, write a showPerson() function.
- Create a few persons with two or more from Syracuse and two or more from Utica and one from Peoria.
- Define People as: using People = std::vector<Person>.
- Add your persons to People.
- Now, write a function that finds all of the duplicate sets of people from the same city, in linear time. Display all of the duplicate sets, but no singles.
- Hint: Picking the right STL Container(s) can get linear time performance.
-
Tuesday - Second Week In-class Exercise:
Find Files
- Write a program that accepts a path on the command line and finds and displays all the files in that directory.
- Add a command line parser that accepts a path as its first argument and one or more file patterns as subsequent arguments.
- Modify your code so that all the files that match each pattern are displayed.
-
Tuesday - Second Week In-class Exercise:
Bash Script for Tailored Man Page Searching
- Write a bash script that searches Man Page sections 2 and 3 for a string supplied on the command line (using -k option).
- Pipe all the 2 results to less preceded by the string "System Calls:"
- Pipe all the 3 results to less preceded by the string "Library Calls:"
-
Tuesday - Second Week Take-home Exercise:
Bash Script for finding system and library functions
- Write a bash script that accepts an alphabetic character on the command line and returns all of the system calls and library calls that start with that letter. Hint: use man syscalls. You also may find tail useful.
- Optionally accept any number of characters on the command line.
-
Wednesday - Second Week In-class Exercise:
Template Logger Class
- Build a template logger class that accepts a string message, prepends your name and a time-stamp, and writes the log message.
- The template parameter determines where each message is written and how it is formatted.
- Construct two classes to be used for template parameters. One writes the message to standard out, the other writes the message to a file.
- Optional extension: make two file writing parameter classes, one writes it's output in JSON format and the other in XML. Give the parameter's write method an option argument which if true writes the message as a string instead of the more structured formatting. Make that argument false by default.
- Note: you might use this class to log events or errors in a program you're working on.
-
Thursday - Second Week In-class Exercise:
Multi-Threaded Logger
- Create a logger that deposits string messages into a Threadsafe BlockingQueue (provided in Repository/Code). A child thread pulls the messages out of the queue and sends each to an output stream. The output stream could be std::cout or a std::ofstream.
- Note that multiple threads can enqueue message concurrently but, because there is only a single dequeuing thread, the output log contains messages, in the order enqueued, without intermingling the log text from individual messages.
- There is no requirement to time stamp or to use templates, although you are free to do so if you wish.
- Please demonstrate your logger by creating two child threads that each log 10 messages in a loop and display the logs by sending to std::cout. You will need to wait for 10 milliseconds or so between messages to ensure that the senders are concurrent.