﻿using DressingSimulation.Domain.Clothes.Interfaces;
using DressingSimulation.Domain.Furniture.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DressingSimulation.Furniture
{
    public class Closet : IFurnitureItem
    {
        private IClothes[] _clothes;
        public Closet(IClothes[] clothes) { _clothes = clothes; }

        public bool RemoveClothing(IClothes clothingItem)
        {
            bool response = false;
            if (_clothes != null)
            {
                var workingList = _clothes.ToList();
                response = workingList.Remove(clothingItem);
                if (response)
                    _clothes = workingList.ToArray();

            }
            return response;
        }

        public bool SearchForClothing(IClothes clothingItem)
        {
            return (_clothes == null)?false: _clothes.Any(clothesItem => clothesItem.Equals(clothingItem));
        }
    }
}
