File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 49
49
<Compile Include =" Components\AlgorithmsCore\BaseClass.cs" />
50
50
<Compile Include =" Components\AlgorithmsCore\BaseClassTools.cs" />
51
51
<Compile Include =" Components\Algorithms\Eratosthenes.cs" />
52
+ <Compile Include =" Components\Algorithms\Algorithm.example.cs" />
52
53
<Compile Include =" Components\Algorithms\Factorial.cs" />
53
54
<Compile Include =" Components\Algorithms\Fibonacci.cs" />
54
55
<Compile Include =" Components\Algorithms\Hanoi.cs" />
Original file line number Diff line number Diff line change
1
+ using System ;
2
+
3
+ // include this
4
+ using AlgorithmsLibrary . AlgorithmsCore ;
5
+
6
+ namespace AlgorithmsLibrary . Algorithms
7
+ {
8
+
9
+ // derive from the "Algorithm" class
10
+ internal class SuperAlgorithm : Algorithm
11
+ {
12
+ // private field, you can add as many as you want
13
+ private string exclamationMark ;
14
+
15
+ // override description to be displayed in the menu
16
+ // (optional)
17
+ public override string Description { get { return "I have the description!" ; } }
18
+
19
+ // private method, you can add as many as you want
20
+ private string GetMessage ( string text )
21
+ {
22
+ return "Im the algorithm! " +
23
+ text +
24
+ exclamationMark +
25
+ " 1 + 1 = " +
26
+ // method defined in the AlgorithmsCore/BaseClassTools.cs
27
+ OnePlusOne ( ) ;
28
+ }
29
+
30
+ // ovverride Display method to handle algorithm output
31
+ // (optional, but required for functionality)
32
+ public override void Display ( )
33
+ {
34
+ exclamationMark = "!" ;
35
+
36
+ Console . Write ( GetMessage ( "Hooray" ) ) ;
37
+ }
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -31,5 +31,12 @@ protected bool IntParseTestWithOutput(string num)
31
31
return false ;
32
32
}
33
33
}
34
+
35
+ // example of the method to use across algorithms
36
+ // you can use any return type or method name
37
+ protected int OnePlusOne ( )
38
+ {
39
+ return 1 + 1 ;
40
+ }
34
41
}
35
42
}
You can’t perform that action at this time.
0 commit comments