关于一道面向对象的设计问题,java基础题,希望大家帮忙解答

Abstract  class AbstractFile  {
        protected  String  name;
       public  void  printName24{System.out.println(name);}
       public  abstract  boolean  addchild(AbstractFile  file);
       public  abstract  boolean  removeChild(AbstractFile  file);
       public  abstract  List<AbstractFile>  getChildren();
   }
   Class  Folder  extends  AbstractFile  {
       private  List  <AbStractFile>  ChildList;
       public  Folder(String  name)  {
          this.name=name;
          this.ChildList  =  new  ArrayLiSt<AbStractFile>24;
       public  boolean  addChild(AbstractFile  file)  {  return  ChlldList.add
       (file);  }
       public  booleau  removeChild(AbstractFile  file)    {  return  childList.
       reloove(file);  }
       public  List<AbstractFile>  getChildren()   {  return ChlldList  ;  }
   }
   public class Client{
       public static void main(String[]args)  {
           //构造一个树形的文件/目录结构
       AbstractFile rootFolder=new Folder("c:\\");
       AbstractFile compositeFolder=new Folder("composite");
       AbstractFile windowsFolder=new Folder("windows");
       AbstractFile file=new File("TestComposite.java");
       rootFolder.addChild(compositeFolder);
       rootFolder.addChild(windowsFolder);
       compositeFolder.addChild(file);
       //打印目录文件树
       printTree(rootFolder);
   }
   private static void printTree(AbstractFile ifile)  {
   ifile.printName();
       List<AbstractFile>children=ifile.getChildren24;
       if(children==null)    return;
       for  (AbstractFile file:children)  {
         23  ;
         }
       }
   }
   该程序运行后输出结果为:
   C:\
   composite
   TestComposite.java
   Windows

请问23处应该填什么?

if(file.name.equals(windows))
System.out.println("Windows");
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网