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 81728a9

Browse files
cleanup + simplifications...
1 parent 52e0ab8 commit 81728a9

File tree

13 files changed

+29
-55
lines changed

13 files changed

+29
-55
lines changed

‎Abstract Factory/Program.RealWorldCode.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Lion : Carnivore
106106
public override void Eat(Herbivore h)
107107
{
108108
// Eat Wildebeest
109-
Console.WriteLine(this.GetType().Name +
109+
Console.WriteLine(GetType().Name +
110110
" eats " + h.GetType().Name);
111111
}
112112
}
@@ -126,7 +126,7 @@ class Wolf : Carnivore
126126
public override void Eat(Herbivore h)
127127
{
128128
// Eat Bison
129-
Console.WriteLine(this.GetType().Name +
129+
Console.WriteLine(GetType().Name +
130130
" eats " + h.GetType().Name);
131131
}
132132
}

‎Abstract Factory/Program.Structural.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ProductB1 : AbstractProductB
106106
{
107107
public override void Interact(AbstractProductA a)
108108
{
109-
Console.WriteLine(this.GetType().Name +
109+
Console.WriteLine(GetType().Name +
110110
" interacts with " + a.GetType().Name);
111111
}
112112
}
@@ -125,7 +125,7 @@ class ProductB2 : AbstractProductB
125125
{
126126
public override void Interact(AbstractProductA a)
127127
{
128-
Console.WriteLine(this.GetType().Name +
128+
Console.WriteLine(GetType().Name +
129129
" interacts with " + a.GetType().Name);
130130
}
131131
}

‎Builder/Program.RealWorld.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class Vehicle
187187
// Constructor
188188
public Vehicle(string vehicleType)
189189
{
190-
this._vehicleType = vehicleType;
190+
_vehicleType = vehicleType;
191191
}
192192

193193
// Indexer

‎Command/Calculator.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62

73
namespace DoFactory.GangOfFour.Command.RealWorld
84
{

‎Command/Command/CalculatorCommand.cs‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
72
namespace DoFactory.GangOfFour.Command.RealWorld
83
{
9-
10-
114
/// <summary>
125
/// The 'ConcreteCommand' class
136
/// </summary>
@@ -18,12 +11,11 @@ class CalculatorCommand : ICommand
1811
private Calculator _calculator;
1912

2013
// Constructor
21-
public CalculatorCommand(Calculator calculator,
22-
char @operator, int operand)
14+
public CalculatorCommand(Calculator calculator, char @operator, int operand)
2315
{
24-
this._calculator = calculator;
25-
this._operator = @operator;
26-
this._operand = operand;
16+
_calculator = calculator;
17+
_operator = @operator;
18+
_operand = operand;
2719
}
2820

2921
// Gets operator

‎Command/Command/ICommand.cs‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace DoFactory.GangOfFour.Command.RealWorld
1+
namespace DoFactory.GangOfFour.Command.RealWorld
82
{
9-
103
/// <summary>
114
/// The 'Command' Interface
125
/// </summary>
@@ -15,4 +8,4 @@ interface ICommand
158
void Execute();
169
void UnExecute();
1710
}
18-
}
11+
}

‎Command/Program.RealWordCode.cs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-

2-
using System;
3-
using System.Collections.Generic;
4-
1+
using System;
52
namespace DoFactory.GangOfFour.Command.RealWorld
63
{
74
/// <summary>

‎Command/User.cs‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
63

74
namespace DoFactory.GangOfFour.Command.RealWorld
85
{
@@ -47,13 +44,12 @@ public void Undo(int levels)
4744
public void Compute(char @operator, int operand)
4845
{
4946
// Create command operation and execute it
50-
ICommand command = new CalculatorCommand(
51-
_calculator, @operator, operand);
47+
ICommand command = new CalculatorCommand(_calculator, @operator, operand);
5248
command.Execute();
5349

5450
// Add command to undo list
5551
_commands.Add(command);
5652
_current++;
5753
}
5854
}
59-
}
55+
}

‎Decorator/Book.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public class Book : LibraryItem
1717
// Constructor
1818
public Book(string author, string title, int numCopies)
1919
{
20-
this._author = author;
21-
this._title = title;
22-
this.NumCopies = numCopies;
20+
_author = author;
21+
_title = title;
22+
NumCopies = numCopies;
2323
}
2424

2525
public override void Display()

‎Decorator/Video.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public class Video : LibraryItem
1818
// Constructor
1919
public Video(string director, string title, int numCopies, int playTime)
2020
{
21-
this._director = director;
22-
this._title = title;
23-
this.NumCopies = numCopies;
24-
this._playTime = playTime;
21+
_director = director;
22+
_title = title;
23+
NumCopies = numCopies;
24+
_playTime = playTime;
2525
}
2626

2727
public override void Display()

0 commit comments

Comments
(0)

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