public void CreateCircleObject() { abstractFactory = factoryProducer.getFactory("shape"); IShape shape = abstractFactory.GetShape("circle"); Assert.IsInstanceOf <Circle>(shape); }
static void Main(string[] args) { AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE"); Shape shape1 = shapeFactory.getShape("Circle"); shape1.draw(); Shape shape2 = shapeFactory.getShape("Square"); shape2.draw(); Shape shape3 = shapeFactory.getShape("Rectangle"); shape3.draw(); var line = Console.ReadLine(); AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR"); Color col1 = colorFactory.getColor("Red"); col1.fill(); Color col2 = colorFactory.getColor("Blue"); col2.fill(); Color col3 = colorFactory.getColor("Green"); col3.fill(); line = Console.ReadLine(); }
public void Test_For_When_Given_A_Different_Shape() { // Arrange var myFactory = FactoryProducer.getFactory("Shape"); // Act 1 var shape1 = myFactory.getShape("Triangle"); // Assert Assert.AreEqual(shape1, null); }
private void initGame() { board = new Board(); shapeFactory = FactoryProducer.getFactory(); shape = shapeFactory.getShape(rnd.Next(1, 6)); shapesInTheBottom = new List <IShape>(); timerAni.Enabled = false; if (context.getState() == gameReset) { pictureBox1.Invalidate(); } }
public int CreateBA(int playerId) { //BattleArena tempBA = new BattleArena(); AbstractFactory abstractFactory = FactoryProducer.getFactory(false); BattleArena tempBA = abstractFactory.getBattleArena("basic"); tempBA.PlayerId = playerId; _context.BattleArenas.Add(tempBA); _context.SaveChanges(); return(GetBAId(playerId)); }
public void NewLevel(int level) { FactoryProducer factoryProducer = new FactoryProducer(); levelFactory = factoryProducer.getFactory(level); //Get the factory for the level library = levelFactory.createLibrary(); //Creates Library Associated with LevelLibrary String word = library.generateWord(); //Generates a word from LevelLibrary shape = levelFactory.createShape(); //Creates the Shape and color of shape for level delaytime = levelFactory.getDelay(); this.level = levelFactory.getLevel(); //Only needed for if dynamic linkage doesnt work, makes sure to get the true level IntLevelLabel.Text = this.level.ToString(); }
public void Test() { //获取形状工厂 AbstractFactory shapeFactory = FactoryProducer.getFactory <ShapeFactory>(); //获取形状为 Circle 的对象 Shape shape1 = shapeFactory.getShape <Circle>(); //调用 Circle 的 draw 方法 shape1.draw(); //获取形状为 Rectangle 的对象 Shape shape2 = shapeFactory.getShape <Rectangle>(); //调用 Rectangle 的 draw 方法 shape2.draw(); //获取形状为 Square 的对象 Shape shape3 = shapeFactory.getShape <Square>(); //调用 Square 的 draw 方法 shape3.draw(); //获取颜色工厂 AbstractFactory colorFactory = FactoryProducer.getFactory <ColorFactory>(); //获取颜色为 Red 的对象 Color color1 = colorFactory.getColor <Red>(); //调用 Red 的 fill 方法 color1.fill(); //获取颜色为 Green 的对象 Color color2 = colorFactory.getColor <Green>(); //调用 Green 的 fill 方法 color2.fill(); //获取颜色为 Blue 的对象 Color color3 = colorFactory.getColor <Blue>(); //调用 Blue 的 fill 方法 color3.fill(); }
static void AbstructFactory() { //get shape factory AbstructFactory.AbstructFactory shapeFactory = FactoryProducer.getFactory("SHAPE"); //get an object of Shape Circle AbstructFactory.Shape shape1 = shapeFactory.GetShape("CIRCLE"); //call draw method of Shape Circle shape1.Drow(); //get an object of Shape Rectangle AbstructFactory.Shape shape2 = shapeFactory.GetShape("RECTANGLE"); //call draw method of Shape Rectangle shape2.Drow(); //get an object of Shape Square AbstructFactory.Shape shape3 = shapeFactory.GetShape("SQUARE"); //call draw method of Shape Square shape3.Drow(); //get color factory AbstructFactory.AbstructFactory colorFactory = FactoryProducer.getFactory("COLOR"); //get an object of Color Red AbstructFactory.Color color1 = colorFactory.GetColor("RED"); //call fill method of Red color1.Fill(); //get an object of Color Green AbstructFactory.Color color2 = colorFactory.GetColor("Green"); //call fill method of Green color2.Fill(); //get an object of Color Blue AbstructFactory.Color color3 = colorFactory.GetColor("BLUE"); //call fill method of Color Blue color3.Fill(); }