Professional Documents
Culture Documents
Boun khaising-E7-Abstract Factory
Boun khaising-E7-Abstract Factory
Boun khaising-E7-Abstract Factory
Class: E7
Question
1. អ្វីទៅ Abstract Factory Design Pattern
នៃដំណោះស្រាយ។
Answer
concrete classes.
other factories.
type.
2. UML diagram
+ code
AbstractProductA CreateProductA();
AbstractProductB CreateProductB();
}
public AbstractProductB CreateProductB()
_productA = factory.CreateProductA();
_productB = factory.CreateProductB();
3. Example
interface VehicleFactory
switch (Bike)
{
case "Sports":
case "Regular":
default:
created", Bike));
switch (Scooter)
case "Sports":
case "Regular":
default:
created", Scooter));
}
}
switch (Bike)
case "Sports":
case "Regular":
default:
created", Bike));
switch (Scooter)
case "Sports":
return new Scooty();
case "Regular":
default:
created", Scooter));
interface Bike
string Name();
interface Scooter
string Name();
{
return "Scooty- Name";
class VehicleClient
Bike bike;
Scooter scooter;
bike = factory.GetBike(type);
scooter = factory.GetScooter(type);
return bike.Name();
return scooter.Name();
class Program
{
Console.WriteLine(hondaclient.GetBikeName());
Console.WriteLine(hondaclient.GetScooterName());
Console.WriteLine(hondaclient.GetBikeName());
Console.WriteLine(hondaclient.GetScooterName());
Console.WriteLine(heroclient.GetBikeName());
Console.WriteLine(heroclient.GetScooterName());
Console.WriteLine(heroclient.GetBikeName());
Console.WriteLine(heroclient.GetScooterName());
Console.ReadKey();