package com.ice.creation.AbstractFactory;

import com.ice.creation.AbstractFactory.factory.*;
import com.ice.creation.AbstractFactory.product.Chair;
import com.ice.creation.AbstractFactory.product.CoffeeTable;
import com.ice.creation.AbstractFactory.product.Sofa;

import java.util.NoSuchElementException;

/**
 * @author ice
 * @blog https://blog.csdn.net/dreaming_coder
 * @description
 * @create 2021-10-13 10:51:49
 */
public class Client {
    private FurnitureFactory factory;

    public Client(FurnitureStyle style) {
        if (style == FurnitureStyle.Modern) {
            this.factory = new ModernLine();
        } else if (style == FurnitureStyle.Victorian) {
            this.factory = new VictorianLine();
        } else if (style == FurnitureStyle.ArtDeco) {
            this.factory = new ArtDecoLine();
        } else {
            throw new NoSuchElementException("没有此种风格生产线");
        }
    }

    public void purchaseFurniture() {
        Chair chair = factory.createChair();
        Sofa sofa = factory.createSofa();
        CoffeeTable coffeeTable = factory.createCoffeeTable();
        chair.info();
        sofa.info();
        coffeeTable.info();
    }
}
