unit.java
来自「< JavaME核心技术最佳实践>>的全部源代码」· Java 代码 · 共 44 行
JAVA
44 行
/*
* Unit.java
*
* Created on 2006年5月5日, 上午11:20
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.j2medev.chapter4.weather;
/**
*
* @author ming
*/
public class Unit {
private String[] units = new String[4];
public static final int TEMPERATRUE = 0;
public static final int DISTANCE = 1;
public static final int PRESSURE = 2;
public static final int SPEED = 3;
/** Creates a new instance of Unit */
public Unit() {
}
public String get(int field){
if(field < 0 || field > 3)
throw new IllegalArgumentException("The unit field is not defined");
return units[field];
}
public void set(int index,String value){
units[index] = value;
}
//only for debug
public String toString(){
return "temperature : "+units[0]+"\n"
+"distance : "+units[1]+"\n"
+"pressure : "+units[2]+"\n"
+"speed : "+units[3]+"\n";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?