10000 edit composite design pattern · RezaJenabi/DesignPatternsCSharp@37271f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37271f1

Browse files
committed
edit composite design pattern
1 parent bb2c15d commit 37271f1

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

Src/Structural/Composite/Boxs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
namespace Composite
44
{
5-
public class Boxs : Component
5+
public class Boxs : Component, IComposite
66
{
77
protected List<Component> _children = new List<Component>();
88

9-
public override void Add(Component component)
9+
public void Add(Component component)
1010
{
1111
this._children.Add(component);
1212
}
1313

14-
public override void Remove(Component component)
14+
public void Remove(Component component)
1515
{
1616
this._children.Remove(component);
1717
}

Src/Structural/Composite/Component.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@ public abstract class Component
77

88
public abstract string Operation();
99

10-
public virtual void Add(Component component)
11-
{
12-
throw new NotImplementedException();
13-
}
14-
15-
public virtual void Remove(Component component)
16-
{
17-
throw new NotImplementedException();
18-
}
10+
1911

2012
public virtual bool IsComposite()
2113
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Composite
2+
{
3+
public interface IComposite
4+
{
5+
void Add(Component component);
6+
7+
void Remove(Component component);
8+
}
9+
}

0 commit comments

Comments
 (0)
0