package ru.oxothuk.triangle;

import ru.oxothuk.triangle.model.descriptor.TriangleDescriptor;
import ru.oxothuk.triangle.factory.DefaultShapeFactory;
import ru.oxothuk.triangle.factory.ShapeFactory;
import ru.oxothuk.triangle.model.Triangle;

import java.text.NumberFormat;
import java.text.ParseException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static ru.oxothuk.triangle.factory.TriangleSpecifications.byEdges;

public class TriangleType {
    public static void main(String[] args) {
        try {
            List<Number> edgesLength = mapArgsToNumbers(args);

            ShapeFactory shapeFactory = new DefaultShapeFactory();
            Triangle triangle = shapeFactory.createTriangle(byEdges(edgesLength));

            String triangleType = new TriangleDescriptor(triangle).type();
            System.out.println(String.format("This is %s triangle", triangleType));
        } catch (Exception e) {
            System.out.println("error while defining triangle type: " + e.getMessage());
            printHelp();
        }
    }

    private static List<Number> mapArgsToNumbers(String[] args) {
        return Stream.of(args)
            .map(arg -> {
                if (!arg.matches("[+-]?\\d+(\\.\\d*)?")) {
                    throw new IllegalArgumentException("Triangle edge length must be a number: " + arg);
                }
                try {
                    return NumberFormat.getInstance().parse(arg);
                } catch (ParseException e) {
                    throw new IllegalArgumentException("Triangle edge length must be a number: " + arg, e);
                }
            })
            .collect(Collectors.toList());
    }

    private static void printHelp() {
        System.out.println("command syntax: java " + TriangleType.class.getName() +
            " <all three triangle edges length>");
    }
}

@@ -620,76 +620,8 @@
 gs);
-%0A%0A            ShapeFactory shapeFactory = new DefaultShapeFactory();
 %0A   
@@ -653,21 +653,8 @@
 e = 
-shapeFactory.
 crea
@@ -667,16 +667,30 @@
 ngle
-(byEdges
+BySpecifiedEdgesLength
 (edg
@@ -702,12 +702,10 @@
 gth)
-)
 ;%0A
-%0A
     
@@ -716,152 +716,34 @@
     
-String triangleType = new TriangleDescriptor(triangle).type();%0A            System.out.println(String.format(%22This is %25s triangle%22, triangleType)
+writeTriangleType(triangle
 );%0A 
@@ -1525,32 +1525,482 @@
 List());%0A    %7D%0A%0A
+    private static Triangle createTriangleBySpecifiedEdgesLength(List%3CNumber%3E edgesLength) %7B%0A        ShapeFactory shapeFactory = new DefaultShapeFactory();%0A        return shapeFactory.createTriangle(byEdges(edgesLength));%0A    %7D%0A%0A    private static void writeTriangleType(Triangle triangle) %7B%0A        String triangleType = new TriangleDescriptor(triangle).type();%0A        System.out.println(String.format(%22This is %25s triangle%22, triangleType));%0A    %7D%0A%0A
     private stat

extract some methods