Skip to content

Instantly share code, notes, and snippets.

@danishsatkut
Created August 22, 2016 08:22
Show Gist options
  • Save danishsatkut/20587f9f8906d35563b58a7859173298 to your computer and use it in GitHub Desktop.
Save danishsatkut/20587f9f8906d35563b58a7859173298 to your computer and use it in GitHub Desktop.
interface PoweredDevice {
public void start();
}
class ScanOperation {
public void perform() {
// Performing scan operation
}
}
class PrintOperation {
public void perform() {
// Perform print operation
}
}
class Scanner implements PoweredDevice {
private ScanOperation operation;
public void start() {
// Use operation.perform()
}
}
class Printer implements PoweredDevice {
private PrintOperation operation;
public void start() {
// Use operation.perform()
}
}
class Copier implements PoweredDevice {
private ScanOperation scanOperation;
private PrintOperation printOperation;
public void start() {
// Use each operations
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment