| 李哲 发表于 2012-5-15 19:29 ![]() 把问题说清楚。
复制代码        
        /**
         * 某个灯变红时,对应方向的灯也要变红,并且下一个方向的灯要变绿
         * @return 下一个要变绿的灯
         */        
        public Lamp blackOut(){
                this.lighted = false;
                if(opposite != null){
                        Lamp.valueOf(opposite).blackOut();
                }                
                
                Lamp nextLamp= null;
                if(next != null){
                        nextLamp = Lamp.valueOf(next);
                        System.out.println("绿灯从" + name() + "-------->切换为" + next);//这里的name()f方法是什么意思                        
                        nextLamp.light();
                }
                return nextLamp;
        }
 |