ts Adapter pattern
The solution for “ts Adapter pattern” can be found here. The following code will assist you in solving the problem.
/*Adapter
The Adapter design pattern is a design pattern lets you convert
the interface of a class into another interface
that it expects.
imagine you want to turn a socket into a plug.
*/
class Socket {
constructor(private type: string) {}
public getType() {
return this.type;
}
}
// Then you make a plug class:
class Plug {
constructor(private type: string) {}
public getType() {
return this.type;
}
}
// Then you make an adapter class that will adapt
// the socket class to the plug class:
class SocketAdapter implements Plug {
constructor(private socket: Socket) {}
public getType() {
return this.socket.getType();
}
}
//Then you make your plug:
const plug = new SocketAdapter(new Socket(‘Type-C’));
console.log(plug.getType());
// As you can see the adapter class uses inheritance to adapt
// the socket class to the plug class.
More questions on [categories-list]
- tss from gene granges
- ixl ansers ixl ansers
- get coin prices node-binance
- how to setup netflix workflow worker
- spritesheets in pyqt spritesheets in pyqt
- cahokia mounds pictures cahokia mounds pictures cahokia mounds pictures
- python 2 decimal places how to get decimal part of a double in python set number of decimals python
- how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python how to find nuber of tweets per day using python
- haskell get specific elements of a String
- vb net code snippets for storing password
- error TS2307: Cannot find module ‘@ngx-meta/core’.
- inline scripts encapsulated in tags