public void Purchase(PurchasedDevice device, int monthLimit) { if (NotUsed(device)) { return; } UsedDevice currentlyUsedDevice = GetUsedDeviceBy(device); if (currentlyUsedDevice.UsedTooShort(monthLimit)) { return; } StopUsing(currentlyUsedDevice); Purchase(device); }
private bool NotUsed(PurchasedDevice purchasedDevice) => !_currentlyUsed.Any(usedDevice => purchasedDevice.IsSameDeviceAs(usedDevice));
private bool Purchased(PurchasedDevice device) => _purchased.Any(x => x.Equals(device));
public bool DidPurchase(PurchasedDevice device) => NotUsed(device) && Purchased(device);
private void Purchase(PurchasedDevice device) { _purchased.Add(device); }
private UsedDevice GetUsedDeviceBy(PurchasedDevice device) { return(_currentlyUsed.First(usedDevice => device.IsSameDeviceAs(usedDevice))); }