public static AreaResult GetArea(params float[] values) { var result = new AreaResult(); var length = values.Length; switch (length) { case 1: { var currentGetter = GetAreaGetter(AllFigures.Circle); var model = new CircleModel { Radius = values.FirstOrDefault() }; return(currentGetter.GetArea(model)); } case 3: { var currentGetter = GetAreaGetter(AllFigures.Triangle); var model = new TriangleModel { FirstLength = values[0], SecondLength = values[1], ThirdLength = values[2] }; return(currentGetter.GetArea(model)); } default: { result.Error = new AreaGetterException($"Нет реализации для value с длинной = {length}"); } break; } return(result); }
public string Operation() { var areaResult = new AreaResult(_Direction, _Coordinate); foreach (var command in _Commands) { Command.Base.Command cmd; switch (command) { case 'L': cmd = new LeftCommand(areaResult.Direction, areaResult.Coordinate); break; case 'R': cmd = new RightCommand(areaResult.Direction, areaResult.Coordinate); break; case 'M': cmd = new MoveCommand(areaResult.Direction, areaResult.Coordinate); break; default: throw new ArgumentException($"Invalid command parameter {command}"); } areaResult = cmd.Execute(); if (!_GridArea.ValidPosition(areaResult.Coordinate)) { throw new ArgumentOutOfRangeException($"Coordinate unknow {areaResult.Coordinate}"); } } return(areaResult.ToString()); }
/// <summary> /// Return Circle area /// </summary> /// <returns>Circle area</returns> public AreaResult GetArea(float radius) { var result = new AreaResult(); if (radius < 0) { result.Error = new AreaGetterException("Радиус не может быть меньше 0."); return(result); } result.SetArea((float)(Math.PI * radius * radius)); return(result); }
/// <summary> /// Returns triangle area /// </summary> /// <returns>Triangle area</returns> public AreaResult GetArea(float first, float second, float third) { var result = new AreaResult(); try { CheckTriangle(first, second, third); result.SetArea(GetCurrentArea(first, second, third)); } catch (AreaGetterException ex) { result.Error = ex; } return(result); }
/// <summary> /// Returns triangle area /// </summary> /// <returns>Triangle area</returns> public AreaResult GetArea(TriangleModel triangle) { var result = new AreaResult(); try { if (triangle == null) { throw new AreaGetterException("Не инстанциированная модель."); } CheckTriangle(triangle.FirstLength, triangle.SecondLength, triangle.ThirdLength); result.SetArea(GetCurrentArea(triangle.FirstLength, triangle.SecondLength, triangle.ThirdLength)); } catch (AreaGetterException ex) { result.Error = ex; } return(result); }
/// <summary> /// Returns triangle area /// </summary> /// <returns>Triangle area</returns> public AreaResult GetArea(IFigureModel figureModel) { var result = new AreaResult(); try { if (figureModel is TriangleModel == false) { throw new AreaGetterException("Другая модель."); } var triangle = figureModel as TriangleModel; CheckTriangle(triangle.FirstLength, triangle.SecondLength, triangle.ThirdLength); result.SetArea(GetCurrentArea(triangle.FirstLength, triangle.SecondLength, triangle.ThirdLength)); } catch (AreaGetterException ex) { result.Error = ex; } return(result); }
public static AreaResult Areas_element(double L_element, double FPI, double Do, double Di, double Pt, double Pr, double Fthickness) { AreaResult r = new AreaResult(); double N_fpm = FPI / 25.4 * 1000;//"Number of fins per meer" //Air side calculations double Aa_tube = Math.PI * Do * L_element * (1 - N_fpm * Fthickness); //"Air side heat transfer area of tubes" double Aa_fin = 2 * N_fpm * L_element * (Pt * Pr - Math.PI * Math.Pow(Do + 2 * Fthickness, 2.0) / 4); //"Air side heat transfer area of fins" r.Aa_tube = Aa_tube; r.Aa_fin = Aa_fin; r.A_a = Aa_tube + Aa_fin; //"Total air side heat transfer area" //{Refrigerant side cacluations} r.A_r = Math.PI * Di * L_element; //"Total refrigerant side heat transfer area" r.A_r_cs = Math.PI * Math.Pow(Di, 2.0) / 4; //"Refrigerant side cross sectional area" //r.A_hx = L * H; //"Front area of the heat exchanger" //r.A_face = r.A_hx - A_MCT_cs - r.A_fin_cs; //"Air side face area" r.A_ratio = r.A_a / r.A_r; //"Area ratio of air side to refrigerant" return(r); }
public AreaResult GetArea(IFigureModel figureModel) { var result = new AreaResult(); return(result); }