SlideShare a Scribd company logo
1 of 14
Adapter Pattern
(A Structural Pattern)
Adapter
Motivation
 Sometimes a toolkit class that's designed for reuse isn't reusable only because its interface doesn't match
   the domain-specific interface an application requires.

 Consider for example a drawing editor that lets users draw and arrange graphical elements (lines,
   polygons, text, etc.) into pictures and diagrams. The drawing editor's key abstraction is the graphical
   object, which has an editable shape and can draw itself. The interface for graphical objects is defined by an
   abstract class called Shape. The editor defines a subclass of Shape for each kind of graphical object: a
   LineShape class for lines, a PolygonShape class for polygons, and so forth.

 Classes for elementary geometric shapes like LineShape and PolygonShape are rather easy to implement,
   because their drawing and editing capabilities are inherently limited. But a TextShape subclass that can
   display and edit text is considerably more difficult to implement, since even basic text editing involves
   complicated screen update and buffer management. Meanwhile, an off-the-shelf user interface toolkit
   might already provide a sophisticated TextView class for displaying and editing text. Ideally we'd like to
   reuse TextView to implement TextShape, but the toolkit wasn't designed with Shape classes in mind. So
   we can't use TextView and Shape objects interchangeably.

 we could define TextShape so that it adapts the TextView interface to Shape's. We can do this in one of
   two ways: (1) by inheriting Shape's interface and TextView's implementation or (2) by composing a
   TextView instance within a TextShape and implementing TextShape in terms of TextView's interface.
   These two approaches correspond to the class and object versions of the Adapter pattern. We call
   TextShape an adapter.
Motivation
Applicability
Use the Adapter pattern when

   you want to use an existing class, and its interface does not
    match the one you need.

   you want to create a reusable class that cooperates with
    unrelated or unforeseen classes, that is, classes that don't
    necessarily have compatible interfaces.

   (object adapter only) you need to use several existing subclasses,
    but it's impractical to adapt their interface by subclassing every
    one. An object adapter can adapt the interface of its parent class.
Structure
Two Types of Adapter
  Class Adapter
  Object Adapter
Structure: Class Adapter
Structure: Object Adapter
Participants
Target (Shape)
  defines the domain-specific interface that Client uses.
Client (DrawingEditor)
  collaborates with objects conforming to the Target
   interface.
Adaptee (TextView)
  defines an existing interface that needs adapting.
Adapter (TextShape)
  adapts the interface of Adaptee to the Target interface.
Collaborations
Clients call operations on an Adapter
 instance. In turn, the adapter calls Adaptee
 operations that carry out the request.
Consequences
 Class and object adapters have different trade-offs. A class adapter
    adapts Adaptee to Target by committing to a concrete Adapter class. As a
     consequence, a class adapter won't work when we want to adapt a class
     and all its subclasses.
    lets Adapter override some of Adaptee's behavior, since Adapter is a
     subclass of Adaptee.
    introduces only one object, and no additional pointer indirection is
     needed to get to the adaptee.

 An object adapter
    lets a single Adapter work with many Adaptees—that is, the Adaptee itself
     and all of its subclasses (if any). The Adapter can also add functionality to
     all Adaptees at once.
    makes it harder to override Adaptee behavior. It will require subclassing
     Adaptee and making Adapter refer to the subclass rather than the Adaptee
     itself.
Consequences
 How much adapting does Adapter do? Adapters vary in the amount of work they do to
   adapt Adaptee to the Target interface. There is a spectrum of possible work, from simple
   interface conversion—for example, changing the names of operations—to supporting an
   entirely different set of operations.

 Pluggable adapters. A class is more reusable when you minimize the assumptions other
   classes must make to use it. By building interface adaptation into a class, you eliminate
   the assumption that other classes see the same interface.

 Using two-way adapters to provide transparency. A potential problem with adapters is
   that they aren't transparent to all clients. An adapted object no longer conforms to the
   Adaptee interface, so it can't be used as is wherever an Adaptee object can. Two-way
   adapters can provide such transparency. Specifically, they're useful when two different
   clients need to view an object differently.
Implementation
Implementing class adapters in C++. In a C++
 implementation of a class adapter, Adapter would inherit
 publicly from Target and privately from Adaptee. Thus
 Adapter would be a subtype of Target but not of Adaptee.

Pluggable adapters.
   Using abstract operations.
   Using delegate objects.
   Parameterized adapters.
