日期:2014-05-20  浏览次数:20737 次

关于类和方法的基本问题 在线等
小弟菜鸟   新学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);
                  }  
        }
}


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