From the course: C++ Design Patterns: Structural
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Challenge: Refactor using the Adapter pattern - C++ Tutorial
From the course: C++ Design Patterns: Structural
Challenge: Refactor using the Adapter pattern
- [Instructor] Here's a challenge for you. Design an adapter that integrates a third party class into your design. The project consists of three classes. The cloud storage abstract class that provides the common interface that all cloud storage services must expose, it has two methods, upload contents, which uploads the specified content to cloud storage and get free space, which returns the amount of free space left on cloud storage. There are two classes that implement this interface, cloud drive and fast share. Your challenge is to design an adapter that integrates a new cloud storage service. Let's call it virtual drive. This class exposes a similar yet, incompatible interface. It has two methods, upload data and used space and a static constant that holds the total storage space. Note that used space returns the used cloud storage space and not the free available space. Now, we can't just add the virtual…