On this page:
Circularly Referential Data

Lab 8: Working with Cyclic Data

Circularly Referential Data

Goals: The goals of this lab is to learn how to design and use circularly referential data.

Related files:
  Buddies.zip     tester.jar  

In this lab, we’ll look at how circular data naturally appears in lists of friends, or ‘buddy lists.’ These buddy lists could be IM buddy lists, Twitter followers, or lists of friends on social networks. Intuitively, a buddy list is just a username and a list of other buddies. If two people are on each other’s buddy lists, we immediately get circularity.

Download the Buddies.zip file above. It contains the files:

Create a project Lab8-Buddies and import the five files listed above into the default package. Add the tester.jar library to the project as you have done before.

All errors should have disappeared and you should be able to run the project.

If someone wants to invite a lot of friends to a party, he or she calls all people on his or her list of buddies, and asks them to invite their friends (buddies) as well, and ask their friends to invite any of their friends as well (and ask them to invite their friends in turn...), eventually inviting anyone that can be reached through this network of friends.

We call those on the person’s buddy list the direct buddies and the others that will also be invited to the party the distant buddies.

Now we would like to ask some pretty common questions. For each question design the method that will find the answer. As always, follow the Design Recipe! The purpose/effect statements and the headers for the methods are already given: