Perform the following refactorings to the Project Streaming codebase.
Account::report()
lines 94-97, the variable time
is used for two different purposes. Perform an Introduce Explaining Variable that adds a new variable to make this part of the code easier to understand.Video
, the two attributes lengthHours
and lengthMinutes
always occur together. Perform an Extract Class to combine these into a single class, Duration
, with minutes and hours as attributes.Account::report()
, apply an Extract Method to extract a new method getNumberOfStreams()
from the code in the loop that computes the number of streams.Account::report()
, apply an Extract Method to extract a new method getNumberOfOriginals()
from the code in the loop that computes the number of originals.Account
but focus all their attention on the class Video
. So use a Move Method to move these methods from class Account
to class Video
. Note: The alternative is to move these methods to class Stream
. Either move is acceptable.getStreamType()
from the code in the loop that determines the stream type.Video
, so apply a Move Method to move the method to the class Video
.Big Refactoring
The class Video
has a type attribute that determines what it is: (Movie
, TV
, or Original
). A switch statement selects the proper logic, a classic sign of poor abstraction and design. Instead, the code should use subclassing and virtual methods to address this problem. Do so by performing the following separate steps:
Movie
, TV
, and Original
, that inherit from the class Video
.Video
and classes Movie
, TV
, and Original
.getNumberOfStreams()
, getNumberOfOrginals()
, and getStreamType()
.Video
, these methods would be a pure virtual methods, making the class Video
abstract.