Question: Im creating some tasks for my game like collect coins or set new record, and idk how to select task in my method right;

Im trying to random select the type of quest, and work with instance of that class but i cant assign it to 1 name "quest" to work with;

```
public class Quests : MonoBehaviour
{
    public Text taskText;

    private void Start()
    {
        SelectQuest();
        taskText.text = quest.discription; //doesnt exist
    }

    public void SelectQuest()
    {
        int random = Random.Range(0, 3);
        switch (random)
        {
            case 0:
                Quest quest = new Quest("Set new record to reward");
                break;
            case 1:
                Quest quest = new Quest(1000, "Collect 1000 coins to reward");
                break; //quest cannot be assign because it used on case 0
            case 2:
                Quest quest = new Quest(5000, "Get 5000 score to reward");
                break; //quest cannot be assign because it used on case 0
        }
    }

}

public class Quest
{
    public string Discription;
    public bool isDone = false;
    public int Target;

    public Quest(int target, string discription)
    {
        Target = target;
        Discription = discription;
    }

    public Quest(string discription)
    {
        Discription = discription;
    }

    public bool CheckForComplete(int target)
    {
        if (Target >= target)
            isDone = true;
        return isDone;
    }
}

```

so what i need - how to do it right - i need to work with only 1 type of task named quest, but i cant choose 1 of 3 types for that quest. cant imagine how to do that

Answer: 
I'm not too sure what you are asking for. But I am making an attempt to clean up your code, which may help.

```
public class Quests : MonoBehaviour
{
    public Text taskText;

    private void Start()
    {
        var quest = SelectQuest();
        taskText.text = quest?.discription; 
    }

    public Quest SelectQuest()
    {
        int random = Random.Range(0, 3);
        switch (random)
        {
            case 0:
                return new Quest("Set new record to reward");   
            case 1:
                return new Quest(1000, "Collect 1000 coins to reward");
            case 2:
                return new Quest(5000, "Get 5000 score to reward");
            default:
            return null;
        }
    }

}

```
Your question is not clear, but If I understand what you are looking for.. I think you just need to hold a public `Quest` field/property in your class.

```
public class Quests : MonoBehaviour
{
    public Text taskText;
    public Quest SelectedQuest { get; private set; } 

    private void Start()
    {
        SelectedQuest = SelectQuest();
        taskText.text = SelecedQuest?.discription; //doesnt exist
    }

    public void SelectQuest()
    {
        Quest retVal = null;
        int random = Random.Range(0, 3);
        switch (random)
        {
            case 0:
                retVal = new Quest("Set new record to reward");
                break;
            case 1:
                retVal = new Quest(1000, "Collect 1000 coins to reward");
                break; //quest cannot be assign because it used on case 0
            case 2:
                retVal = new Quest(5000, "Get 5000 score to reward");
                break; //quest cannot be assign because it used on case 0
            default:
                break;
        }
        return retVal;
    }
}

```