using Model.Stub;
﻿using System.Runtime.CompilerServices;

namespace Model;

public class CustomTitle : Title { 

    public string Path
    {
        get => path;

        set
        {
            if (value != null && value.Length < Manager.MAX_DESCRIPTION_LENGTH)
            {
                path = value;
            }
        }
    }

    private string path = Manager.DEFAULT_URL;

    public CustomTitle(string name, string imageURL, string information, string path) : base(name, imageURL, information)
    {
        Path = path;
    }

    public CustomTitle() : base(Manager.DEFAULT_NAME, Manager.DEFAULT_URL, Manager.DEFAULT_DESC) { }

    public override bool Equals(object? obj)
    {
        if (obj is null) return false;
        if (obj.GetType() != typeof(CustomTitle)) return false;
        if (obj is CustomTitle customTitle && ImageURL == customTitle.ImageURL) return true;
        else return false;
    }

    public override int GetHashCode()
    {
        return ImageURL.GetHashCode();
    }

    public override string ToString()
    {
        return $"Name : {Name}, Path : {Path}";
    }
}
