/*
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package edu.pdx.its.portal.routelandia;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by locle on 2/27/15.
 */
public class TravelingInfo {
    protected int hour;
    protected int minutes;
    protected double speed;
    protected double travelTime;


    public TravelingInfo(int hour, int minutes, double speed, double travelTime) {
        this.hour = hour;
        this.minutes = minutes;
        this.speed = speed;
        this.travelTime = travelTime;
    }

    public TravelingInfo(JSONObject jsonObject) throws JSONException {
        //get hour, minute, speed, and travel time from each json obj
        this.hour    = Integer.parseInt(jsonObject.getString("hour"));
        this.minutes = Integer.parseInt(jsonObject.getString("minute"));
        this.speed   = 0.0;

        if (!jsonObject.isNull("speed")) {
            this.speed = Double.parseDouble(jsonObject.getString("speed"));
        }
        this.travelTime = 0.0;
        if (!jsonObject.isNull("traveltime")) {
            this.travelTime = Double.parseDouble(jsonObject.getString("traveltime"));
        }

    }

    public int getHour() {
        return hour;
    }

    public int getMinutes() {
        return minutes;
    }

    public double getSpeed() {
        return speed;
    }

    public double getTravelTime() {
        return travelTime;
    }

    public String toString(){
        return "hour: " + hour + " minute: " + minutes + " speed: " + speed + " traveltime: " + travelTime +'\n';
    }
}

@@ -833,16 +833,47 @@
 elTime;%0A
+    protected double accuracy;%0A
 %0A%0A    pu
@@ -945,16 +945,33 @@
 avelTime
+, double accuracy
 ) %7B%0A    
@@ -1082,32 +1082,66 @@
 e = travelTime;%0A
+        this.accuracy = accuracy;%0A
     %7D%0A%0A    publi
@@ -1744,24 +1744,190 @@
 );%0A        %7D
+%0A        this.accuracy = 0.0;%0A        if(!jsonObject.isNull(%22accuracy%22)) %7B%0A            this.accuracy = Double.parseDouble(jsonObject.getString(%22accuracy%22));%0A        %7D
 %0A%0A    %7D%0A%0A   
@@ -2161,32 +2161,98 @@
 velTime;%0A    %7D%0A%0A
+    public double getAccuracy() %7B%0A        return accuracy;%0A    %7D%0A%0A
     public Strin
@@ -2377,12 +2377,40 @@
 me +
-'%5Cn'
+ %22 accuracy: %22 + accuracy + %22%5Cn%22
 ;%0A  

Add accuracy to the TravelingInfo model