Advertisement
Dr_Max_Experience

update cycle

Jan 29th, 2022
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ООП
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Behaviour[] behaviours =
  10.             {
  11.                 new Mover(),
  12.                 new Jumper()
  13.             };
  14.  
  15.             while (true)
  16.             {
  17.                 foreach (var behaviour in behaviours)
  18.                 {
  19.                     behaviour.Update();
  20.                 }
  21.             }
  22.         }
  23.     }
  24.    
  25.     class Behaviour
  26.     {
  27.         public virtual void Update()
  28.         {
  29.  
  30.         }
  31.     }
  32.  
  33.     class Mover : Behaviour
  34.     {
  35.         public override void Update()
  36.         {
  37.             Console.WriteLine("Moving");
  38.         }
  39.     }
  40.  
  41.     class Jumper : Behaviour
  42.     {
  43.         public override void Update()
  44.         {
  45.             Console.WriteLine("Jumping");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement