Esempio n. 1
0
    static void Main(string[] args)
    {
        var bob     = new Kid("Bob", new List <Kid>());
        var alice   = new Kid("Alice", new List <Kid>());
        var jimList = new List <Kid>();

        jimList.Add(bob);
        jimList.Add(alice);
        var jim     = new Kid("Jim", jimList);
        var joeList = new List <Kid>();

        joeList.Add(bob);
        var joe      = new Kid("Joe", joeList);
        var dudeList = new List <Kid>();

        dudeList.Add(jim);
        dudeList.Add(alice);
        var dude       = new Kid("Dude", dudeList);
        var sophieList = new List <Kid>();

        sophieList.Add(dude);
        var sophie      = new Kid("Sophie", sophieList);
        var margretList = new List <Kid>();

        margretList.Add(sophie);
        var margret = new Kid("Margret", margretList);

        try {
            Console.WriteLine($"{bob.CanBeFriendsWith(bob)}");
            var v2 = bob.CanBeFriendsWith(alice);
            Console.WriteLine($"{v2}");
            var v3 = bob.CanBeFriendsWith(jim);
            Console.WriteLine($"{v3}");
        } catch (NullReferenceException e) {
            Console.WriteLine($"{e.Source}")
        }
        return;
    }