Green Energy Ltd. has recently employed you as a consultant software developer in its Systems department.

You have been contracted to help design and develop data collection and analysis software to monitor Electromagnetic-field (EM-field) energy levels in order to help Ireland meet the EU Directive on electricity pollution levels. In the project scope, it is required that multiple EM-field stations will be placed around the Irish Electricity Network and each station will capture data via its EM-field detectors.

(a) Develop a class EMfieldDetector to model the detected data via an array and methods operating on the array. The class should have the following members:

  • An array that can hold whole values;
  • A constant that specifies the maximum number of values that can be stored in the array;
  • A constructor with one argument that initialises the constant in the previous point and initialises the array to be able to store whole numbers;
  • A method that adds a number to the array.
  • A method that returns the value at a given position in the array. The position is specified by the value of the argument.
  • A method call that will add all elements currently in the array and return the result.
  • A method which overrides the inherited toString method and returns a string that appends the size of the array to the value returned by the inherited toString method.

Include your Java code into your solution document.

(b) Develop the implementation of a method isCompliant that will compare the contents of the Detector objects integer array with the contents of the argument (EU compliant) objects array. The contents of the detector object is deemed to be compliant if both objects respective arrays are of the same size and contain the same numbers in matching order.

Include your Java code for the isCompliant method into your solution document.

(c) Add a method to the EMfieldDetector class called recordEnergyReading which writes all numbers in the int array to a file specified by the String argument. For example, the call recordEnergyReading (detectordata.txt) will write to the file detectordata.txt. Each number written to the file should be separated from the next by a blank space.

Include your Java code for the recordEnergyReading method into your solution document.

(d) Add a method to the EMfieldDetector class called loadEnergyData that reads int numbers from a target file (the file name is specified by the String argument). So the call loadEnergyData (detectordata.txt) will read the int numbers in the file dectordatadata.txt into the int array within EMfieldDetector.

Include your Java code for the loadEnergyData method into your solution document.

(e) Write a class TestEMfieldDetector with a main method that will create a number of EMfieldDetector objects. Your code should fully test all the functionality of the EMfieldDetector class including the isCompliant method. Include your Java code and the resulting output into your solution document.

(f) You discover that the detector produces additional data points under certain conditions, for example, near heavily populated urban areas. Briefly explain the changes you need to make to the EMfieldDetector class and why. In your answer, refer to each of the below collection types and explain whether it is well-suited to replacing the int array in the EMfieldDetector class:

  • ArrayList
  • HashMap
  • TreeSet
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.