Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Lab 7 - Persistent Data - COMP2100/6442 Skip navigation COMP2100/6442 ANU College of Engineering & Computer Science Search query Search ANU web, staff & maps Search COMP2100/6442 Exams menu Search query Search ANU web, staff & maps Search Search COMP2100/6442 labs Overview Lab 1 - Install Lab 2 - Git / SSH Lab 3 - Trees Lab 4 - Parser Lab 5 - Android 1 Lab 6 - Android 2 Lab 7 - Persistent Data Lab 8 - PHP Lab 9 - Lab Test 1 Lab Test 2 related sites Wattle Lab 7 - Persistent Data Partial code for this lab is available at here. Task 1 - Save data to a file [0.5 marks] This stage aims to save the data of a class to a file. Open your Book Collection implementation (task/BookCollection.java) and fill in the “save” functions. Directly save the class using bespoke or serialization method. For bespoke, you could define your own format for saving a book collection. Implement saveToBespokeFile method once you define your own format. Using JSON to save the structure of the book collection. Implement saveToJSONFile in BookCollection.java. There are multiple ways to write JSON documents as well. In this task, we will use Gson library which is one of the most popular way in the industry. However, Gson is not part of the JRE. Please add gson-2.8.6.jar file to your classpath to import the library properly. The jar file is available in the lab repository as well. Here’s a simple explanation on how to use Gson library to read/write json files link Using XML to save the structure of the book collection. Implement saveToXMLFile in BookCollection.java. There are many different ways to write XML documents. During the class, we have discussed DOM-based approach. You can use DOM-based approach, or you may want to use an alternative. In this case, please make sure that your implementation is compilable with Java 8+ (Use standard library). Task 2 - Load data from a file [0.5 marks] Similarly, now implement the “load” methods for these files. Note that the format for these has already been specified, and each of these load methods should be capable of reading the corresponding file saved in Task 1. Implement loadFromBespokeFile method in BookCollection.java to load a book collection which is stored by saveToBespokeFile method. Implement loadFromJSONFile method in BookCollection.java to load a book collection which is stored by saveToJSONFile method. Implement loadFromXMLFile method in BookCollection.java to load a book collection which is stored by saveToXMLFile method. For both task 1 and 2, you can add throw statements in each of methood signature if needed. Please use the given test file to check the correctness of your implementation. Note that the test cases do not validate the correctness of your JSON or XML files. You may want to validate the correctness of file format with additional test cases. Submission Guideline This is an individual task. You can discuss with your colleagues how to solve the tasks, but never copy their solutions. Assignment deadline: 11:55pm 20 May 2020 Submission mode: Electronic, via Wattle (Lab 7) Submission format (IMPORTANT): Upload your final version of java files to Wattle. You should upload BookCollection.java to Wattle submission page (1 java file). Do not change the structure of the partial code including class names and package structure. You may use standard libraries to complete the tasks, but it is not allowed to use external libraries. Do not import packages outside of the standard java SE package. The list of available packages can be found here: https://docs.oracle.com/en/java/javase/11/docs/api/index.html Some IDEs (such as NetBeans) will automatically import some libraries. Please remove these libraries before submit. Violation of the submission format will have their assignment not evaluated by an autograder and get zero marks. Updated:  / Responsible Officer:  / Page Contact:   Contact ANU Copyright Disclaimer Privacy Freedom of Information +61 2 6125 5111 The Australian National University, Canberra CRICOS Provider : 00120C ABN : 52 234 063 906 You appear to be using Internet Explorer 7, or have compatibility view turned on. Your browser is not supported by ANU web styles. » Learn how to fix this » Ignore this warning in future