From e472550fe154f0afa5b36d2a7e2334d4680d7884 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 20 Oct 2013 23:14:51 -0700 Subject: First stage of a major refactoring. Question and Answer can now be serialized and deserialized to/from JSON. As such, I no longer have to pass awkward maps around. As part of this change I have introduced a Provider interface to abstract out loading and persisting these beans. The scoring logic has been completed factored out of SurveyResultsResource and into the various ScoringEngines. Tests have been added for Question, Answer, and the ScoringEngines. A bug has been fixed in computing the value for slider questions. The label identifiers in the circle questions have changed from all lower case to camel case. That is, topleft is now topLeft. Several issues have been corrected in the circle answers where the point values did not match the labels. Testing and code coverage support and reports have been added. --- src/com/p4square/grow/backend/resources/Point.java | 52 ---------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/com/p4square/grow/backend/resources/Point.java (limited to 'src/com/p4square/grow/backend/resources/Point.java') diff --git a/src/com/p4square/grow/backend/resources/Point.java b/src/com/p4square/grow/backend/resources/Point.java deleted file mode 100644 index e1b15a8..0000000 --- a/src/com/p4square/grow/backend/resources/Point.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2013 Jesse Morgan - */ - -package com.p4square.grow.backend.resources; - -/** - * Simple double based point class. - * - * @author Jesse Morgan - */ -class Point { - public static Point valueOf(String str) { - final int comma = str.indexOf(','); - if (comma == -1) { - throw new IllegalArgumentException("Malformed point string"); - } - - final String sX = str.substring(0, comma); - final String sY = str.substring(comma + 1); - - return new Point(Double.valueOf(sX), Double.valueOf(sY)); - } - - private final double mX; - private final double mY; - - public Point(double x, double y) { - mX = x; - mY = y; - } - - public double distance(Point other) { - final double dx = mX - other.mX; - final double dy = mY - other.mY; - - return Math.sqrt(dx*dx + dy*dy); - } - - public double getX() { - return mX; - } - - public double getY() { - return mY; - } - - @Override - public String toString() { - return String.format("%.2f,%.2f", mX, mY); - } -} -- cgit v1.2.3