/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gamegraphics.elements;


import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;


/**
 *
 * @author Ani
 */
public class House extends Canvas{
    protected List<Figure> figureList;
    protected Random random;
    protected List<Point> coordinateList;
    protected int coorX;
    protected int coorY;



    public House(Dimension d) {
        this((int) d.getWidth(), (int) d.getHeight());
    }

    public House(int coorX, int coorY){
        this.coorX = coorX;
        this.coorY = coorY;
        random = new Random();
        figureList = new ArrayList<Figure>();
        coordinateList = new ArrayList<Point>();
        addFigures(4);
        
    }

    public int getCoorX() {
        return coorX;
    }

    public int getCoorY() {
        return coorY;
    }

    public List<Point> getCoordinateList() {
        return coordinateList;
    }

    public List<Figure> getFigureList() {
        return figureList;
    }

    public void setFigureList(List<Figure> figureList) {
        this.figureList = figureList;
    }

    public void removeFigures(){
        figureList.clear();
        coordinateList.clear();
    }

    public void addFigure(){
        figureList.add(new Figure());
        coordinateList.add(new Point(coorX + random.nextInt(30)+5, coorY + random.nextInt(30)));
    }

    public void addFigure(Figure figure){
        figureList.add(figure);
    }

    public void addFigure(int x, int y){
        figureList.add(new Figure());
        coordinateList.add(new Point(coorX + x, coorY + y));
    }

    public void addFigures(int number){
        for (int i=0; i<number; i++){
            addFigure();
        }
    }

    public int getNumberOfFigures(){
        return figureList.size();
    }

    public Point getCoordinatesOfFigure(int number){
        return coordinateList.get(number);
    }


    @Override
    public void paint(Graphics g) {

        for (int i = 0; i<figureList.size(); i++){
            figureList.get(i).paint(g, coordinateList.get(i).x, coordinateList.get(i).y);
        }
    }

}
