Question: Implement the Computer problem using the Abstract Factory pattern. public abstract class Computer { public abstract String getRAM(); public abstract String getCPU(); @Override public String
Implement the Computer problem using the Abstract Factory pattern.
public abstract class Computer { public abstract String getRAM(); public abstract String getCPU(); @Override public String toString(){ return "RAM= "+this.getRAM()+", CPU="+this.getCPU(); } } public class PC extends Computer { private String ram; private String cpu; public PC(String ram, String cpu) { } //Override public String getRAM() { } //Override public String getCPU() { } } public class Server extends Computer { ......... }
public interface ComputerAbstractFactory {
public Computer createComputer();
} public class PCFactory implements ComputerAbstractFactory { private String ram; private String cpu; public PCFactory(String ram, String cpu) { } //Override public Computer createComputer() { ........... }
} public class ServerFactory implements ComputerAbstractFactory { ............ } public class ComputerFactory {
public static Computer getComputer(ComputerAbstractFactory factory) { ..................... } } Create a class Test to test the class Computer Factory.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
