Answered step by step
Verified Expert Solution
Question
1 Approved Answer
he Factory Method pattern defines an interface or abstract class for creating objects in a superclass but allows subclasses to alter the type of objects
he Factory Method pattern defines an interface or abstract class for creating objects in a superclass but allows subclasses to alter the type of objects to be created. Use NetBeans to create a Java program that implements this design pattern. Name your project TestFactory. Create an abstract superclass named Laptop. Any subclass of an abstract class must either implement all of the abstract methods in the superclass or be declared abstract itself. Copy the code below. abstract class Laptop { public abstract int getRAM(); public abstract int getSSD(); public abstract String getCPU(); public String toString() { return "RAM=" this.getRAM() "GB, SSD=" this.getSSD() ", CPU=" this.getCPU(); } } Create a subclass named Minimum that extends your superclass. In this class, declare three (3) private variables with the following names and data types: ram (int) ssd (int) cpu (String) Copy the code below for the constructor of your Minimum class. This constructor has three (3) parameters: ram, ssd, and cpu. Parameters are separated by commas as seen below. public Minimum(int ram, int ssd, String cpu){ this.ram=ram; this.ssd=ssd; this.cpu=cpu; } Create three (3) public getter methods named after the abstract methods in your superclass. These methods should return the value of the instance
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started