我的代码中有这个
switch (auctionType)
{
case AuctionTypes.OpenBid:
destination = new EnglishAuction();
break;
case AuctionTypes.FixedPrice:
destination = new BuyoutAuction();
break;
case AuctionTypes.ClosedBid:
destination = new SealedFirstPriceAuction();
break;
default:
destination = new Auction();
break;
}
我想知道的是如何通过使用策略或状态模式来消除 switch 语句?