main.cs1045 chars56 lines
This code defines a factory method CarFactory
that creates instances of different types of cars based on the input car type. The CarFactory
class has a static method GetCar
which takes a car type as input and returns an instance of the corresponding car. There are two concrete classes Sedan
and Suv
that implement the ICar
interface. The client code demonstrates how to use the factory method to create and drive different types of cars.
gistlibby LogSnag