亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

打印出地理位置對象的字段時出錯

打印出地理位置對象的字段時出錯

翻閱古今 2021-11-24 20:12:58
import java.util.*;public class RoadTrip{    ArrayList<GeoLocation> roadTrip = new ArrayList<GeoLocation>();    double cheat = 0;    // Create a GeoLocation and add it to the road trip    public void addStop(String name, double latitude, double longitude)    {        GeoLocation loc = new GeoLocation(name + " ", latitude, longitude);        roadTrip.add(loc);    }    // Get the total number of stops in the trip    public int getNumberOfStops()    {        return roadTrip.size();    }    // Get the total miles of the trip    public double getTripLength()    {        double totalDistance = 0;        for (int i = 1; i < roadTrip.size(); i++ )        {            GeoLocation here = roadTrip.get(i);            GeoLocation prev = roadTrip.get(i-1);            totalDistance = totalDistance + here.distanceFrom(prev);        }        return totalDistance;    }    // Return a formatted toString of the trip    public String toString()    {        int i = 0;        String retVal="";        for( Object test: roadTrip)        {            retVal = retVal + ( i + 1 ) + ". " + test + "\n";            i++;        }        return retVal;    }}當我返回 retVal 時,它返回值粉末彈簧(-110.97168, -110.97168)阿貢 (-149.00134, -149.00134)澤巴(-84.74096, -84.74096)Hyampom(-53.2522, -53.2522)北費爾菲爾德(47.05816, 47.05816)什么時候應該回來粉末彈簧 (70.47312, -110.97168)阿貢 (-12.26804, -149.00134)澤巴 (-3.89922, -84.74096)Hyampom (84.57072, -53.2522)北費爾菲爾德 (73.14154, 47.05816)問題是緯度值出于某種原因等于經度值。編輯:忘記我在搞亂代碼并刪除緯度部分,把它放回去;仍然給出相同的結果
查看完整描述

1 回答

?
哈士奇WWW

TA貢獻1799條經驗 獲得超6個贊

發現錯誤。一個和我一起工作的人更改了地理定位中的一些代碼,但沒有通知我。


查看完整回答
反對 回復 2021-11-24
  • 1 回答
  • 0 關注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號