day10-笔记本案例
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.inmind.duotai_test12;
|
||||
//笔记本类,包含运行功能、关机功能、使用USB设备功能
|
||||
public class Laplop {
|
||||
public void powerOn(){
|
||||
System.out.println("笔记本开机");
|
||||
}
|
||||
|
||||
public void powerOff(){
|
||||
System.out.println("笔记本关机");
|
||||
}
|
||||
|
||||
public void useUSB(Usb usbDevice) {
|
||||
usbDevice.open();
|
||||
//加上类型判断,是鼠标就点,是键盘就敲
|
||||
if (usbDevice instanceof Mouse) {
|
||||
Mouse mouse = (Mouse) usbDevice;
|
||||
mouse.click();
|
||||
}
|
||||
if (usbDevice instanceof KeyBoard) {
|
||||
KeyBoard keyBoard = (KeyBoard)usbDevice;
|
||||
keyBoard.knock();
|
||||
}
|
||||
|
||||
usbDevice.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user