Demo på Clean Code

This commit is contained in:
2026-03-08 11:55:18 +01:00
parent fe9a1e6400
commit f966c97d32
10 changed files with 227 additions and 0 deletions

37
CleanDemo/GameRunner.cs Normal file
View File

@@ -0,0 +1,37 @@
public class GameRunner {
static void Main(string[] args) {
Player player = new Player("Hero", 100, 15);
player.AddToInventory("potion");
player.AddToInventory("sword");
Enemy goblin = new Enemy("Goblin", 40, 8, EnemyType.Normal);
Enemy dragon = new Enemy("Dragon", 120, 25, EnemyType.Boss);
var battle = new BattleService();
Console.WriteLine("=== GAME START ===");
player.Describe();
goblin.Describe();
Console.WriteLine("\n-- Round 1 --");
battle.PlayerAttacks(player, goblin);
battle.EnemyAttacks(goblin, player);
battle.PlayerAttacks(player, goblin);
Console.WriteLine("\n-- Round 2 --");
player.Describe();
player.Heal();
Console.WriteLine("\n-- Boss Fight --");
dragon.Describe();
battle.PlayerAttacks(player, dragon);
battle.EnemyAttacks(dragon, player);
battle.PlayerAttacks(player, dragon);
battle.EnemyAttacks(dragon, player);
battle.PlayerAttacks(player, dragon);
Console.WriteLine("\n=== RESULT ===");
player.Describe();
}
}