public FlipperInvoker(PointReceiver pointReceiver) { _pointReceiver = pointReceiver; _commands = new Dictionary <string, ICommand>(); _commands.Add("bumper", new BumperCommand(_pointReceiver)); _commands.Add("ramp", new RampCommand(_pointReceiver)); _commands.Add("target", new TargetCommand(_pointReceiver)); _commands.Add("hole", new HoleCommand(_pointReceiver)); _commands.Add("secret", new SecretRoomCommand(_pointReceiver)); }
static void Main(string[] args) { PointReceiver pointReceiver = new PointReceiver(0); FlipperInvoker flipper = new FlipperInvoker(pointReceiver); // Invoker acts as client too Console.WriteLine($"Flipper started! You start with {pointReceiver.GetPoints()} points"); while (true) { Console.Write("Object the ball hit (bumper, ramp, target, hole, secret) or quit flipper (exit/quit): "); string hitObject = Console.ReadLine(); if (hitObject.ToLower() == "quit" || hitObject.ToLower() == "exit") { break; } flipper.HitSomething(hitObject); Console.WriteLine($"Your current points are {pointReceiver.GetPoints()}"); } Console.WriteLine($"Flipper ended! You have reached {pointReceiver.GetPoints()} points!"); }