Example #1
0
        public void RestoreRobotStateTest()//inapropriate naming
        {
            //Arrange
            var robot        = new CyborgRobot(null);
            var robotMemento = new RobotMemento(30);

            //Act
            robot.RestoreState(robotMemento);

            //Assert
            Assert.Equal(30, robot.BatteryCharge);
        }
Example #2
0
        public void RestoreState()
        {
            //Arrange
            var robot        = new CyborgRobot(null);
            var robotMemento = new RobotMemento(30);

            //Act
            robot.RestoreState(robotMemento);

            //Assert
            Assert.Equal(30, robot.BatteryCharge);
        }
Example #3
0
 public string RestoreState(RobotMemento robotMemento)
 {
     Id = robotMemento.Id;
     RobotImageBase64 = robotMemento.RobotImageBase64;
     Name             = robotMemento.Name;
     Description      = robotMemento.Description;
     BatteryCharge    = robotMemento.BatteryCharge;
     MaxWeight        = robotMemento.MaxWeight;
     Baggage          = robotMemento.Baggage;
     CurrentWeight    = robotMemento.CurrentWeight;
     Health           = robotMemento.Health;
     return("State succesfully restored. " + GetInfo() + "\r\n");
 }
Example #4
0
        public Robot(Position position, int battery, string[] strategies,
                     FacingControl facingControl, MovingControl movingControl,
                     ElementType[,] terrainElementTypes, Stack <CommandType> stackCommandTypes)
        {
            Position          = position;
            Battery           = (battery > 0) ? battery : 0;
            NextStrategy      = 0;
            FacingControl     = facingControl;
            MovingControl     = movingControl;
            Strategies        = strategies;
            Terrain           = terrainElementTypes;
            StackCommandTypes = stackCommandTypes;
            VisitedCells      = new List <Location> {
                Position.Location
            };
            SamplesCollected = new List <ElementType>();

            SolutionStepByStep = new List <Result>();

            _robotMemento = new RobotMemento(position, battery, strategies, facingControl, movingControl);
        }
Example #5
0
 public void RestoreState(RobotMemento memento)
 {
     this.BatteryCharge = memento.BatteryCharge;
 }