代码实现以下文字描述的系统。
手机有打电话、听歌、照像、摄像的功能。应该如何设计?(继承类,实现多个接口)
1、电话类
1 public class Phone { 2 public void call(){ 3 System.out.println("打电话"); 4 } 5 }
2、听歌
1 public interface ListenSong { 2 public void song (); 3 }
3、摄像
1 public interface Camera { 2 public void shot(); 3 4 }
4、照相
1 public interface TakePhoto { 2 public void picture(); 3 }
5、测试类
1 public class MyPhone extends Phone implements ListenSong,TakePhoto,Camera { 2 3 @Override 4 public void shot() { 5 // TODO Auto-generated method stub 6 System.out.println("摄影"); 7 } 8 9 @Override 10 public void picture() { 11 // TODO Auto-generated method stub 12 System.out.println("照相"); 13 } 14 15 @Override 16 public void song() { 17 // TODO Auto-generated method stub 18 System.out.println("听歌"); 19 } 20 21 }