Define mouse , keyboard , The rules of notebook
interface USB { void open();// Open function void close();// Turn off the function }
Mouse implementation USB rule
class Mouse implements USB { public void open() { System.out.println(" Mouse on ");
} public void close() { System.out.println(" Mouse off "); } }
 

Keyboard implementation USB rule  
class KeyBoard implements USB { public void open() {
System.out.println(" Keyboard on "); } public void close() { System.out.println(" Keyboard off ");
} }
 

  Define notebook
class NoteBook { // Notebook open operation function public void run() { System.out.println(" Notebook running ");
} // Notebook use usb equipment , When the notebook object calls this function , It must be passed a match USB Regular USB equipment public void useUSB(USB
usb) { // Judge whether there is USB equipment if (usb != null) { usb.open(); usb.close(); } } public
void shutDown() { System.out.println(" Notebook off "); } }
 
public class Test { public static void main(String[] args) { // Create notebook entity object
NoteBook nb = new NoteBook(); // Notebook on nb.run(); // Create a mouse entity object Mouse m = new
Mouse(); // Notebook using mouse nb.useUSB(m); // Create keyboard entity object KeyBoard kb = new KeyBoard(); //
Notebook using keyboard nb.useUSB(kb); // Notebook off nb.shutDown(); } }
 

Technology
©2020 ioDraw All rights reserved
Laravel HomesteadVue Novice : The front end of file preview function python-- Freshman final test questions ( With answers )C# Time every day 00 spot 00 branch 00 Second auto restart software This article takes you to explain the working principle of matrix keyboard springboot+vue+shiro Function authority Mining virus processing record Vue Export page as PDF file @ControllerAdvice Intercept abnormal return data 10000 R & D personnel ! Huawei's world's first car size lidar 150 M detection range