The task is to write the PhoneFactory. This task is pretty similar to the previous one, but you should implement not only some parts of the TestDrive class, but also PhoneDetailsFactory and PhoneFactory.
Abstract factory
Phone factory
Report a typo
Sample Input 1:
Sample Output 1:
-Hello, I need Android phone
-Okay! Please wait for a sec, - Calling to the SamsungFactory. -Bring me the Samsung Galaxy S10
Samsung Galaxy S10
Camera: 16MP+12MP+12MP
Display: 6.1" Dynamic AMOLED
Processor: Exynos 9820
Security: FingerPrint
There it is!
-Hello, I need iOS phone
-Okay! Please wait for a sec, - Calling to the iPhoneFactory. -Bring me the iPhoneXS"
This is THE iPhoneXs
Camera: 12MP
Display: 5.8" OLED
Processor: A12
Security: FaceID
There it is!Write a program in Java 17
class TestDrive {
public static void main(String[] args) throws InterruptedException {
Phone phone;
PhoneFactory iphoneFactory = /* write your code here */
PhoneFactory samsungFactory = /* write your code here */
System.out.println("-Hello, I need Android phone");
System.out.println("-Okay! Please wait for a sec, " +
"- Calling to the SamsungFactory. " +
"-Bring me the Samsung Galaxy S10");
Thread.sleep(1500);
phone = /* write your code here */
System.out.println(phone.getDescription());
System.out.println("There it is!\n");
System.out.println("-Hello, I need iOS phone");
System.out.println("-Okay! Please wait for a sec, " +
"- Calling to the iPhoneFactory. " +
"-Bring me the iPhoneXS\"");
Thread.sleep(1500);
phone = /* write your code here */
System.out.println(phone.getDescription());
System.out.println("There it is!");
}
}
interface PhoneFactory {
Phone createPhone();
}
class IphoneFactory implements PhoneFactory {
@Override
public Phone createPhone() {
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.