-
Notifications
You must be signed in to change notification settings - Fork 0
/
Borrowable.cs
38 lines (32 loc) · 916 Bytes
/
Borrowable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using DecoratorDesignPatternExample.Core.Domain;
using System;
using System.Collections.Generic;
namespace DecoratorDesignPatternExample
{
/// <summary>
/// The 'ConcreteDecorator' class
/// </summary>
class Borrowable : LibraryItemDecorator
{
protected List<string> borrowers = new List<string>();
public Borrowable(LibraryItem libraryItem) : base(libraryItem) { }
public void BorrowItem(string name)
{
borrowers.Add(name);
libraryItem.NumCopies--;
}
public void ReturnItem(string name)
{
borrowers.Remove(name);
libraryItem.NumCopies++;
}
public override void Display()
{
base.Display();
foreach (string borrower in borrowers)
{
Console.WriteLine(" borrower: " + borrower);
}
}
}
}