Untitled
unknown
java
a year ago
857 B
1
Indexable
// Prototype interface representing IoT devices interface IoTDevice extends Cloneable { IoTDevice clone () ; void configure () ; } // Concrete implementation of the Prototype pattern for a Smart Light class SmartLight implements IoTDevice { @Override public IoTDevice clone () { return new SmartLight () ; } @Override public void configure () { System . out . println ( " Configuring Smart Light ... " ) ; // Additional configuration logic } } // Client class for smart home simulation public class SmartHomeSimulation { public static void main ( String [] args ) { IoTDevice smartLightPrototype = new SmartLight () ; // Create and configure smart lights dynamically IoTDevice light1 = smartLightPrototype . clone () ; light1 . configure () ; IoTDevice light2 = smartLightPrototype . clone () ; light2 . configure () ; } }
Editor is loading...
Leave a Comment