Please answer in JAVA The Abstract Factory design pattern defines a template, or interface, for the creation
Fantastic news! We've Found the answer you've been seeking!
Question:
Please answer in JAVA The Abstract Factory design pattern defines a template, or interface, for the creation of similar types of objects or implementations. Usually, Abstract Factory will encapsulate a factory method or more within for the actual creation of the product. In the example below, you'll notice the presence of two abstract classes, Mobile (Product) and MobileStore (Creator). One family of concrete product implementations are AppleASeries, AppleBSeries and AppleCSeries, to be created by the AppleStore, which is the concrete implementation of the creator. In a similar fashion another family of products, such as PixelASeries, PixelBSeries and PixelCSeries, are to be created by GoogleStore, another concrete implementation of MobileStore. Provide implementations of any classes that are required to enableMobileStoreFactory to instantiate the concrete instance of the abstract factory (MobileStore) based upon the variable specified, either "Apple" (AppleStore) or "Pixel" (GoogleStore). The factory is then responsible for creating objects of similar types based on the choice such as "ASeries" or "BSeries" or "CSeries". The mobile is then assembled based upon this by the MobileStore. You may use Main class to test your code. public interface Mobile { public default void chassis() { System.out.println("Default Chassis Included."); } public void experience(); public default void integrity() { System.out.println("Default Integrity Check."); } public default void box() { System.out.println("Default Box Packaging."); } public default void software(){ System.out.println("Default Software."); } } -------------------------- public class Main { public static void main(String... args) { MobileStore mobileStore = MobileStoreFactory.getMobileStore("Apple"); Mobile mobile = mobileStore.assemble("ASeries"); mobile.experience(); System.out.println(""); mobileStore = MobileStoreFactory.getMobileStore("Pixel"); mobile = mobileStore.assemble("BSeries"); mobile.experience(); } }
Related Book For
Intermediate Accounting
ISBN: 978-0324300987
10th Edition
Authors: Loren A Nikolai, D. Bazley and Jefferson P. Jones
Posted Date: