-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add algorithm & shared method examples
- Loading branch information
1 parent
160e7fd
commit f46a821
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
|
||
// include this | ||
using AlgorithmsLibrary.AlgorithmsCore; | ||
|
||
namespace AlgorithmsLibrary.Algorithms | ||
{ | ||
|
||
// derive from the "Algorithm" class | ||
internal class SuperAlgorithm : Algorithm | ||
{ | ||
// private field, you can add as many as you want | ||
private string exclamationMark; | ||
|
||
// override description to be displayed in the menu | ||
// (optional) | ||
public override string Description { get { return "I have the description!"; } } | ||
|
||
// private method, you can add as many as you want | ||
private string GetMessage(string text) | ||
{ | ||
return "Im the algorithm! " + | ||
text + | ||
exclamationMark + | ||
" 1 + 1 = " + | ||
// method defined in the AlgorithmsCore/BaseClassTools.cs | ||
OnePlusOne(); | ||
} | ||
|
||
// ovverride Display method to handle algorithm output | ||
// (optional, but required for functionality) | ||
public override void Display() | ||
{ | ||
exclamationMark = "!"; | ||
|
||
Console.Write(GetMessage("Hooray")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters