Question: In addition to the implementation requirements from Homework 1 , you must use arrays, class, and at least one method in this assignment. Arrays will
In addition to the implementation requirements from Homework you must use arrays, class, and at least one method in this assignment. Arrays will be used to store the data. Note that the memory for array size must be dynamically allocated because in many cases, it is not possible to know how much data will be found in a file at the time your code is written. Therefore, it is important to know how to allocate memory dynamically.
EV must initially allocate enough space to hold the data for recordsrows As it reads the file, if that allocation proves to be insufficient, EV will ask for a new allocation twice that large using new copy the old data to the new space, and send old the old data space to the garbage collector. You may call System.gc to request the garbage collector to remove it if needed and continue reading from the file. If that allocation also proves to be insufficient, EV will repeat the doubling, copying, and resuming process, continuing in this way until the entire file is read in This process of dynamically doubling the array size as the data is read must be modularized within a method. This method must be tested and shown to work correctly using JUnit tests that will be included in your test bench, as well as work in the final integrated program. This method will be named "doubleEVRecordArray" and its required signature follows:
EVRecord doubleEVRecordArray EVRecord currentEVRecordArray
The data for each recordrow will be stored in a structure named "Record," which is defined as follows:
class EVRecord
with correct attributes names or any different strategy your come up
The array of records will be defined as an array of records in your program as
EVRecord data; array of records
You must use good programming style and documentation, including making your code modular, using explanatory comments for each section of code, using meaningful variable and method names, using consistent indentation, etc.
You may write your program from scratch or start from programs for which the source code is freely available on the web or through other sources such as friends or student organizations If you do not start from scratch, you must give a complete and accurate accounting of where your code came from and indicate which parts are original or changed and which you got from which sources Failure to give credit where credit is due is academic fraud and will be dealt with accordingly.
You may use existing classes and data structures such as vectors in your code for reading and parsing the input data. However, the doubleEVRecordArray function must be written from scratch for arrays.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
