forked from abishekaditya/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClient.cs
35 lines (30 loc) · 843 Bytes
/
Client.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
using System;
using System.Collections;
namespace IteratorPattern
{
public class Client
{
private IEnumerable _breakfast;
private IEnumerable _dinner;
public Client(BreakfastMenu breakfast, DinnerMenu dinner)
{
this._breakfast = breakfast.Items;
this._dinner = dinner.Items;
}
public void PrintMenu()
{
var breakfast = _breakfast;
PrintMenu(breakfast);
var dinner = _dinner;
PrintMenu(dinner);
}
private void PrintMenu(IEnumerable iter)
{
foreach (var item in iter)
{
var i = (Menu) item;
Console.WriteLine($"{i.Name} Rs. {i.Price} { (i.Vegetarian ? "*" : "x") } \n {i.Description} ");
}
}
}
}