Factory Method is a creational design pattern that deals with the object creation. It separates the object creation logic from…