1. 实现思路
  2. 编写类及接口
  3. 编写测试类、让手机播放音频、发信息和通电话
  4. 让智能手机上网、播放视频、照相、发信息和通电话
TheakePictures接口
//照相public interface TheakePictures {void takePictures();}``

//连接网络
NetWork接口
public interface NetWork {void netWorkConn();
}
PlayWiring 接口
//播放
public interface PlayWiring {void play();
/*** 手机抽象类*/
public abstract  class Handset {private  String brand;private  String type;public abstract void sendInfo();public abstract void call();public abstract void info();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 abstract void show();
}
/*** 智能手机类*/
public class AptitudeHandset extends Handset implements NetWork,TheakePictures,PlayWiring{@Overridepublic void sendInfo() {System.out.println(this.getBrand()+this.getType()+"发信息");}@Overridepublic void call() {System.out.println(this.getBrand()+this.getType()+"打电话");}@Overridepublic void info() {System.out.println(this.getBrand()+this.getType()+"收信息");}@Overridepublic void netWorkConn() {System.out.println(this.getBrand()+this.getType()+"上网");}@Overridepublic void play() {System.out.println(this.getBrand()+this.getType()+"播放视频");}@Overridepublic void takePictures() {System.out.println(this.getBrand()+this.getType()+"照照片");}public void show(){this.netWorkConn();this.call();this.sendInfo();this.takePictures();this.play();}
}
/*** 普通手机类*/
public class CommonHandset extends Handset implements PlayWiring {@Overridepublic void sendInfo() {System.out.println(this.getBrand()+this.getType()+"手机发信息");}@Overridepublic void call() {System.out.println(this.getBrand()+this.getType()+"手机打电话");}@Overridepublic void info() {System.out.println(this.getBrand()+this.getType()+"手机收信息");}@Overridepublic void play() {System.out.println(this.getBrand()+this.getType()+"手机播放视频");}@Overridepublic void show() {this.call();this.sendInfo();this.play();}
}
import java.util.Scanner;/*** 装配手机类*/
public class Host {Scanner sc=new Scanner(System.in);int brandId,typeId;//手机品牌 手机型号public Handset select(int type){Handset handset;if(type==1){/*** 实现智能手机功能*/handset=new AptitudeHandset();System.out.println("1、小米 2、华为、 3、苹果");System.out.println("请选择手机品牌:");brandId=sc.nextInt();switch (brandId){case 1://设置手机品牌handset.setBrand("小米");// System.out.println(aptitudeHandset.getBrand());System.out.println("1、红米 2、小米note 3、小米8");System.out.println("请选择小米手机类型");typeId=sc.nextInt();//设置小米手机类型if(typeId==1){handset.setType("红米");}else if (typeId==2){handset.setType("小米note");}else {handset.setType("小米8");}break;case 2:handset.setBrand("华为");System.out.println("1、荣耀  2、nava  3、华为10");System.out.println("请选择华为手机类型");typeId=sc.nextInt();//设置小米手机类型if(typeId==1){handset.setType("荣耀 ");}else if (typeId==2){handset.setType("nava");}else {handset.setType("华为10");}break;default:handset.setBrand("苹果");System.out.println("1、iphone7  2、iphoneX  3、iphone9");System.out.println("请选择华为手机类型");typeId=sc.nextInt();//设置小米手机类型if(typeId==1){handset.setType("iphone7 ");}else if (typeId==2){handset.setType("iphoneX");}else {handset.setType("iphone9");}break;}}else{/*** 实现普通手机功能*/handset=new CommonHandset();System.out.println("1、诺基亚 2、金立手机 3、三星");System.out.println("请选择普通手机品牌");brandId=sc.nextInt();switch (brandId){case 1://设置手机品牌handset.setBrand("诺基亚");System.out.println("1、210黑色直板 2、105老人备用机 3、3.1plus移动版");System.out.println("请选择诺基亚手机类型");typeId=sc.nextInt();if (typeId==1){handset.setType("210黑色直板");}else if(typeId==2){handset.setType("105老人备用机");}else {handset.setType("3.1plus移动版");}break;case 2:handset.setBrand("金立");System.out.println("1、语音王 2、A350");System.out.println("请选择金立手机类型");typeId=sc.nextInt();if(typeId==1){handset.setType("语音王");}else {handset.setType("A350");}break;default:handset.setBrand("三星");System.out.println("1、B289电信 2、E1150老人机");System.out.println("请选择三星手机类型");typeId=sc.nextInt();if(typeId==1){handset.setType("B289电信");}else {handset.setType("E1150老人机");}break;}}return  handset;}
}
import java.util.Scanner;/*** 测试类*/
public class Test {public static void main(String[] args) {Scanner sc=new Scanner(System.in);Host host=new Host();
//        AptitudeHandset aptitudeHandset=new AptitudeHandset();
//        CommonHandset commonHandset=new CommonHandset();Handset handset;System.out.println("1、智能手机 2、普通手机");System.out.println("请选择手机类型:");int chiooce=sc.nextInt();handset=host.select(chiooce);handset.show();}
}

使用接口实现手机功能------完善相关推荐

