Beispiel #1
0
        public void ExecuteCommand1(object parameter)
        {
            BodyNameToAdd.Trim();

            StringBuilder SB = new StringBuilder();

            if (BodyNameToAdd == "")
            {
                SB.Remove(0, SB.Length);
                SB.Append("Please type in a name for the body.");
                throw new ArgumentException(SB.ToString());
            }

            if (BodyNameToAdd.Length < 3)
            {
                SB.Remove(0, SB.Length);
                SB.Append(" Name must be longer than 3 characters");
                throw new ArgumentException(SB.ToString());
            }
            if (BodyWeightToAdd < 0)
            {
                SB.Remove(0, SB.Length);
                SB.Append("Body weight must be greather than 0");
                SB.Append("Please give a valid weight");
                throw new ArgumentException(SB.ToString());
            }
            if (BodyXCoord < 0)
            {
                SB.Remove(0, SB.Length);
                SB.Append("Coordinate x must be greather than 0");
                SB.Append("Please give a valid weight");
                throw new ArgumentException(SB.ToString());
            }
            if (BodyYCoord < 0)
            {
                SB.Remove(0, SB.Length);
                SB.Append("Coordinate y must be greather than 0");
                SB.Append("Please give a valid weight");
                throw new ArgumentException(SB.ToString());
            }
            if (BodyZCoord < 0)
            {
                SB.Remove(0, SB.Length);
                SB.Append("Coordinate z must be greather than 0");
                SB.Append("Please give a valid weight");
                throw new ArgumentException(SB.ToString());
            }

            Bodies.AddBody(BodyNameToAdd,
                           BodyWeightToAdd, BodyXCoord, BodyYCoord, BodyZCoord);
        }
Beispiel #2
0
 /// <inheritdoc/>
 public void ReplaceEntityBody(
     Guid entity,
     Body body)
 {
     if (body == null)
     {
         throw new ArgumentNullException(nameof(body));
     }
     if (bodies.BodyForEntity(entity) == null)
     {
         throw new NonExistingEntity(entity);
     }
     bodies.AddBody(body);
 }