📄 forecast.java
字号:
package com.j2medev.chapter4;
//Forecast代表了天气预报信息
public class Forecast {
public static final int DAY = 0;
public static final int DATE = 1;
public static final int LOW = 2;
public static final int HIGH = 3;
public static final int TEXT = 4;
public static final int CODE = 5;
private Unit unit = null;
private String[] forcast = new String[6];
public Forecast() {
}
public void setUnit(Unit u){
this.unit = u;
}
public String get(int field){
if(field < 0 || field > 6)
throw new IllegalArgumentException("the att is not defined");
return forcast[field];
}
public void set(int index,String value){
forcast[index]=value;
}
public String toString(){
return "day : "+forcast[0]+"\n"
+"date : "+forcast[1]+"\n"
+"low : "+forcast[2]+unit.get(Unit.TEMPERATRUE)+"\n"
+"high : "+forcast[3]+unit.get(Unit.TEMPERATRUE)+"\n"
+"text : "+forcast[4]+"\n";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -