LINQ and lambdas - Get Control of your data - Refactoring
Head First C#: A Learner’s Guide to Real-World Programming with C# and .NET Core (Andrew Stellman(著)、Jennifer Greene(著)、O’Reilly Media)のChapter 9(LINQ and lambdas - Get Control of your data)、p.511(Sharpen your pencil)の解答を求めてみる。
コード
NectarCollector.cs
using System;
namespace BeehiveManagementSystem
{
public class NectarCollector : Bee
{
private const float NECTAR_COLLECTED_PER_SHIFT = 33.25f;
public override float CostPerShift => 1.95f;
public NectarCollector() : base("Nectar Collector") { }
protected override void DoJob()
{
HoneyValut.CollectNectar(NECTAR_COLLECTED_PER_SHIFT);
}
}
}
コード
PriceRange.cs
using System;
namespace MyFirstConsoleApp
{
public class ScaryScary:FunnyFunny, IScaryClown
{
private int scaryThingCount;
public ScaryScary(string funnyThingIHave, int scaryThingCount)
:base(funnyThingIHave)
{
this.scaryThingCount = scaryThingCount;
}
public string ScaryThingIHave => $"{scaryThingCount} spiders";
public void ScareLittleChildren() =>
Console.WriteLine($"Boo! Gotcha! Look at my {ScaryThingIHave}!");
}
}