Challenge: Flyweight Pattern
In this challenge, you have to implement the flyweight pattern to solve the given problem.
We'll cover the following
Problem statement
In this challenge, you have been given the Dress
class.
First, you need to define the dressPrice
function, which is used to set the price
of a dress and return it. The prices of different type
of dresses are as follows:
-
maxi
:1000
-
gown
:2000
-
skirt
:500
Every dress has a unique serialNumber
and there cannot be multiple dresses with the same serialNumber
. However, in the code given below, there is no such restriction. It allows dresses with the same serialNumber
to be created more than once:
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.