In this kata we are going to mimic a software versioning system.
You have to implement a VersionManager class.
It should accept an optional parameter that represents the initial version. The input will be in one
of the following formats: "{MAJOR}", "{MAJOR}.{MINOR}", or "{MAJOR}.{MINOR}.{PATCH}". More
values may be provided after PATCH but they should be ignored. If these 3 parts are not decimal
values, an exception with the message "Error occured while parsing version!" should be thrown. If
the initial version is not provided or is an empty string, use "0.0.1" by default.
This class should support the following methods, all of which should be chainable (
except release):
major()- increaseMAJORby1, setMINORandPATCHto0minor()- increaseMINORby1, setPATCHto0patch()- increasePATCHby1rollback()- return theMAJOR,MINOR, andPATCHto their values before the previousmajor/minor/patchcall, or throw an exception with the message"Cannot rollback!"if there's no version to roll back to. Multiple calls torollback()should be possible and restore the version historyrelease()- return a string in the format"{MAJOR}.{MINOR}.{PATCH}"