static void Main(string[] args)
        {
            PlayerStatistics p1 = new PlayerStatistics();

            p1.level          = 4;
            p1.score          = 34;
            p1.checkPointTime = DateTime.Now;
            Console.WriteLine("Initial:");
            p1.PrintStatistics();

            CareTaker ct = new CareTaker();

            ct.checkpoint = p1.CreateCheckPoint(p1);
            Console.WriteLine();

            p1.level          = 8;
            p1.score          = 96;
            p1.checkPointTime = DateTime.Now.AddHours(10);
            Console.WriteLine("Updated:");
            p1.PrintStatistics();
            Console.WriteLine();

            p1.RestoreCheckPoint(ct.checkpoint);
            Console.WriteLine("Restored:");
            p1.PrintStatistics();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("MEMENTO DESIGN PATTERN \n");

            Console.WriteLine("--------");

            Person person = new Person("Atoke", "Femi");

            Console.WriteLine("Initial full name is {0}", person.FullName);

            person.Update("Adetayo", "Oyegbile");
            Console.WriteLine("Updated full name is {0}", person.FullName);

            person.Revert();
            Console.WriteLine("Reverted full name is {0}", person.FullName);

            Console.WriteLine("--------");

            Console.WriteLine("Game Player statistics");

            // step 1 - set initial data
            PlayerStatistics _statistics = new PlayerStatistics();

            _statistics.LevelId        = 1;
            _statistics.Score          = 100;
            _statistics.CheckPointTime = DateTime.Now;
            _statistics.PrintStatistics();

            // step 2 - create and store data in memento instance
            CheckPointCareTaker _careTaker = new CheckPointCareTaker();

            _careTaker.checkPoint = _statistics.CreateCheckPoint(_statistics);
            Console.WriteLine(Environment.NewLine);

            // step 3 -  change the data
            _statistics.LevelId        = 4;
            _statistics.Score          = 320;
            _statistics.CheckPointTime = DateTime.Now.Add(new TimeSpan(0, 0, 40, 0));
            _statistics.PrintStatistics();
            Console.WriteLine(Environment.NewLine);

            // step 4 - restore the initial data
            _statistics.RestoreCheckPoint(_careTaker.checkPoint);
            _statistics.PrintStatistics();
        }
 public CheckPointMemento CreateCheckPoint(PlayerStatistics statistics)
 {
     return(new CheckPointMemento(statistics.level, statistics.score, statistics.checkPointTime));
 }