package com.akarpov.tutorial;

/**
 * Created with IntelliJ IDEA.
 * User: akarpov
 * Date: 06/07/13
 * Time: 2:44 PM
 * To change this template use File | Settings | File Templates.
 */
public class RobotFactory {
    public static final int MAX_ROBOTS = 10;

    public static int numRobots;

    public static Robot makeRobot() {
        if (numRobots >= MAX_ROBOTS) {
            throw new RuntimeException("Maximum number of robots reached!");
        }
        System.out.println("Making a generic anonymous class robot.");
        return new Robot() {};

    }
    public static Robot makeTerminator(String model) {
        if (numRobots >= MAX_ROBOTS) {
            throw new RuntimeException("Maximum number of robots reached!");
        }

        return new Terminator(model);
    }

    public static Robot cloneRoboto(Robot r) {
        return r.duplicate();
    }
}
