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
JavaScript study ( Scope )R Language group summation , Group average , Group count antd table sort 2021 Front end high frequency interview questions ( You have to watch it !!!)Android end Firefox Testing credit card and address auto fill function Sql What is the order of execution of ?vue+element-ui Realize the input limit of price 2021 Front end interview questions and written questions ——Vuejavascript Adding and deleting form information FastAPI to write get,post Interface , adopt json Interface for parameter transfer