Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/14/13 11:03:13 (11 years ago)
Author:
ascheibe
Message:

#2069 fixed cloning constructors and formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Robocode/HeuristicLab.Problems.Robocode/Symbols/Void Methods/TurnGunLeft.cs

    r9565 r9630  
    33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    44
    5 namespace HeuristicLab.Problems.Robocode
    6 {
    7     [StorableClass]
    8     public class TurnGunLeft : CodeNode
    9     {
    10         public override int MinimumArity { get { return 1; } }
    11         public override int MaximumArity { get { return 1; } }
     5namespace HeuristicLab.Problems.Robocode {
     6  [StorableClass]
     7  public class TurnGunLeft : CodeNode {
     8    public override int MinimumArity { get { return 1; } }
     9    public override int MaximumArity { get { return 1; } }
    1210
    13         [Storable]
    14         public override string Prefix { get; set; }
     11    [Storable]
     12    public override string Prefix { get; set; }
    1513
    16         [Storable]
    17         public override string Suffix { get; set; }
     14    [Storable]
     15    public override string Suffix { get; set; }
    1816
    19         [StorableConstructor]
    20         private TurnGunLeft(bool deserializing) : base(deserializing) { }
    21         private TurnGunLeft(TurnGunLeft original, Cloner cloner)
    22             : base(original, cloner)
    23         {
    24             this.Prefix = "setTurnGunLeft(";
    25             this.Suffix = ");";
    26         }
     17    [StorableConstructor]
     18    private TurnGunLeft(bool deserializing) : base(deserializing) { }
     19    private TurnGunLeft(TurnGunLeft original, Cloner cloner)
     20      : base(original, cloner) {
     21    }
    2722
    28         public TurnGunLeft()
    29             : base("TurnGunLeft", "Immediately turns the robot's gun to the left by degrees.")
    30         {
    31             this.Prefix = "setTurnGunLeft(";
    32             this.Suffix = ");";
    33         }
     23    public TurnGunLeft()
     24      : base("TurnGunLeft", "Immediately turns the robot's gun to the left by degrees.") {
     25      this.Prefix = "setTurnGunLeft(";
     26      this.Suffix = ");";
     27    }
    3428
    35         public override IDeepCloneable Clone(Cloner cloner)
    36         {
    37             return new TurnGunLeft(this, cloner);
    38         }
     29    public override IDeepCloneable Clone(Cloner cloner) {
     30      return new TurnGunLeft(this, cloner);
     31    }
    3932
    40         public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children)
    41         {
    42             var enumerator = children.GetEnumerator();
     33    public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {
     34      var enumerator = children.GetEnumerator();
    4335
    44             if (!enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was not given a child.");
    45             var symbol = enumerator.Current.Symbol;
     36      if (!enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was not given a child.");
     37      var symbol = enumerator.Current.Symbol;
    4638
    47             if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
    48                 throw new System.Exception("TurnGunLeft was given a child of type " + symbol.GetType().ToString() +
    49                     ". The expected child must be of type " + typeof(Number).ToString() + " or " +
    50                     typeof(NumericalOperation).ToString() + " or " +
    51                     typeof(NumericalExpression).ToString() + ".");
     39      if (!(symbol is Number || symbol is NumericalOperation || symbol is NumericalExpression))
     40        throw new System.Exception("TurnGunLeft was given a child of type " + symbol.GetType().ToString() +
     41            ". The expected child must be of type " + typeof(Number).ToString() + " or " +
     42            typeof(NumericalOperation).ToString() + " or " +
     43            typeof(NumericalExpression).ToString() + ".");
    5244
    53             string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
    54             if (enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was given more than one child.");
     45      string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees);
     46      if (enumerator.MoveNext()) throw new System.Exception("TurnGunLeft was given more than one child.");
    5547
    56             return this.Prefix + result + this.Suffix;
    57         }
     48      return this.Prefix + result + this.Suffix;
    5849    }
     50  }
    5951}
Note: See TracChangeset for help on using the changeset viewer.