This .sln
is a homework about Guide To The Galaxy!!
See also:GuideToTheGalaxy
All of source codes already push to GitHub: https://github.com/denghejun/MerchantsGuideToTheGalaxy.git.
This is a Windows Console Application with 3 menus, you can run it step by step.
1.Input Data From File
2.Input Data From Console
3.Exit
Contains the unit test codes of Biz logic objects.
- It was a test console app by design.
- Please press
F5
to run all unit tests inVisualStudio IDE
or double clickGuideToTheGalaxy.Tests.exe
directly.
Contains all Roman Codes
and Rules. And has a RomanCaculator
, it was used to calculate a serial RomanNumbers, like below:
var calculator = new RomanCalculator();
calculator.Add(RomanNumber.I);
calculator.Add(RomanNumber.X);
var value = calculator.Value; //value will be IX = 9
Contains many micro directives
which can execute its command to solve the user input.
- Each static method of
command
as a public API to communicate with othercommand
. - The purpose of
directive
&command
was separateAction
fromData
. - The inherit of command means which
directive
will be supported by currentcommand
. - The inherit of directive means which
Command
can be executed by currentdirective
.
To define a new command
and directive
like below:
public class UnknownCommand : Command<UnknownCommandDirective>
{
public UnknownCommand(UnknownCommandDirective directive) : base(directive)
{
}
public override object Execute()
{
return this._directive.Message;
}
}
public class UnknownCommandDirective : CommandDirective<UnknownCommand>
{
public UnknownCommandDirective(string content) : base(content)
{
}
public string Message
{
get
{
return "I have no idea what you are talking about";
}
}
public override UnknownCommand Command
{
get
{
return new UnknownCommand(this);
}
}
}
And you can use directive
like below:
var result = DirectiveProxy<UnknownCommandDirective>.Create("whatever you want").Command.Execute();
one of test samples like below:
DirectiveProxy<AliasCommandDirective>.Create("glob is I").Command.Execute();
DirectiveProxy<AliasCommandDirective>.Create("prok is V").Command.Execute();
DirectiveProxy<AliasCommandDirective>.Create("pish is X").Command.Execute();
DirectiveProxy<AliasCommandDirective>.Create("tegj is L").Command.Execute();
DirectiveProxy<UnitPriceCommandDirective>.Create("glob glob Silver is 34 Credits").Command.Execute();
var response = DirectiveProxy<HowManyCommandDirective>.Create("how many Credits is glob prok Silver ?").Command.Execute();
Assert.That(response?.ToString(), Is.EqualTo("glob prok Silver is 68 Credits"));