day10-笔记本案例

This commit is contained in:
2026-07-27 16:55:40 +08:00
parent 2e3054287a
commit 8ecc8d41f8
5 changed files with 98 additions and 0 deletions
@@ -0,0 +1,32 @@
package com.inmind.duotai_test12;
/*
笔记本电脑
笔记本电脑(laptop)通常具备使用USB设备的功能。在生产时,笔记本都预留了可以插入USB设备的USB接口,但具体是什么USB设备,
笔记本厂商并不关心,只要符合USB规格的设备都可以。
定义USB接口,具备最基本的开启功能和关闭功能。鼠标和键盘要想能在电脑上使用,那么鼠标和键盘也必须遵守USB规范,实现USB接口,
否则鼠标和键盘的生产出来也无法使用。
案例分析
进行描述笔记本类,实现笔记本使用USB鼠标、USB键盘
USB接口,包含开启功能、关闭功能
笔记本类,包含运行功能、关机功能、使用USB设备功能
鼠标类,要实现USB接口,并具备点击的方法
键盘类,要实现USB接口,具备敲击的方法
*/
public class Test12 {
public static void main(String[] args) {
//买一个笔记本
Laplop laplop = new Laplop();
//开机
laplop.powerOn();
//买一个鼠标和键盘
Mouse mouse = new Mouse();
KeyBoard keyBoard = new KeyBoard();
//让笔记本使用键盘和鼠标
laplop.useUSB(mouse);
laplop.useUSB(keyBoard);
//关机
laplop.powerOff();
}
}