Assignment
 Your application domain needs a generic Stack<T> class. And your
  development platform is C#.NET

 Let’s assume .NET Framework doesn’t have a generic stack
  implementation (actually, there is; but just assume there isn’t :D).
  Also assume there is a generic queue implementation in C# (actually,
  you don’t have to assume this time; there is in fact one such class
  under System.Collections.Generic :D).

 Write an adapter for this generic queue class to be useable as a
  generic stack class. You must show both versions – class adapter and
  object adapter. And your stack class should contain all the standard
  stack operations.

More Related Content

What's hot

What's hot (20)

The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Proxy Design Pattern
Proxy Design PatternProxy Design Pattern
Proxy Design Pattern
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
Adapter Pattern
Adapter PatternAdapter Pattern
Adapter Pattern
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Observer Software Design Pattern
Observer Software Design Pattern Observer Software Design Pattern
Observer Software Design Pattern
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 

Viewers also liked

Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
Manoj Kumar
 
Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603
melbournepatterns
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
Guo Albert
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorial
Piyush Mittal
 

Viewers also liked (20)

Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603Adapter Pattern Abhijit Hiremagalur 200603
Adapter Pattern Abhijit Hiremagalur 200603
 
Design patterns - Adapter Pattern
Design patterns - Adapter PatternDesign patterns - Adapter Pattern
Design patterns - Adapter Pattern
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
 
Strategy Design Pattern
Strategy Design PatternStrategy Design Pattern
Strategy Design Pattern
 
Design Patterns - Part 1 of 2
Design Patterns - Part 1 of 2Design Patterns - Part 1 of 2
Design Patterns - Part 1 of 2
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
 
Cost of quality
Cost of qualityCost of quality
Cost of quality
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorial
 
Cost of Quality
Cost of  QualityCost of  Quality
Cost of Quality
 
Cost of Quality
Cost of QualityCost of Quality
Cost of Quality
 
Cost Of Quality
Cost Of QualityCost Of Quality
Cost Of Quality
 
Cost of quality
Cost of qualityCost of quality
Cost of quality
 
QUALITY & COST
QUALITY & COSTQUALITY & COST
QUALITY & COST
 
Cost of quality concept and advantages
Cost of quality   concept and advantagesCost of quality   concept and advantages
Cost of quality concept and advantages
 
Cost of quality
Cost of qualityCost of quality
Cost of quality
 
Strategy Design Pattern
Strategy Design PatternStrategy Design Pattern
Strategy Design Pattern
 
Cost of quality
Cost of qualityCost of quality
Cost of quality
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK Examples
 

Similar to Adapter pattern

M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design Patterns
Dang Tuan
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
stanbridge
 
Design patterns
Design patternsDesign patterns
Design patterns
Akhilesh Gupta
 

Similar to Adapter pattern (20)

Sda 9
Sda   9Sda   9
Sda 9
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
M04 Design Patterns
M04 Design PatternsM04 Design Patterns
M04 Design Patterns
 
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
 
Interface Vs Abstact
Interface Vs AbstactInterface Vs Abstact
Interface Vs Abstact
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Facadepattern
FacadepatternFacadepattern
Facadepattern
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentation
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Design patterns in brief
Design patterns in briefDesign patterns in brief
Design patterns in brief
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
 
React hooks
React hooksReact hooks
React hooks
 
Angularj2.0
Angularj2.0Angularj2.0
Angularj2.0
 
Designing Better API
Designing Better APIDesigning Better API
Designing Better API
 
Design Patern::Adaptor pattern
Design Patern::Adaptor patternDesign Patern::Adaptor pattern
Design Patern::Adaptor pattern
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 

More from Shakil Ahmed (18)

Algorithm
AlgorithmAlgorithm
Algorithm
 
B-tree & R-tree
B-tree & R-treeB-tree & R-tree
B-tree & R-tree
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
Command pattern
Command patternCommand pattern
Command pattern
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Proxy pattern
Proxy patternProxy pattern
Proxy pattern
 
iOS 5
iOS 5iOS 5
iOS 5
 
Ios development
Ios developmentIos development
Ios development
 
Graph
GraphGraph
Graph
 
Lowest common ancestor
Lowest common ancestorLowest common ancestor
Lowest common ancestor
 
Segment tree
Segment treeSegment tree
Segment tree
 
Tree & bst
Tree & bstTree & bst
Tree & bst
 
