90 points: The program
Contact_Book_V2.java has no means for saving the data users enter.Please modify this program to enable it store data to and retrieve it from a file.To make this work, you will need to add:
- menu items for the write and read operations
- View methods to receive requests for these operations from the user
- Controller methods to receive the requests from view and forward them to the model
- A Model method to write the TreeMap’s objects to an ObjectOutputStream.
- Another Model method to read the objects from the file back into the TreeMap using an ObjectInputStream.Unless you can think of another way to do this,this application will use the TreeMap as temporary storage for adding and deleting contacts. Then the user will save her changes to the file by invoking the write method. After starting the application,she will select the option to read the file into the TreeMap.A really clever alternative would be to automatically read the file when the application starts and automatically write to the file when the user chooses to exit.It will help to trace the path for existing operations like adding a new contact or finding a contact from their menu items through their related view and controller methods then finally to their model methods.The sample program
ObjectFileDriver.java in the BoatWithTreeMap group demonstrates writing TreeMaps to files.
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: firstname.lastname@example.org 微信号:vipnxx