Commit fe27547
Changed files (10)
product
project
project.specifications
product/project/presentation/CommandLineArgument.cs โ product/project/presentation/model/CommandLineArgument.cs
@@ -1,4 +1,4 @@
-namespace mars.rover.presentation
+namespace mars.rover.presentation.model
{
public class CommandLineArgument
{
product/project/presentation/HeadingFactory.cs โ product/project/presentation/model/HeadingFactory.cs
@@ -2,7 +2,7 @@ using System;
using mars.rover.common;
using mars.rover.domain;
-namespace mars.rover.presentation
+namespace mars.rover.presentation.model
{
public class HeadingFactory : Specification<string>
{
product/project/presentation/model/UnknownHeadingFactory.cs
@@ -0,0 +1,59 @@
+using mars.rover.domain;
+
+namespace mars.rover.presentation.model
+{
+ internal class UnknownHeadingFactory : HeadingFactory
+ {
+ public UnknownHeadingFactory() : base(null, null)
+ {
+ }
+
+ public override bool is_satisfied_by(string item)
+ {
+ return true;
+ }
+
+ public override Heading create(Plateau plateau)
+ {
+ return new UnknownHeading();
+ }
+
+ class UnknownHeading : Heading
+ {
+ public bool Equals(Heading other)
+ {
+ if (null == other) return false;
+ return other is UnknownHeading;
+ }
+
+ public Heading turn_left()
+ {
+ return this;
+ }
+
+ public Heading turn_right()
+ {
+ return this;
+ }
+
+ public void move_forward_from(Coordinate x, Coordinate y)
+ {
+ }
+
+ public override string ToString()
+ {
+ return "Unknown";
+ }
+
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as Heading);
+ }
+
+ public override int GetHashCode()
+ {
+ return ToString().GetHashCode();
+ }
+ }
+ }
+}
\ No newline at end of file
product/project/presentation/CaptureUserInstructionsConsoleView.cs
@@ -18,7 +18,7 @@ namespace mars.rover.presentation
writer.WriteLine("Enter upper right coordinates:");
presenter.provide_upper_right_coordinates(reader.ReadLine());
- for (int i = 0; i < 2; i++)
+ for (var i = 0; i < 2; i++)
{
writer.WriteLine("enter coordinates to deploy a rover to:");
presenter.deploy_rover_to(reader.ReadLine());
product/project/presentation/CaptureUserInstructionsPresenter.cs
@@ -2,6 +2,7 @@ using System;
using System.Linq;
using mars.rover.common;
using mars.rover.domain;
+using mars.rover.presentation.model;
namespace mars.rover.presentation
{
product/project/Program.cs
@@ -4,6 +4,7 @@ using System.Linq;
using mars.rover.common;
using mars.rover.domain;
using mars.rover.presentation;
+using mars.rover.presentation.model;
namespace mars.rover
{
@@ -32,12 +33,14 @@ namespace mars.rover
new HeadingFactory("E", x => new East(x)),
new HeadingFactory("W", x => new West(x)),
new HeadingFactory("S", x => new South(x)),
+ new UnknownHeadingFactory(),
},
new DefaultRegistry<Navigation>
{
new Navigation('L', x => x.turn_left()),
new Navigation('R', x => x.turn_right()),
new Navigation('M', x => x.move_forward()),
+ new UnknownNavigation(),
}
));
program.run_against(args.Select(x => (CommandLineArgument) x));
product/project/project.csproj
@@ -48,12 +48,12 @@
<Compile Include="common\DefaultRegistry.cs" />
<Compile Include="common\EnumerableExtensions.cs" />
<Compile Include="common\Registry.cs" />
- <Compile Include="presentation\HeadingFactory.cs" />
+ <Compile Include="presentation\model\HeadingFactory.cs" />
<Compile Include="common\CallbackCommand.cs" />
<Compile Include="presentation\CaptureUserInstructionsConsoleView.cs" />
<Compile Include="presentation\CaptureUserInstructionsView.cs" />
<Compile Include="common\Command.cs" />
- <Compile Include="presentation\CommandLineArgument.cs" />
+ <Compile Include="presentation\model\CommandLineArgument.cs" />
<Compile Include="presentation\infrastructure\CommandProcessor.cs" />
<Compile Include="domain\Coordinate.cs" />
<Compile Include="domain\East.cs" />
@@ -64,7 +64,7 @@
<Compile Include="common\ParameterizedCommand.cs" />
<Compile Include="domain\Mars.cs" />
<Compile Include="domain\Plateau.cs" />
- <Compile Include="presentation\Navigation.cs" />
+ <Compile Include="presentation\model\Navigation.cs" />
<Compile Include="presentation\Presenter.cs" />
<Compile Include="presentation\CaptureUserInstructionsPresenter.cs" />
<Compile Include="common\Specification.cs" />
@@ -73,6 +73,8 @@
<Compile Include="domain\Rover.cs" />
<Compile Include="domain\South.cs" />
<Compile Include="domain\West.cs" />
+ <Compile Include="presentation\model\UnknownHeadingFactory.cs" />
+ <Compile Include="presentation\model\UnknownNavigation.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
product/project.specifications/ProgramSpecs.cs
@@ -5,6 +5,7 @@ using developwithpassion.bdd.mbunit.standard.observations;
using mars.rover;
using mars.rover.common;
using mars.rover.presentation;
+using mars.rover.presentation.model;
namespace specifications
{