Skip to main content

Exercises

Exercise 1: Modify DisplayTreeView so that it displays the phone numbers (type and number) associated with each contact. The tree should display the set of phone numbers associated with a contact as a set of subnodes of the contact.

Exercise 2: Complete the DisplayPhoneNumber method. This method displays a phone number's information on the Edit Phone Information GUI panel. The method accepts as an argument a string representing the object ID of the PhoneNumber instance to be displayed. Event handling code has been provided so that clicking a phone number displayed on the tree invokes DisplayPhoneNumber. Note that DisplayPhoneNumber should invoke DisplayContact passing as an argument the object ID of the Contact associated with the displayed PhoneNumber.

Exercise 3: Complete the UpdatePhoneNumber method. This method saves to the database any changes made to a phone number through the Edit Phone Information GUI panel. If the method successfully saves the PhoneNumber instance, then it should invoke RefreshContacts and DisplayPhoneNumber. It should pass DisplayPhoneNumber the object ID of the saved PhoneNumberInstance. Note that this method can be invoked in two different places:

  1. In the event handling code for the Update button. The event handling code is provided.

  2. In the code for the AddPhoneNumber method. This is code that you write.

Exercise 4: Complete the AddPhoneNumber method. The method creates a new phone number using the information entered into the Edit Phone Information GUI panel. The method assigns the new PhoneNumber to be a child object of the Contact instance displayed by the Edit Phone Information panel when AddPhoneNumber is invoked. To avoid code duplication, the method may make use of the UpdatePhoneNumber method completed in an earlier exercise.

Exercise 5: Complete the DeletePhoneNumber method. This method removes from the database the phone number displayed in Edit Phone Information. The method can use the ClearPhoneNumber method to clear the Edit Phone Information display. The code for ClearPhoneNumber ismethodname provided. The event handler for the Delete button invokes DeletePhoneNumber. The event handling code is provided.

FeedbackOpens in a new tab