Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC.The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?
1) Give the goahead for further design using the current scheme
2) Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type
3) Ask for the option of WindowsPC to be removed as it will soon be obsolete
4) Change the hierarchy to remove the need for the superfluous Computer Class.

解决方案 »

  1.   

    我选2)...
    原来SCJP考这些啊,开眼界了...
      

  2.   


        应当是2,我开始没有查superfluous 的意思。   JAVA 是与平台无关的,operating System 肯定是不必要的。
      

  3.   

    2
    因为server可以是windows,也可以是linux;workstation也一样。
      

  4.   

    跟平台什么的没有关系,跟java的关系也不大。
    继承数设计不合理。