Pattern interview question

Finish this method in this class in whatever language.