From a0e547b483e7fb46e7e36fe545fd5fbf654aa219 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 26 Mar 2024 07:42:32 +0100 Subject: [PATCH] Solve csharp/exercises/annalyns-infiltration --- .../AnnalynsInfiltration.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/csharp/annalyns-infiltration/AnnalynsInfiltration.cs b/csharp/annalyns-infiltration/AnnalynsInfiltration.cs index 86e2bcd..b186f2e 100644 --- a/csharp/annalyns-infiltration/AnnalynsInfiltration.cs +++ b/csharp/annalyns-infiltration/AnnalynsInfiltration.cs @@ -4,21 +4,30 @@ static class QuestLogic { public static bool CanFastAttack(bool knightIsAwake) { - throw new NotImplementedException("Please implement the (static) QuestLogic.CanFastAttack() method"); + return !knightIsAwake; } public static bool CanSpy(bool knightIsAwake, bool archerIsAwake, bool prisonerIsAwake) { - throw new NotImplementedException("Please implement the (static) QuestLogic.CanSpy() method"); + return knightIsAwake || archerIsAwake || prisonerIsAwake; } public static bool CanSignalPrisoner(bool archerIsAwake, bool prisonerIsAwake) { - throw new NotImplementedException("Please implement the (static) QuestLogic.CanSignalPrisoner() method"); + return !archerIsAwake && prisonerIsAwake; } public static bool CanFreePrisoner(bool knightIsAwake, bool archerIsAwake, bool prisonerIsAwake, bool petDogIsPresent) { - throw new NotImplementedException("Please implement the (static) QuestLogic.CanFreePrisoner() method"); + if (petDogIsPresent && !archerIsAwake) + { + return true; + } + if (!petDogIsPresent && !archerIsAwake && !knightIsAwake && prisonerIsAwake) + { + return true; + } + + return false; } }