Singleton Logger, Templated Dice

Lab Assignment

The project is due in one week: by the midnight on the day of the next lab. Make sure to include your name in comments of the source files.
  1. Singleton Logger. Write code for a program that implements logging into a file using Singleton design pattern. Specifically, you need to implement a class Logger whose object has a public function report(const String&). Logger is first accessed opens a text file log.txt for appending. When report() is invoked, the argument string is appended to the file. When the program terminates, the log file stream is closed. You may implement either Classic or Meyers Singleton. See this program for an example of opening a file for appending. Make sure to disallow singleton object copying (you may use either pre-C++11 or C++11 features to implement this).

    Demonstrate the operation of your object by invoking the report() in at least two separate functions.

  2. Template Dice. Using the Templated Method Design Pattern, modify the templated games example as follows. Add a game of Dice where two players try to get the higher score by rolling five dice up to three times. A single dice roll should be a random number from 1-6. Thus, the minimum score is 5 and the maximum is 30. The first player is the computer. The computer randomly selects whether to roll again or pass and keep the score. The second player is human. The program should print the round number, the outcome of the round (for both human and computer) and ask whether the human wants to roll again or pass. The game ends either after three moves (rounds) or when both players decide to pass and keep the score. In the end, the program should print the scores and declare the winner (human or computer). Computer wins if the score is tied. Here is an example dialog:
    Round 1: Computer rolled: 1 2 3 5 6, computer's score = 17
    You rolled: 1 2 5 3 1, your score = 12
    Roll again? [y/n] y
    
    Round 2: Computer rolled: 2 3 1 5 1, computer's score = 12
    You rolled: 6 6 3 1 5, your score = 21
    Roll again? [y/n] n
    
    Round 3: Computer rolled: 5 5 5 6 3, computer's score = 24
    You rolled: passed, your score = 21
    You lose!
    

    In the template method example, you should not modify the base class template method, you should only write primitive operations for the new derived class Dice

Milestone: Implement singleton logger (the first part of the assignment).