protected override void ExecuteFigureInstanceCommand(string[] splitCommand) { switch (splitCommand[0]) { case "area": { IAreaMeasurable areaMeasurableFigure = this.currentFigure as IAreaMeasurable; if (areaMeasurableFigure != null) { Console.WriteLine("{0:0.00}", areaMeasurableFigure.GetArea()); } else { Console.WriteLine("undefined"); } break; } case "volume": { IVolumeMeasurable volumeMeasurableFigure = this.currentFigure as IVolumeMeasurable; if (volumeMeasurableFigure != null) { Console.WriteLine("{0:0.00}", volumeMeasurableFigure.GetVolume()); } else { Console.WriteLine("undefined"); } break; } case "normal": { IFlat flatFigure = this.currentFigure as IFlat; if (flatFigure != null) { Console.WriteLine(flatFigure.GetNormal().ToString()); } else { Console.WriteLine("undefined"); } break; } default: { base.ExecuteFigureInstanceCommand(splitCommand); break; } } }
protected override void ExecuteFigureInstanceCommand(string[] splitCommand) { switch (splitCommand[0]) { case "area": { IAreaMeasurable currentAsAreaMeasurable = this.currentFigure as IAreaMeasurable; if (currentAsAreaMeasurable != null) { Console.WriteLine("{0:F2}", currentAsAreaMeasurable.GetArea()); } else { Console.WriteLine("undefined"); } break; } case "volume": { IVolumeMeasurable currentAsVolumeMeasurable = this.currentFigure as IVolumeMeasurable; if (currentAsVolumeMeasurable != null) { Console.WriteLine("{0:F2}", currentAsVolumeMeasurable.GetVolume()); } else { Console.WriteLine("undefined"); } break; } case "normal": { IFlat currentAsFlat = this.currentFigure as IFlat; if (currentAsFlat != null) { Vector3D normal = currentAsFlat.GetNormal(); Console.WriteLine("{0:F2}", normal); } else { Console.WriteLine("undefined"); } break; } default: base.ExecuteFigureInstanceCommand(splitCommand); break; } }
protected virtual void ExecuteFigureInstanceCommand(string[] splitCommand) { switch (splitCommand[0]) { case "translate": { Vector3D transVector = Vector3D.Parse(splitCommand[1]); this.currentFigure.Translate(transVector); break; } case "rotate": { Vector3D center = Vector3D.Parse(splitCommand[1]); double degrees = double.Parse(splitCommand[2]); this.currentFigure.RotateInXY(center, degrees); break; } case "scale": { Vector3D center = Vector3D.Parse(splitCommand[1]); double factor = double.Parse(splitCommand[2]); this.currentFigure.Scale(center, factor); break; } case "center": { Vector3D figCenter = this.currentFigure.GetCenter(); Console.WriteLine(figCenter.ToString()); break; } case "measure": { Console.WriteLine("{0:0.00}", this.currentFigure.GetPrimaryMeasure()); break; } // area case "area": { if (this.currentFigure as IAreaMeasurable != null) { IAreaMeasurable fig = this.currentFigure as IAreaMeasurable; Console.WriteLine("{0:0.00}", fig.GetArea()); } else { Console.WriteLine("undefined"); } break; } // volume case "volume": { if (this.currentFigure as IVolumeMeasurable != null) { IVolumeMeasurable fig = this.currentFigure as IVolumeMeasurable; Console.WriteLine("{0:0.00}", fig.GetVolume()); } else { Console.WriteLine("undefined"); } break; } // normal case "normal": { if (this.currentFigure as IFlat != null) { IFlat fig = this.currentFigure as IFlat; Console.WriteLine(fig.GetNormal()); } else { Console.WriteLine("undefined"); } break; } } }