diff --git a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/application/Application.java b/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/application/Application.java deleted file mode 100644 index 581c774f52..0000000000 --- a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/application/Application.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.templatemethodpattern.application; - -import com.baeldung.templatemethodpattern.model.Computer; -import com.baeldung.templatemethodpattern.model.HighEndComputer; -import com.baeldung.templatemethodpattern.model.StandardComputer; - -public class Application { - - public static void main(String[] args) { - Computer standardComputer = new StandardComputer(); - standardComputer.buildComputer(); - standardComputer.getComputerParts().forEach((k, v) -> System.out.println("Part : " + k + " Value : " + v)); - - Computer highEndComputer = new HighEndComputer(); - highEndComputer.buildComputer(); - highEndComputer.getComputerParts().forEach((k, v) -> System.out.println("Part : " + k + " Value : " + v)); - } -} diff --git a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/Computer.java b/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/Computer.java deleted file mode 100644 index e2561089bd..0000000000 --- a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/Computer.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.templatemethodpattern.model; - -import java.util.HashMap; -import java.util.Map; - -public abstract class Computer { - - protected Map computerParts = new HashMap<>(); - - public final void buildComputer() { - addProcessor(); - addMotherboard(); - addMemory(); - addHardDrive(); - addGraphicCard(); - addSoundCard(); - } - - public abstract void addProcessor(); - - public abstract void addMotherboard(); - - public abstract void addMemory(); - - public abstract void addHardDrive(); - - public abstract void addGraphicCard(); - - public abstract void addSoundCard(); - - public Map getComputerParts() { - return computerParts; - } -} diff --git a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/HighEndComputer.java b/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/HighEndComputer.java deleted file mode 100644 index 11baeca6f7..0000000000 --- a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/HighEndComputer.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.templatemethodpattern.model; - -public class HighEndComputer extends Computer { - - @Override - public void addProcessor() { - computerParts.put("Processor", "High End Processor"); - } - - @Override - public void addMotherboard() { - computerParts.put("Motherboard", "High End Motherboard"); - } - - @Override - public void addMemory() { - computerParts.put("Memory", "16GB"); - } - - @Override - public void addHardDrive() { - computerParts.put("Hard Drive", "2TB Hard Drive"); - } - - @Override - public void addGraphicCard() { - computerParts.put("Graphic Card", "High End Graphic Card"); - } - - @Override - public void addSoundCard() { - computerParts.put("Sound Card", "High End Sound Card"); - } -} diff --git a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/StandardComputer.java b/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/StandardComputer.java deleted file mode 100644 index 22ff370203..0000000000 --- a/core-java/templatemethodpattern/src/main/java/com/baeldung/templatemethodpattern/model/StandardComputer.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.templatemethodpattern.model; - -public class StandardComputer extends Computer { - - @Override - public void addProcessor() { - computerParts.put("Processor", "Standard Processor"); - } - - @Override - public void addMotherboard() { - computerParts.put("Motherboard", "Standard Motherboard"); - } - - @Override - public void addMemory() { - computerParts.put("Memory", "8GB"); - } - - @Override - public void addHardDrive() { - computerParts.put("Hard Drive", "1TB Hard Drive"); - } - - @Override - public void addGraphicCard() { - computerParts.put("Graphic Card", "Standard Graphic Card"); - } - - @Override - public void addSoundCard() { - computerParts.put("Sound Card", "Standard Sound Card"); - } -} diff --git a/core-java/templatemethodpattern/src/test/java/com/baeldung/templatemethodpatterntest/TemplateMethodPatternTest.java b/core-java/templatemethodpattern/src/test/java/com/baeldung/templatemethodpatterntest/TemplateMethodPatternTest.java deleted file mode 100644 index afe66883ac..0000000000 --- a/core-java/templatemethodpattern/src/test/java/com/baeldung/templatemethodpatterntest/TemplateMethodPatternTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.baeldung.templatemethodpatterntest; - -import com.baeldung.templatemethodpattern.model.HighEndComputer; -import com.baeldung.templatemethodpattern.model.StandardComputer; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class TemplateMethodPatternTest { - - private static StandardComputer standardComputer; - private static HighEndComputer highEndComputer; - - @BeforeClass - public static void setUpStandardComputerInstance() { - standardComputer = new StandardComputer(); - } - - @BeforeClass - public static void setUpHighEndComputerInstance() { - highEndComputer = new HighEndComputer(); - } - - @Test - public void givenStandardProcessor_whenAddingProcessor_thenEqualAssertion() { - standardComputer.addProcessor(); - Assert.assertEquals("Standard Processor", standardComputer - .getComputerParts().get("Processor")); - } - - @Test - public void givenStandardMotherBoard_whenAddingMotherBoard_thenEqualAssertion() { - standardComputer.addMotherboard(); - Assert.assertEquals("Standard Motherboard", standardComputer - .getComputerParts().get("Motherboard")); - } - - @Test - public void givenStandardMemory_whenAddingMemory_thenEqualAssertion() { - standardComputer.addMemory(); - Assert.assertEquals("8GB", standardComputer - .getComputerParts().get("Memory")); - } - - @Test - public void givenStandardHardDrive_whenAddingHardDrive_thenEqualAssertion() { - standardComputer.addHardDrive(); - Assert.assertEquals("1TB Hard Drive", standardComputer - .getComputerParts().get("Hard Drive")); - } - - @Test - public void givenStandardGraphicaCard_whenAddingGraphicCard_thenEqualAssertion() { - standardComputer.addGraphicCard(); - Assert.assertEquals("Standard Graphic Card", standardComputer - .getComputerParts().get("Graphic Card")); - } - - @Test - public void givenStandardSoundCard_whenAddingSoundCard_thenEqualAssertion() { - standardComputer.addSoundCard(); - Assert.assertEquals("Standard Sound Card", standardComputer - .getComputerParts().get("Sound Card")); - } - - @Test - public void givenAllStandardParts_whenBuildingComputer_thenSixParts() { - standardComputer.buildComputer(); - Assert.assertEquals(6, standardComputer - .getComputerParts().size()); - } - - @Test - public void givenHightEndProcessor_whenAddingProcessor_thenEqualAssertion() { - highEndComputer.addProcessor(); - Assert.assertEquals("High End Processor", highEndComputer - .getComputerParts().get("Processor")); - } - - @Test - public void givenHighEnddMotherBoard_whenAddingMotherBoard_thenEqualAssertion() { - highEndComputer.addMotherboard(); - Assert.assertEquals("High End Motherboard", highEndComputer - .getComputerParts().get("Motherboard")); - } - - @Test - public void givenHighEndMemory_whenAddingMemory_thenEqualAssertion() { - highEndComputer.addMemory(); - Assert.assertEquals("16GB", highEndComputer - .getComputerParts().get("Memory")); - } - - @Test - public void givenHighEndHardDrive_whenAddingHardDrive_thenEqualAssertion() { - highEndComputer.addHardDrive(); - Assert.assertEquals("2TB Hard Drive", highEndComputer - .getComputerParts().get("Hard Drive")); - } - - @Test - public void givenHighEndGraphicCard_whenAddingGraphicCard_thenEqualAssertion() { - highEndComputer.addGraphicCard(); - Assert.assertEquals("High End Graphic Card", highEndComputer - .getComputerParts().get("Graphic Card")); - } - - @Test - public void givenHighEndSoundCard_whenAddingSoundCard_thenEqualAssertion() { - highEndComputer.addSoundCard(); - Assert.assertEquals("High End Sound Card", highEndComputer - .getComputerParts().get("Sound Card")); - } - - @Test - public void givenAllHighEndParts_whenBuildingComputer_thenSixParts() { - highEndComputer.buildComputer(); - Assert.assertEquals(6, highEndComputer.getComputerParts().size()); - } -}