⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forecast.java

📁 j2me简单实例,j2me教程加源码,希望大家喜欢
💻 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 + -