// GetProgram delegates the object creation for a program to the factory and then continues processing public OfficeProgram GetProgram(OfficeProg prog) { var program = _officeProgramFactory.CreateOfficeProgram(prog); program.PutToBasket(); program.PutLabel(); return(program); }
public OfficeProgram CreateOfficeProgram(OfficeProg prog) { switch (prog) { case OfficeProg.Word: return(new Word()); case OfficeProg.Powerpoint: return(new Powerpoint()); case OfficeProg.Excel: return(new Excel()); case OfficeProg.None: return(null); default: throw new ArgumentOutOfRangeException(nameof(prog), prog, null); } }