📄 baseunit.java
字号:
package ranab.unit;
/**
* This is the base class of all the unit converters.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
abstract class BaseUnit {
/**
* Get all the possible units.
*/
public abstract String[] getAllUnits();
/**
* Convert one unit from another
*/
public abstract String convertUnit(String value, int from, int to) throws UnitException;
/**
* Get double value.
*/
public static double getDoubleValue(String input) throws UnitException {
if(input == null) {
throw new UnitException("Input cannot be null");
}
input = input.trim();
if(input.equals("")) {
throw new UnitException("Input not found");
}
try {
return Double.parseDouble(input);
}
catch(NumberFormatException ex) {
throw new UnitException(input + " : not a valid input");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -