• 接口实现手机


    手机的功能接口类:

    /**
     * @author Administrator
     *连接网络功能接口
     */
    public interface Network {
        public abstract void networkConn();
    }
    
    
    /**
     * @author Administrator
     *    音频播放功能接口
     */
    public interface PlayWiring {
        public abstract void play(String name);
    }
    
    
    /**
     * @author Administrator
     *    拍照功能接口
     */
    public interface ThreakePicture {
        public abstract void takePicture();
    }

    智能手机以及普通手机共有的属性以及方法构成的父类:

    public abstract class Handset {
        private String band;
        private String type;
        
        
        public String getBand() {
            return band;
        }
        public void setBand(String band) {
            this.band = band;
        }
        public String getType() {
            return type;
        }
        public void setType(String type) {
            this.type = type;
        }
        
        
        public void sendInfo() {
            System.out.println("发短信的功能");
        }
        
        public void call() {
            System.out.println("打电话的功能");
        }
        
        public abstract void info();
        
    }

    智能手机类:

    public class AptitudeHandset extends Handset implements ThreakePicture,Network,PlayWiring{
        
        public void info() {
            System.out.println("我是一台"+this.getBand()+" "+this.getType()+"手机");
        }
    
        @Override
        public void play(String name) {
            System.out.println("正在播放"+name);
            
        }
    
        @Override
        public void networkConn() {
            
            System.out.println("我有连接网络的功能");
        }
    
        @Override
        public void takePicture() {
            System.out.println("我有拍照功能");
            
        }
    
        
    }

    普通手机类:

    public class CommonHandset extends Handset implements PlayWiring {
    
        public void play(String name) {
            System.out.println("正在播放"+name);
    
        }
    
        @Override
        public void info() {
            System.out.println("我是一台"+this.getBand()+" "+this.getType()+"手机");
    
        }
    }

    测试类:

    public class Text {
        public static void main(String[] args) {
            AptitudeHandset ad = new AptitudeHandset();
            ad.setBand("苹果");
            ad.setType("6plus");
            ad.info();
            ad.call();
            ad.sendInfo();
            ad.networkConn();
            ad.takePicture();
            ad.play("最炫民族风");
            System.out.println();
            
            CommonHandset ch = new CommonHandset();
            ch.setBand("诺基亚");
            ch.setType("15");
            ch.info();
            ch.call();
            ch.sendInfo();
            ch.play("最炫民族风");
    
        }
    }

    测试运行结果:

  • 相关阅读:
    深入理解 Embedding层的本质
    tf.nn.embedding_lookup()的用法
    深度学习原理与框架-CNN在文本分类的应用 1.tf.nn.embedding_lookup(根据索引数据从数据中取出数据) 2.saver.restore(加载sess参数)
    通俗理解tf.name_scope()、tf.variable_scope()
    TENSORFLOW变量作用域(VARIABLE SCOPE)
    Tensorflow函数——tf.variable_scope()
    tf.variable_scope 参数
    何查看Tomcat版本信息
    XCode4中的文本查找和文本替换功能
    引入第三方库错误Undefined symbols for architecture i386: _OBJC_CLASS_$的解决方案
  • 原文地址:https://www.cnblogs.com/Dean-0/p/11208620.html
Copyright © 2020-2023  润新知