<?php

namespace AppBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;

class Room
{
    // von BookingRequest abgeguckt, brauch ich das überhaupt, wenn ich bei $type ein Assert habe?
    const SINGLE = 1;
    const DOUBLE = 2;
    const TRIPLE = 3;

    const SINGLECHILD = 4;
    const DOUBLECHILD = 5;
    const TRIPLECHILD = 6;

    /**
     * @Assert\NotNull
     * @Assert\Choice(choices={1,2,3})
     */
    private $type;

    private $child = false;

    /**
     * @Assert\Valid
     */
    private $travelers = [];

    private $travelerCount;
    private $childrenCount;

    public function __construct($type)
    {
        $child = 0;
        if($type == 4){
            $type = 1;
            $child = 1;
            $this->child = true;
        }
        if($type == 5){
            $type = 2;
            $child = 1;
            $this->child = true;
        }
        if($type == 6){
            $type = 3;
            $child = 1;
            $this->child = true;
        }
        $this->type = $type;

        for($i = 0; $i < $this->type; $i++)
        {
            $this->travelers[] = new Traveler();
        }

        for($i = 0; $i < $child; $i++)
        {
            $temp = new Traveler();
            $temp->setChild(true);
            $this->travelers[] = $temp;
            $this->childrenCount++;
        }

        $this->travelerCount = $type;
    }

    /**
     * @return int
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @param int $type
     */
    public function setType($type)
    {
        $this->type = $type;
    }

    /**
     * @return int
     */
    public function getChild()
    {
        return $this->child;
    }

    /**
     * @param int $child
     */
    public function setChild($child)
    {
        $this->child = $child;
    }

    /**
     * @return Traveler[]
     */
    public function getTravelers()
    {
        return $this->travelers;
    }

    /**
     * @param Traveler[] $travelers
     */
    public function setTravelers($travelers)
    {
        $this->travelers = $travelers;
    }

    /**
     * @return mixed
     */
    public function getTravelerCount()
    {
        return $this->travelerCount;
    }

    /**
     * @param mixed $travelerCount
     */
    public function setTravelerCount($travelerCount)
    {
        $this->travelerCount = $travelerCount;
    }

    /**
     * @return mixed
     */
    public function getChildrenCount()
    {
        return $this->childrenCount;
    }

    /**
     * @param mixed $childrenCount
     */
    public function setChildrenCount($childrenCount)
    {
        $this->childrenCount = $childrenCount;
    }


}