Trie tree
Trie treeTrie tree
Trie tree
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search Techniques
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Adapter pattern

  • 3. Motivation  Sometimes a toolkit class that's designed for reuse isn't reusable only because its interface doesn't match the domain-specific interface an application requires.  Consider for example a drawing editor that lets users draw and arrange graphical elements (lines, polygons, text, etc.) into pictures and diagrams. The drawing editor's key abstraction is the graphical object, which has an editable shape and can draw itself. The interface for graphical objects is defined by an abstract class called Shape. The editor defines a subclass of Shape for each kind of graphical object: a LineShape class for lines, a PolygonShape class for polygons, and so forth.  Classes for elementary geometric shapes like LineShape and PolygonShape are rather easy to implement, because their drawing and editing capabilities are inherently limited. But a TextShape subclass that can display and edit text is considerably more difficult to implement, since even basic text editing involves complicated screen update and buffer management. Meanwhile, an off-the-shelf user interface toolkit might already provide a sophisticated TextView class for displaying and editing text. Ideally we'd like to reuse TextView to implement TextShape, but the toolkit wasn't designed with Shape classes in mind. So we can't use TextView and Shape objects interchangeably.  we could define TextShape so that it adapts the TextView interface to Shape's. We can do this in one of two ways: (1) by inheriting Shape's interface and TextView's implementation or (2) by composing a TextView instance within a TextShape and implementing TextShape in terms of TextView's interface. These two approaches correspond to the class and object versions of the Adapter pattern. We call TextShape an adapter.
  • 5. Applicability Use the Adapter pattern when  you want to use an existing class, and its interface does not match the one you need.  you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces.  (object adapter only) you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class.
  • 6. Structure Two Types of Adapter Class Adapter Object Adapter
  • 9. Participants Target (Shape) defines the domain-specific interface that Client uses. Client (DrawingEditor) collaborates with objects conforming to the Target interface. Adaptee (TextView) defines an existing interface that needs adapting. Adapter (TextShape) adapts the interface of Adaptee to the Target interface.
  • 10. Collaborations Clients call operations on an Adapter instance. In turn, the adapter calls Adaptee operations that carry out the request.
  • 11. Consequences  Class and object adapters have different trade-offs. A class adapter  adapts Adaptee to Target by committing to a concrete Adapter class. As a consequence, a class adapter won't work when we want to adapt a class and all its subclasses.  lets Adapter override some of Adaptee's behavior, since Adapter is a subclass of Adaptee.  introduces only one object, and no additional pointer indirection is needed to get to the adaptee.  An object adapter  lets a single Adapter work with many Adaptees—that is, the Adaptee itself and all of its subclasses (if any). The Adapter can also add functionality to all Adaptees at once.  makes it harder to override Adaptee behavior. It will require subclassing Adaptee and making Adapter refer to the subclass rather than the Adaptee itself.
  • 12. Consequences  How much adapting does Adapter do? Adapters vary in the amount of work they do to adapt Adaptee to the Target interface. There is a spectrum of possible work, from simple interface conversion—for example, changing the names of operations—to supporting an entirely different set of operations.  Pluggable adapters. A class is more reusable when you minimize the assumptions other classes must make to use it. By building interface adaptation into a class, you eliminate the assumption that other classes see the same interface.  Using two-way adapters to provide transparency. A potential problem with adapters is that they aren't transparent to all clients. An adapted object no longer conforms to the Adaptee interface, so it can't be used as is wherever an Adaptee object can. Two-way adapters can provide such transparency. Specifically, they're useful when two different clients need to view an object differently.
  • 13. Implementation Implementing class adapters in C++. In a C++ implementation of a class adapter, Adapter would inherit publicly from Target and privately from Adaptee. Thus Adapter would be a subtype of Target but not of Adaptee. Pluggable adapters.  Using abstract operations.  Using delegate objects.  Parameterized adapters.
  • 14. Assignment  Your application domain needs a generic Stack<T> class. And your development platform is C#.NET  Let’s assume .NET Framework doesn’t have a generic stack implementation (actually, there is; but just assume there isn’t :D). Also assume there is a generic queue implementation in C# (actually, you don’t have to assume this time; there is in fact one such class under System.Collections.Generic :D).  Write an adapter for this generic queue class to be useable as a generic stack class. You must show both versions – class adapter and object adapter. And your stack class should contain all the standard stack operations.