Computer scienceFundamentalsEssentialsSoftware constructionDesign patternsStructural design patterns

Adapter pattern

Adapter class example

Report a typo

Which chunk of pseudocode represents an adapter class?

A)

class A extends Object1 is
  private field obj: Object2

  constructor of A(obj: Object2) is
    this.obj = obj

  method getObject() is
    return obj.getObject()

B)

class B is
  constructor of B ...

  method getObject() is ...

  method fits(...) is
    if(this.getObject() == Object2.getObject())
      return true;
    else
      return false;

C)

class C is
  method getInstance() is
    if (instance == null) then
      instance = new Object()
    return instance
Select one option from the list
___

Create a free account to access the full topic