Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Something
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { // enemy objects Robot bot = new Robot("lvl 7 Robot "); Ninja nin = new Ninja("lvl 12 Ninja"); Dragon d = new Dragon("lvl 4 Dragon"); // weapon objects Gun bob = new Gun(); Club cl = new Club(); // enemies attack bot.Attack(); nin.Attack(); d.Attack(); // attack with weapons bob.Attack(bot); cl.Attack(nin); } } interface IWeapon { void Attack ( IEnemy target ); } class Gun : IWeapon { public void Attack (IEnemy target) { Console.WriteLine( $"You shoot {target.Name} in the head!" ); } } class Club : IWeapon { public void Attack (IEnemy target) { Console.WriteLine($"You club {target.Name}!"); } } interface IEnemy { string Name { get; set; } void Attack (); } class Robot : IEnemy { public string Name { get; set; } public Robot (string name) { Name = name; } public void Attack () { Console.WriteLine($"{Name} shoots a laser at you!"); } } class Ninja : IEnemy { public string Name { get; set; } public Ninja (string name) { Name = name; } public void Attack () { Console.WriteLine($"{Name} throws a shuriken at you!"); } } class Dragon : IEnemy { public string Name { get; set; } public Dragon (string name) { Name = name; } public void Attack () { Console.WriteLine($"{Name} breathes fire at you!"); } } }
run
|
edit
|
history
|
help
0
DateTime Parser
c# yamuk çizgi
6.4 Parallelism: threads and events
*271*271#
retrylogic
单链表
Asignacion 692018
What is the best way to iterate over a Dictionary in C#?
Test
sdfrgthyjui65trfvf