Created
April 9, 2023 20:29
-
-
Save priyankahdp/4df909f2c8a0b3d5908c5dd466fb9c05 to your computer and use it in GitHub Desktop.
template-pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.designpatterns.template; | |
public class WashineMachineApplication { | |
public static void main(String[] args) { | |
WashineMachineProcess wmProcess = new WashineMachineProcessor(); | |
wmProcess.run(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.designpatterns.template; | |
//defines the algorithm's skeleton | |
public abstract class WashineMachineProcess { | |
public final void run() { | |
switchOn(); | |
openLid(); | |
insertClothes(); | |
insertWashingPowder(); | |
closeLid(); | |
pressStartButton(); | |
} | |
protected abstract void switchOn(); | |
protected abstract void openLid(); | |
protected abstract void insertClothes(); | |
protected abstract void insertWashingPowder(); | |
protected abstract void closeLid(); | |
protected abstract void pressStartButton(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.designpatterns.template; | |
public class WashineMachineProcessor extends WashineMachineProcess { | |
@Override | |
protected void switchOn() { | |
System.out.println("switchOn function"); | |
} | |
@Override | |
protected void openLid() { | |
System.out.println("openLid function"); | |
} | |
@Override | |
protected void insertClothes() { | |
System.out.println("insertClothes function"); | |
} | |
@Override | |
protected void insertWashingPowder() { | |
System.out.println("insertWashingPowder function"); | |
} | |
@Override | |
protected void closeLid() { | |
System.out.println("closeLid function"); | |
} | |
@Override | |
protected void pressStartButton() { | |
System.out.println("pressStartButton function"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment