Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 37271f1

Browse files
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 overridevoid Add(Component component)
9+
public void Add(Component component)
1010
{
1111
this._children.Add(component);
1212
}
1313

14-
public overridevoid 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)

AltStyle によって変換されたページ (->オリジナル) /