Any better design? i am planing to use command pattern in the algorithemic level

Posted by Muaralidharan under C# on 7/13/2013 | Points: 10 | Views : 1674 | Status : [Member] | Replies : 0
I have deigned the problem like,
problem explained below.I am looking for design pattern for both algorithem or is there any better solution? Since as per the below requirement it says algorithem should be interchangeable and should not implement the IHardware interface.
public interface ICleaningAlgorithm {
void Clean(IRobot robot);
public interface IReturnAlgorithm {
void Return(IRobot robot);
Example classes (without implementation):
public class CleaningAlgorithm : ICleaningAlgorithm {
public void Clean(IRobot robot) {
/* pseudocode from the post */

public class ReturnAlgorithm {
public void Return(IRobot robot) {
/* some shortest path algorithm */

Rumba Mumba Robots is a company that creates cleaning robots. We creates the software of this robots and we buy the hardware. We’ve a contract with the hardware provider that is an interface, and a Hardware Fake class for testing.

Our robots always work in rectangular rooms, without obstacles. Always start in the top left corner (coordinates x=0, y=0), pointing to the east (FaceTo = 0). Our robot has a sensor to detect if it has a wall in front of it (IsObstacle()=true).

You have this pseudocode algorithm to clean the room:

1)Rotate left.

2) If there isn’t an obstacle and the robot was never there, walk.

3)If not, rotate right.

4)If there isn’t an obstacle and the robot was never there, walk.

3)If not, rotate right.

4)If there isn’t an obstacle and the robot was never there, walk.

3)If not, the room is cleaned.

After clean the room, you need to return to the top left corner as fast as you can. Don’t care about use again cleaned cells.

At the end, you need to print the path that you use to clean the room (all the cells used, in the order that has been cleaned) and the total of movement the robot has used (printing the property TotalMovements)

1) Implement the cleaning algorithm.

2) Implement the return algorithm.

3) Both algorithm need to be easily interchangeable.

4) The software mustn’t be coupled with the hardware, and this hardware need to be easily interchangeable.

5) After clean the room, we need to know the path used and the total of movements.

1) You must use the class Hardware provided. You mustn’t implement the interface or your own hardware class.

2) AS the Hardware class is a fake class, it needs the size of the room (i.e. 4x5) in the constructor. You need to pass this information to the constructor, but you mustn’t use this information in your class.

3) Use TDD only if you’re comfortable using it. Focus on the design and the implementation.

4) Clean code and good naming are positives.

5) The robot doesn’t remind the path.

6) Don’t care about the GUI. You can use a Console Application, Test classes or whatever you need.
public interface IMyRobot


/// <summary>

/// Return true if there's an obstacle in front of the robot.

/// </summary>

/// <returns></returns>

bool IsObstacle();

/// <summary>

/// Turn 90 degrees to the right.

/// </summary>

void TurnRight();

/// <summary>

/// Turn 90 degrees to the left.

/// </summary>

void TurnLeft();


(No response found.)

Login to post response