我是java的新手,并且在接下来的两周内完成了以下任务。关于如何开始的任何指示将不胜感激:
编写一个Java类,其实例代表巴比伦数字。您的班级应至少提供以下方法:
String
,例如"34,45,2"
或"1,23,4,59,55"
等。)如果您的班级可以代表的数字幅度有限制,请说明这些限制是什么。
答案 0 :(得分:1)
您将在下面找到一组可能对您有所帮助的方法:
/**
* A representation of a Babylonina number.
* <p>
* TODO some examples/explanations of what Babyloninan numbers
*/
class Babylonian
{
/**
* Constructs a Babylonina number from a string.
*/
public Babylonian(String number)
{
}
/**
* Returns the value of this Babyloninan number as an {@code int}.
*
* @return the value of this Babylonian number (as an int)
*/
public int getBabylonian()
{
}
/**
* Returns the value of this Babyloninan number as a {@code String}.
*
* @return the value of this Babylonian number (as a String)
*/
public String toString()
{
}
/**
* Adds the Babylonian number {@code x} to this number.
*
* @param x the Babylonian number to add
*/
public void add(Babylonian x)
{
}
/**
* Substracts the Babylonian number {@code x} to this number.
*
* @param x the Babylonian number to substract
*/
public void subtract(Babylonian x)
{
}
}