Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implement the Cake problem the Factory Method pattern. Cake is the abstract class, all different cake classes inherit from this class. Cake class has three

implement the Cake problem the Factory Method pattern. Cake is the abstract class, all different cake classes inherit from this class. Cake class has three properties; name of the cake, type of the cake (whether cake contains butter or it is butter less) and the last one is price. The class Cake has two abstract methods:

void recipe() void comments() 

It also has another public method called aboutCake( ). The method provides the name and the price of the cakes and the comments about the cake.

Create three subclasses from the class Cake. Encapsulating Object Creation

You are going to define a factory interface and a concrete factory class (CakeFactory) that implements factory interface which will encapsulate the object creation code for different types of cakes.

public interface Factory { Cake createCake(String cakeName); } 
public class CakeFactory implements Factory { public Cake createCake(String cakeName) { ........... } 

Create a class Test to test the class CakeFactory.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago