• 手机


    手机类

    package cn.phone;
    
    public class Phone {
            private String brand;
            private String type;
            public void sendInfo() {
                System.out.println("发信息的功能");
            }
            public void call() {
                System.out.println("通电话的功能");
            }
            
            public String getBrand() {
                return brand;
            }
            public void setBrand(String brand) {
                this.brand = brand;
            }
            public String getType() {
                return type;
            }
            public void setType(String type) {
                this.type = type;
            }
            public  void print() {
                System.out.println("这是一部"+this.brand+this.getType()+"手机");
            }
    }

    接口类

    package cn.phone;
    //照相接口
    public interface TheakePictures {
        public void takePictures() ;
    }
    package cn.phone;
    //l连接网络接口
    public interface Network {
        public void networkConn();
    }
    package cn.phone;
    //播放接口
    public interface PlayWiring {
        public void play();
    }

    智能手机类

    package cn.phone;
    
    public class AptitudePhone extends Phone implements TheakePictures,Network,PlayWiring{
        public void takePictures() {
            System.out.println("照相功能");
        }
        public void networkConn() {
            System.out.println("连接网络功能");
        }
        public void play() {
            System.out.println("播放功能");
        }
    //    public void print() {
    //        
    //        System.out.println();
    //    }
        
        public void toprint() {
            super.call();
            super.sendInfo();
            takePictures();
            networkConn();
            play();
        }
    }

    普通手机类

    package cn.phone;
    
    public class CommonPhone extends Phone implements PlayWiring {
        public void play() {
            System.out.println("播放功能");
        }
        public void toprint() {
            super.call();
            super.sendInfo();
            play();
            
        }
    }

    测试类

    package cn.phone;
    
    public class Test {
        public static void main(String[] args) {
            Phone phone = new Phone();
            AptitudePhone aptitudePhone = new AptitudePhone();
            aptitudePhone.setBrand("苹果");
            aptitudePhone.setType("xr");
            aptitudePhone.print();
            aptitudePhone.toprint();
            CommonPhone commonPhone = new CommonPhone();
            commonPhone.setBrand("VIVO");
            commonPhone.setType("X9");
            commonPhone.print();
            commonPhone.toprint();
        }
    }

  • 相关阅读:
    一次友情协助的渗透测试
    jQuery---微博发布案例
    jQuery---清空节点和删除节点
    jQuery---城市选择案例
    jQuery---创建和添加节点
    jQuery---动态创建节点
    jQuery---音乐导航
    jQuery---停止动画详解 stop();
    jQuery---手风琴案例+stop的使用(解决动画队列的问题)
    jQuery---自定义动画 animate();
  • 原文地址:https://www.cnblogs.com/lev1/p/11218815.html
Copyright © 2020-2023  润新知