alexbancheva

Engine_WeaponFactory

Aug 5th, 2021
1,151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace WeaponsFactory.Core
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading.Tasks;
  8.     using WeaponsFactory.Factories;
  9.  
  10.     public class Engine : IEngine
  11.     {
  12.         private WeaponFactory weaponFactory;
  13.  
  14.         public Engine()
  15.         {
  16.             this.weaponFactory = new WeaponFactory();
  17.         }
  18.  
  19.         public void Run()
  20.         {
  21.             var input = Console.ReadLine()
  22.                .Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
  23.  
  24.             var weapon = this.weaponFactory.CreateWeapon(input[0]);
  25.             var result = weapon.InflictDamage(int.Parse(input[1]));
  26.             Console.WriteLine(result);
  27.         }
  28.     }
  29. }
  30.  
RAW Paste Data