Gaining experience with:
Please watch this video Introducing the BlueJ Debugger
Student Organizations at Wellesley College are clubs, created and managed entirely by students, with the purpose of enhancing the Wellesley Community. Students are encouraged to participate in these clubs. They can also create new Student Organizations if they feel they are needed to cover some interest. There are currently over 200 student organizations at Wellesley College.
A Student Organization has a president, may have a vice-president, as well as regular members. All Organization members need to be current Wellesley students. Once a student has graduated, they cannot be a member any more.
For this lab, we will use Java's LinkedLists (click for LinkedList Java API) to represent the members in Student Organizations. Every node in such a List will contain an object of type ClubStudent. Linked Lists offer themselves as a suitable type of data structure in this application, since the number of members in a student organization is not known in advance, and also this number will grow and shrink over the organization's lifetime.
We are providing you with two classes, named Student and ClubStudent. Download the starting code.
First, notice that the Student class implements the Java Comparable Interface. Pay particular attention to the equals() and compareTo() method definitions. According to these definitions what does it mean for a Student instance to be greater (or smaller) than another one? What does it mean for two such instances to be equal?
Now, take a closer look at the ClubStudent class. What properties and methods does a ClubStudent instance inherit from its parent? What are the relevant characteristics of a ClubStudent, that have been added onto the Student data? What about relevant behaviors?
In this task is to define a new class, named StudentOrganization. We will use Java's LinkedList in this definition.
For the purposes of this application, we are interested in keeping track of the name, the members, the president and the vice-president of an organization.
Question: What is the relationship between the two classes: ClubStudent and StudentOrganization?
Start your StudentOrganization class implementation:
Set up its instance variables
Write a 1-parameter constructor that takes the name of the Organization as its only input. It is used to just create an Organization without members, president or vice president.
Test this constructor, even at this early point. You do not expect much to happen yet, but at least you should not see any "abnormal" behaviors.
Write some instance methods
toString() that provides for a reasonable string representation of a Student Organization object. Make sure to test this method, even if it is on an empty organization!
numOfMembers() a method to return the size of the organization.
addMember() to add a member to the organization. Does it need an input argument? What type? How should this method behave if the object specified to be added to the organization is already there? Remember that since you are using Java's LinkedLists implementation, its API can have lots of useful methods already defined for you to use!
At this point you are in a position to do some comprehensive testing of all your code so far. Add a few members to your clubs and test that they are printed correctly.
Add a method to return all the members that have not paid their fees. What structure are you going to use to hold these members?
We will demonstrate the BlueJ debugger on our version of StudentOrganization program. Then, try your hands on using the debugger on your own program.