Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace PatternTest
- {
- interface ICommand { }
- class Move : ICommand
- {
- public int dx { get; set; }
- public int dy { get; set; }
- }
- class FullScreen : ICommand { }
- class Exit : ICommand { }
- class Program
- {
- static void Main(string[] args)
- {
- int player_x = 0;
- int player_y = 0;
- ICommand myCommand = new Move { dx = -1, dy = 0 };
- switch (myCommand) {
- case Move m:
- player_x += m.dx;
- player_y += m.dy;
- break;
- case FullScreen _:
- // toggle full screen
- break;
- case Exit _:
- // quit game nicely
- break;
- }
- Console.WriteLine("Hello World!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement