首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

关于类和方法的基本有关问题

2012-01-11 
关于类和方法的基本问题 在线等小弟菜鸟新学Java要求完成一个类publicclassTimeTableReader{/*OVERVIEW:Re

关于类和方法的基本问题 在线等
小弟菜鸟   新学Java
要求完成一个类

public   class   TimeTableReader   {


        /*   OVERVIEW:   Reads   a   Timetable   from   a   text   file.
    public   TimeTableReader(String   filename)   throws   FileNotFoundException,   IOException   {

/*Creates   a   timetable   reader   that   will   read   from   the   text   file   fileName.
          */

        }

        public   timetable   read()   throws   IOException,   FormatException,   InvalidTimeException,   InvalidDurationException   {
               

        }
}

其中   timetable   有另一个class   timetable定义    
小弟不明白这个需要完成的类各部分要写什么内容  
TimeTableReader(String   filename)   方法   是要做什么     怎么创建一个新的reader  
public   timetable   read()   是要做什么   read没有参数  
小弟明白怎么完成这个读文件的   过程   只是不知道   怎么放
下边是小弟写的  

public   TimeTableReader(string   filename){
BufferedReader   br   =   new   BufferedReader   (new   FileReader( "filename "));
String   line   =   br.readLine();
while   (line   !=   null){
        StringTokenizer   st   =   new   StringTokenizer   (line);
          while   (st.hasMoreTokens()){
                            int   i   =   st.countTokens();
                            String[]   arr   =   new   String[i];
                          for   (int   j   =   0;   j   <   i;j++)
                                    {
                                    arr[j]   =   st.nextToken().trim();
                            }
                  String   no   =   arr[0];          
                  String   t   =   arr[1];
                  String   rt   =   arr[2];
                  String   ad   =   arr[3];
                  FLight   job   =   new   job   (no,t,rt,ad);
                  TimeTable   readin   =   new   TimeTable();
                  readin.add(job);
                  }  
        }
}


------解决方案--------------------


TimeTableReader(String filename)是你的TimeTableReader类的构造方法啊.
这个方法只负责和要读取的文件做好连接就可以了.
读取的事交给read()方法
[解决办法]
不会,帮你顶吧

热点排行