Skip to content

Instantly share code, notes, and snippets.

@cch12313
Created November 8, 2021 17:13
Show Gist options
  • Save cch12313/8b67ede6c28c54761f319c74928422ec to your computer and use it in GitHub Desktop.
Save cch12313/8b67ede6c28c54761f319c74928422ec to your computer and use it in GitHub Desktop.
public enum RacingType
{
Default = 0,
Toyote = 1,
Bens = 2,
Tezla = 3,
Blanket = 4,
Chair = 5,
Gororo = 6,
}
public class RacingFactory
{
public IRacing Create(RacingType racingType)
{
IRacing racing;
switch (racingType)
{
case RacingType.Toyote:
racing = new Toyote();
break;
case RacingType.Bens:
racing = new Bens();
break;
case RacingType.Tezla:
racing = new Tezla();
break;
case RacingType.Blanket:
racing = new Blanket();
break;
case RacingType.Chair:
racing = new Chair();
break;
case RacingType.Gororo:
racing = new Gororo();
break;
default:
throw new NotImplementedException();
}
return racing;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment