0
0
LLDsystem_design~10 mins

Adapter pattern in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the Adapter class implementing the Target interface.

LLD
class Adapter([1]):
    def __init__(self, adaptee):
        self.adaptee = adaptee
Drag options to blanks, or click blank then click option'
AAdaptee
BClient
CTarget
DAdapter
Attempts:
3 left
💡 Hint
Common Mistakes
Using Adaptee as the base class instead of Target.
Not implementing any interface.
Confusing Adapter with Client.
2fill in blank
medium

Complete the Adapter method to call the adaptee's specific request.

LLD
    def request(self):
        return self.adaptee.[1]()
Drag options to blanks, or click blank then click option'
Aspecific_request
Badapter_request
Ctarget_request
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Calling request() on adaptee which does not exist.
Using target_request() which is not defined.
Using adapter_request() which is not a method.
3fill in blank
hard

Fix the error in the client code to use the Adapter correctly.

LLD
adaptee = Adaptee()
adapter = [1](adaptee)
result = adapter.request()
Drag options to blanks, or click blank then click option'
AAdaptee
BAdapter
CTarget
DClient
Attempts:
3 left
💡 Hint
Common Mistakes
Instantiating Adaptee instead of Adapter for the adapter variable.
Using Target which is an interface, not a class.
Using Client as a class which is not defined.
4fill in blank
hard

Fill both blanks to complete the Adapter pattern class definitions.

LLD
class [1]:
    def specific_request(self):
        return "Adaptee behavior"

class [2]:
    def request(self):
        pass
Drag options to blanks, or click blank then click option'
AAdaptee
BAdapter
CTarget
DClient
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up Adaptee and Target class names.
Using Adapter as the base interface.
Confusing Client with interface classes.
5fill in blank
hard

Fill all three blanks to complete the Adapter's request method implementation.

LLD
class Adapter(Target):
    def __init__(self, adaptee):
        self.adaptee = adaptee

    def request(self):
        return self.adaptee.[1]() + ' adapted by ' + [2].[3]
Drag options to blanks, or click blank then click option'
Aspecific_request
Bself
C__class__.__name__
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Calling wrong method on adaptee.
Using class name directly instead of self.__class__.__name__.
Using request instead of specific_request.