  1. Java 使用类,接口实现手机功能-- 练习接口的使用

    |--需求说明 |--实现思路 1.根据....is......a....就是继承的逻辑,确定所有的手机都有一个手机的父类,这个父类定义为抽象类,里面定义两个抽象方法  实现打电话和发信息 2.根据. ...

  2. android外接usb摄像头demo_手机USB接口有哪些功能 手机USB接口功能介绍【详解】

    手机身上的USB接口主要的任务就是充电,连接PC传输数据,你还能想到其他的功能吗?没错,它还能连接USB小风扇.小台灯等外设.但是,你以为所有手机在实现这些功能时的体验和效果都是一样的吗? 充电速度和 ...

  3. 基于百度接口的手机无广告浏览器设计

    摘要 搜索工具在人们网络生活中扮演着重要的角色,在当今发达的信息时代,人们依靠各种各样的搜索工具来在网络上寻找所需要的资料,没有搜索工具,这些正确.有效的资源就没办法呈现在人们的眼前,因此,在搜索引擎 ...

  4. android 仿微信demo————注册功能完善添加头像功能(移动端)

    android 仿微信demo----微信启动界面实现 android 仿微信demo----注册功能实现(移动端) android 仿微信demo----注册功能实现(服务端) android 仿微 ...

  5. android采用MVP完整漫画APP、钉钉地图效果、功能完善的音乐播放器、仿QQ动态登录效果、触手app主页等源码...

    Android精选源码 一个可以上拉下滑的Ui效果,觉得好看可以学学 APP登陆页面适配 一款采用MVP的的完整漫画APP源码 android实现钉钉地图效果源码 一个使用单个文字生成壁纸图片的app ...

  6. 文件管理系统源码_基于Spring Cloud微服务构建多平台功能完善小说弹幕网站源码分享...

    致力于打造一个完整的可商用.可学习的小说门户平台,重新进行了数据库设计.代码重构和功能增强,提升了程序整体的可读性和性能,增加了很多商用特性. 是一个多平台(web.安卓app.微信小程序).功能完善 ...

  7. 那些慢慢消失的手机功能,最怀念第一个!

    随着科技的高速发展,我们的生活水平也是可见性的在提高,而智能手机也成为我们生活里不可缺少的东西,从最原始的"砖头"到现在的全面屏,手机真的经历了"女大十八变"似 ...

  8. Day215.课程详细页面功能完善、Echarts统计分析模块[生成统计数据+生成图表]前后端整合 -谷粒学院

    谷粒学院 课程详细页面功能完善 一.修改课程详细接口 1.在service_order模块添加接口 用于判断订单中status值是否为1,为1则为已支付 @RestController @CrossO ...

  9. 通过简单的类和接口实现手机套餐办理服务

    一.功能简介 1.功能 此程序实现了简单的手机套餐办理,包括注册新用户,购取手机卡,选择手机套餐,并模拟了用户充值话费以及使用手机套餐来进行消费,包括通话.短信.流量计费等功能. 2.套餐详情 3.套 ...

最新文章

  1. 032_使用ArrayDeque模拟栈结构
  2. 趣学python3(6)-条件语句
  3. boost::histogram::make_weighted_histogram用法的测试程序
  4. Consul etcd ZooKeeper euerka 对比
  5. mysql limit的使用方法
  6. Eclipse:如何附加Java源代码
  7. 还要做手机?罗永浩称还完债就重返科技行业
  8. js实现IE、谷歌浏览器打印网页内容
  9. java对mysql进行查找替换_Java对MySQL数据库进行连接、查询和修改【转载】
  10. ROS 日志消息(C++)
  11. 毕设题目:Matlab优化覆盖
  12. hyperf获取客户端真实ip
  13. php alt什么意思,img标签的alt作用是什么
  14. cubieboard mysql_【Linux】【笔记】Cubieboard开发板Debian系统+SAMBA共享+远程迅雷Xware+Nginx+PH......
  15. 解决jinja2模板中包含大括号的情况
  16. 关于Android 9 隐藏虚拟按键的问题
  17. 什么是4:4:4、4:2:2、4:2:0?了解图像压缩取样的方式
  18. 黑白棋,又叫翻转棋(Reversi)、苹果棋或奥赛罗棋(Othello)。棋盘共有8行8列共64格。开局时,棋盘正中央的4格先置放黑白相隔的4枚棋子。双方轮流落子,只要落子和棋盘上任一枚己方的棋子
  19. IT十年人生过客-八-银总和2011总结
  20. Parametric Diagrams

热门文章

  1. 迷城国度---久违了的ARPG
  2. VS2010下ocx开发:(2)在C#程序中调用ocx控件
  3. java中什么是类型_什么是Java中的“SAM类型”?
  4. linux系统局域网传输,利用ssh在linux系统之间在局域网内传输文件
  5. ceph-deploy 添加/删除 mon节点
  6. 微服务日志配置以及在生产环境怎么查看日志?
  7. 7-9 悄悄关注 (25 分)
  8. 2020年T电梯修理考试及T电梯修理考试总结
  9. 记账本典型用户和使用场景分析
  10. Linux下最好用的五大BT下载工具