class DistanceDemo implements Application<BigInteger, ProtocolBuilderNumeric> {

  public static <ResourcePoolT extends ResourcePool> void main(String[] args) throws IOException {
    CmdLineUtil<ResourcePoolT, ProtocolBuilderNumeric> cmdUtil = new CmdLineUtil<>();
    int x = 0;
    int y = 0;
    cmdUtil.addOption(Option.builder("x").desc("The integer x coordinate of this party. "
        + "Note only party 1 and 2 should supply this input.").hasArg().build());
    cmdUtil.addOption(Option.builder("y").desc("The integer y coordinate of this party. "
        + "Note only party 1 and 2 should supply this input").hasArg().build());
    CommandLine cmd = cmdUtil.parse(args);
    NetworkConfiguration networkConfiguration = cmdUtil.getNetworkConfiguration();

    if (networkConfiguration.getMyId() == 1 || networkConfiguration.getMyId() == 2) {
      if (!cmd.hasOption("x") || !cmd.hasOption("y")) {
        cmdUtil.displayHelp();
        throw new IllegalArgumentException("Party 1 and 2 must submit input");
      } else {
        x = Integer.parseInt(cmd.getOptionValue("x"));
        y = Integer.parseInt(cmd.getOptionValue("y"));
      }
    } else {
      if (cmd.hasOption("x") || cmd.hasOption("y")) {
        throw new IllegalArgumentException("Only party 1 and 2 should submit input");
      }
    }

    DistanceDemo distDemo = new DistanceDemo(networkConfiguration.getMyId(), x, y);
    SecureComputationEngine<ResourcePoolT, ProtocolBuilderNumeric> sce = cmdUtil.getSce();
    ResourcePoolT resourcePool = cmdUtil.getResourcePool();
    BigInteger bigInteger = sce.runApplication(distDemo, resourcePool, cmdUtil.getNetwork());
    double dist = Math.sqrt(bigInteger.doubleValue());
    log.info("Distance between party 1 and 2 is: " + dist);
    cmdUtil.closeNetwork();
    sce.shutdownSCE();

  }

  public  DistanceDemo(int id, int x, int y);

}