1 Star 0 Fork 0

谢继业/Using Objects and Implementing Classes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MapLabels (2).java 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
谢继业 提交于 2020-05-08 00:49 . add MapLabels(2).java
/**
A map label has a place name, longitude and latitude
*/
public class MapLabels
{
private String placeName;
private double latitude;
private double longitude;
/**
Constructs a map label with place name, logitude and latitude given in decimal degrees
*/
public MapLabels (String name, double aLat, double aLong)
{
// your work here
placeName = name;
latitude = aLat;
longitude = aLong;
}
/**
Constructs a map label with place name, logitude and latitude given in degrees, minutes, seconds
*/
public MapLabels (String name, int degLat, int minLat, double secLat, int degLong, int minLong, double secLong)
{
// your work here
placeName = name;
// decimalDegress = Math.signum(degrees) * (Math.abs(degrees) + minutes/60. + seconds/3600.);
latitude = Math.signum(degLat) * (Math.abs(degLat) + minLat/60. + secLat/3600.);
longitude = Math.signum(degLong) * (Math.abs(degLong) + minLong/60. + secLong/3600.);
}
/**
Gets the string in XML form
@return the string
*/
public String toString()
{
//your work here
// use \" to print a "
String label = "<label name=\""
+ placeName + "\" "+"latitude=\""+latitude+"\" "+"longitude=\""+longitude+"\"/>";
return label;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xjyng/Using-Objects-and-Implementing-Classes.git
git@gitee.com:xjyng/Using-Objects-and-Implementing-Classes.git
xjyng
Using-Objects-and-Implementing-Classes
Using Objects and Implementing Classes
master

搜索帮助