Skip to content

This EX is a Typescript EX that practices Adapter-design-pattern.

Notifications You must be signed in to change notification settings

LiatHanunu/Adapter-Design-Pattern-EX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdapterDesignPatternTS

This EX is a Typescript EX that practices Adapter-design-pattern.

Adapter is a structural design pattern that allows objects with incompatible interfaces to collaborate.

In this Ex I implement the use of adapter design-pattern, using TypeScript.

Ex instructions

  • Using interface, Create Processor interface that hsa a name and process method - gets input as string and returns string.
  • Create StringProcessor as a base class for all string processors.
  • StringProcessor implements Processor interface!
  • Leave process method as abstract.
  • Create UpCase (class, a kind of Processor), Which gets input as a string and returns the string in upper case
  • Create DownCase (a kind of Processor), Which gets input as a string and returns the string in lower case
  • Create SplitterMark (a kind of Processor), Which gets input as a string and returns the string with ! in between the words
  • Create a Tester class with static method like so:
  • process(p:Processor, s:string):void {
  • log("Using Processor " + p.name)
  • log(p.process(s))
  • }
  • Create a new class named String Swapper that has a method named swap, taking a string and returns a string.
  • This method swaps each 2 characters, starting from both sides of the string, in that input ('Ahalan' -> 'nalahA')
  • Assume you can't change existing code, How can we use our new string swapper class with our Tester process method?
  • Create processors objects and test them via Tester.process

About

This EX is a Typescript EX that practices Adapter-design-pattern.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages