diff_months: 11

Assignment 2

Download Solution Now
Added on: 2024-11-22 10:00:45
Order Code: SA Student Ritik IT Computer Science Assignment(9_23_36575_369)
Question Task Id: 495059

COIT20245

Assignment 2

Due: End of week 10. Check the exact date and time in the submission area on the unit website.

Weighting: 30%

To be Submitted:

A zip file of the NetBeans Project with your assignment 1 application.

A Word document with your report (that includes testing)

Note that:

Your program must be submitted as a NetBeans project and must use Java 17 or the marker will not be able to test your work and no marks will be awarded.

No marks will be awarded if the assignment does not compile and run. Markers must be able to run and test your code to mark it. It is therefore essential that you develop the code incrementally and maintain a backup of your last working phase. If your last phase does not compile and run, then you must submit the previous phase that does compile and run. In addition, always check that you have submitted the correct work. (A good test is to download your submission and check it on a different machine.)

Introduction

In this assignment, you are to implement a console application that supports simple MAP (Mean Arterial Pressure) analysis functionality. A phased implementation approach is recommended and an outline for such an approach is provided in Appendix 1. The application is to be conformant with the class diagram provided in Figure 1.

The Application

The raw data to be analysed is to be stored in 3 arrays. Use array initialisers to specify initial values of your choosing. The 3 arrays are to contain person identifiers (string values), systolic blood pressure (SBP) and diastolic blood pressure (DSP). Both SBP and DSP are to be specified as int values. MAP is determined from an individuals blood pressure using the following formula:

MAP = 1.0/3.0 * SBP + 2.0/3.0 * DBP

The raw data is to be used to create objects of type PatientRecord, which are to be stored in an array of type PatentRecord. The PatientRecord class is to conform to the class shown in the UML Diagram below:

Figure 1. Class Diagram

Note that in Figure 1, the visibility of class methods and attributes are designated as + (public) and (private). Associations are annotated with a label (for readability) and multiplicity. The multiplicity captures the number of object instances that can be involved in the association. In this case, only two values apply 1 and *, which means many.

Your application must conform to the design in the UML class diagram or you will not be given a passing grade for the assignment. In this regard, note that no additional classes and/or public methods / variables are permitted. Public methods must have the same names, parameter lists and return types shown in the diagram. Accessors (public/private) must also correspond to the class diagram. You may add private helper methods (or additional private members although if you need additional class members you may not have understood the design). If you believe that there is something missing in the diagram please discuss this with the unit coordinator.

MAP is calculated as a floating point value and is to be stored in a variable of type double. In addition to the map attribute, PatientRecord also has a category attribute, which has values of high, medium and low. A normal mean arterial pressure is a value in the range 70 and 100 mmHg inclusive.

Category determination is to be provided as a separate (private) method called classify(). Creation of the PatientRecord array is to occur when the MAPAnalyser object is constructed, using a private method called loadFromTables(). This method will iterate through three separate arrays containing ids, systolic blood pressures and diastolic blood pressures, construct PatientRecord objects and add them to the data array. These arrays are to be populated using array initializers. Appendix 1 has the code for the loadFromTables() method, but note that it only populates the array with two PatientRecords. This is not sufficient to thoroughly test your code.

The list of PatientRecords is also to be sorted in ascending order of the MAP values for each patient. The sort method to achieve this is also to be invoked in the MAPAnalysers constructor (after the list has been built using loadFromTables().

The applications View class is to execute (using a switch statement) the following command options:

Display the record for a specified patientDisplay records for all patients with MAP values within a specified range.

Display the minimum, maximum, median and average MAP valuesDisplay all the patient recordsExit the applicationAs it is a console application, the user will need to be prompted to enter a command and its arguments (if any). You are to use the minimal interaction scheme, as illustrated below. First the menu will be displayed and then after that the user enters the choice with any additional information required for the menu option chosen. The prompt is a simple > symbol One of the options is to display the menu message again. In the example below, the user selects option 1 which requires a patient id (the patient to be found). The user input is highlighted in the screenshot below:

The output showing the details of the record is minimalist with the data displayed between <> as folows:

<id sbp dbp MAP category>

Note that:

Each command is designated a number.

Command 1 requires a single argument the patient id.

Command 2 requires 2 arguments the lower and upper bounds of a range of MAP values. The program is to display all the records >= the map1 value specified and <= the map2 value specified.

I have added a help command (command 0).

The command options are displayed at the start of the application and whenever a help command (option 0) is entered, rather than after each command.

Patient records are displayed (with no explanation of the fields) using PatientRecord.toString()

For a sorted list of values, if the number of values is odd, the median is the middle value. If the number of values is even, the median is the average of the two middle values.

For the commands that require arguments note that:

For commands 1 and 2, basic error checking is expected. For command 1, an error message (e.g. no patient record found) is to be displayed if an id does not exist. The command loop is to display this message if no record (i.e. a null reference) is returned from the find method. For command 2, an error message is to be displayed if the lower member of the range is < 0 or if the second member is > 200 or if the second member of a range is less than the first member. The range values are to be checked in the command loop and the find method should only be invoked if the range values are valid.

For command 2, the range is inclusive of the values specified. Consequently, having both members of a range equal is valid.

For command 2, the find() method is to find the records in the range specified. The results are to be stored and returned in an ArrayList. If there are no records found in the range specified, this find() method is to return null. If no records were found, then the command loop is to display an appropriate message (e.g. No records in this range found).

An appropriate message is to be displayed if the user enters an invalid command, followed by a display of the menu.

You can assume that if the user enters a 1, it will be followed by an id and if 2 is entered it will be followed by two numbers (separated with spaces).

The application must conform to the class diagram in Appendix 1, although additional private members and methods are permitted.

Submission

You are to submit two separate files:

Your zipped NetBeans project folder.

Report.docx. You must complete the report template supplied on the unit website. As you will see, this file is to contain the following Sections:

Limitations

Known bugsTest plan

Test results

Student name, student ID number, unit name and unit code are to be included on the title page.

The limitations section is to specify any limitations that your program has in terms of calculations and data validation.

The test plan is to contain a comprehensive list of program functionality to be tested, the input values (and patient record data) to be used to test each item of functionality, the expected output from the test and the actual output from the test.

The test results section is to contain screenshots to demonstrate that the program generates the actual outputs shown in the test plan.

Marking Criteria

Functionality

(and correct use of programming constructs)

Follows Design specified Code Documentation

& Layout Good coding practices

(Naming conventions, meaningful names, efficient code - see guide) Report

Limitations and Testing

(includes thorough test plan and test results) Total

Phase 1

(- correct structure with "dummy /stub methods - compiles and runs (no output) 2 6 1 2 11

Phase 2

- command loop works with data returned from "dummy/stub" methods. Data validation (as specified) 5 1 1 5 12

Phase 3

table populated and sorted. Option 4 implemented to display it. (Plus additional test data) 5 1 1 2 9

Phase 4: option 1

(find based on id) 3 1 1 2 7

phase 4: option 2 (find records in range) use ArrayList5 1 1 2 9

phase 4: option 3

(stats - max, min, average, median) 5 1 1 5 12

Total 25 11 6 18 60

Note:

The final mark will be converted to a mark out of 30. This assessment item is worth 30% of your marks.

It is your responsibility to ensure that source code files are included in your NetBeans project submission as well as your report.doc. Note: the report file must not be in the zip file. It must be uploaded as a separate .doc file to go through Turnitin.

Marks will be based on working code. No marks will be awarded for code that does not compileTo be awarded marks you must also follow the design specified (i.e. adhere to the design in the UML class diagram).

If you are aware of a bug in your code that you dont fix before submission, document this in the bugs section of the report. If the marker finds an undocumented bug you will lose the mark for the bug and also for poor testing and documentation. If it is documented you will only lose the mark for the bug.

Marks will be deducted for late submission. (-5% of the total possible marks for the assignment is deducted for each day late.)

Remember to:

1. Document the code see the guide about code documentation on the unit website. You must include a comment before every method and class header as well as the code in the body of methods when appropriate. The start of each class should include a description of the class and the author. Before each method there should be a comment to describe what the method does (not how), the parameters and any return values. You must use Javadoc comments to add this information to your code in this assignment.

2. Test the code thoroughly as you develop each phase.

3. Complete the report with your test plan and test results. Make sure it is clear what condition is being tested in each test case. See the documentation about testing and test plans on the unit website.

4. Follow good programming practices see the coding guidelines document on the unit website.

Note: Appendix 1 (with the details of each phase of development) begins on the next page.

Appendix 1

It is best practice to develop an application incrementally. The idea is that the work is broken up into phases, with each phase producing a working system. Furthermore, if a phase involves the provision of multiple functionalities, as in Phase 3 below, these should also be tackled incrementally. The advantage of this approach is that you have a series of working systems that you can demonstrate to the customer. In your case, it means that you can always submit a working system, albeit one perhaps with limited functionality. For this to work properly, you must save copies of your working versions as you go. This way of doing things is such a good idea (especially for team development) that software support is readily available in the form of version control systems such as SVN, GIT, CVS etc. However, we dont introduce you to version control until later in your course.

Given that you are provided with the class diagram., the following are the development phases you are to follow:

Phase 0

Read Section 2 very carefully and seek clarification from your tutor (or me) about anything that is unclear.

Phase 1.

Create all classes with members and dummy methods as per the class diagram. Where constructors set member variables via parameters, add code to do this. Leave void methods with an empty body. Where methods require a return value, just return a sensible type-consistent default value, as shown below for the MAPAnalyser public methods:

// these are all "dummy"/stub" methods that will have different bodies

// in later phases

public MAPAnalyser() {

numRecords = 0; patients = new PatientRecord[numRecords]; }

public PatientRecord[] getAllRecords() {

return patients; }

public PatientRecord find(String id) {

return null; }

public double lowestMAP() {

return 0; }

public double highestMAP() {

return 0; }

public double medianMAP() {

return 0; }

public double averageMAP(){

return 0; }

public ArrayList<PatientRecord> find(double map1, double map2) {

// no records found

ArrayList<PatientRecord> list = new ArrayList<>();

//initial dummy data

PatientRecord r = new PatientRecord("S0", 0, 0, 0, "low");

list.add(r); return list; }

Note that:

The find() is overloaded. In the dummy/stub methods, find(String) returns null, which is also a sensible return value if a record with the specified id is not found. For find(double, double ), an array list of length 1 is returned by the dummy/stub method. It has a dummy record to illustrate how to create the array list and add a record to the array list. When you implement the find method in a later phase, it is possible that there will be no records in the specified range. The commandLoop() method in the View class must be able to test for this situation and display an appropriate message if there were no records in the specified range.

The convention in Java is to make the return value of the toString() minimalist, as in:

<S01 90 120 110 high>

i.e. there is no naming of values.

The data between <> is:

<id sbp dbp MAP category>

Follow that convention when you write the PatientRecord classs toString() method.

In the main() method, add the following code:

MAPAnalyser a = new MAPAnalyser();

View v = new View( a );

v.commandLoop();// does nothing

Do not proceed to Phase 2 until this code compiles.

You now have an application that compiles but when it runs, no output will be produced. Also, we have not created any records. However, we do have an empty data array, which is an important test case.

Make a backup copy of this completed phase. It is important to make a backup of each completed phase (or subphase) before adding more functionality to your program. You should also get one phase working before adding the code for a subsequent phase. It is much harder to debug a program if you keep adding more code to a program that is not working. If you are having difficulties debugging a phase you should ask for help from the teaching team. Learning to debug is a very important skill to develop.

Phase 2.

Get the command loop working with the dummy methods.

The find methods will be unsuccessful; you will need to explicitly test the return values and display an appropriate message. The getAllRecords() method returns the whole array and is used to get the records to be displayed in option 4. The following shows a sample run for phase 2. The user input is highlighted.

Note: that the above tests do not represent a complete set of test cases for phase 2. What other input should be used to test everything that you have implemented in phase 2? What data validation were you told that you need to do (discussed earlier in this specification)?

Phase 3

You now need to populate the data array, i.e. the array called patients which is an array of PatientRecords. The loadFromTables() method is provided below. This method is responsible for loading the patient data from array initialisers, creating the PatientRecord for each patient and adding the reference to the PatientRecord to the patients array.

However, in the example below the array initialisers only have the data for two patient records.

It is your responsibility to populate the array initialisers with appropriate test data designed to test your program thoroughly. You may need to test your code with more than one set of test data to do this. For example, you will require two different sets of data to check that finding the median MAP works both when there is an even number of patient records and when there is an odd number of patient records.

Add the following private loadFromTables() method to your MAPAnalyser class.

private void loadFromTables() {

String[] ids = {

"S10", "S15"

};

int[] sbps = {

90, 110

};

int[] dbps = {

70, 60

};

numRecords = ids.length;

patients = new PatientRecord[numRecords];

for (int i = 0; i < numRecords; i++ ) {

double map = (1.0/3.0 *sbps[i]) + (2.0/3.0*dbps[i]); String category = classify( map );

PatientRecord record = new PatientRecord(ids[i],sbps[i],dbps[i],map,category );

patients[i] = record;

}

}

Note that for loadFromTables to work you must also write the classify() method in the MAPAnalyser.

Remember that the loadFromTables() method must be invoked in the MAPAnalysers constructor.

Replace the dummy code in the phase 1 constructor with an invocation of the loadFromTables() method.

Once the array is populated, you must test that it has been populated correctly by displaying its contents.

Implement option 4 from the menu now so that you can use it to check the contents of your array. The getAllRecords() method is to return the reference to your patients array. In the View classs command loop you must display the contents of the array returned by calling the getAllRecords() method (or an appropriate message if the array is empty). You can make use of the PatientRecord classs toString() method to display each patient record in the array in turn. Note that there is no need to call the toString() method explicitly. It will be called implicitly whenever a string representation of an object is required.

Next sort the array of patient records according their MAP values. This requires you to implement the private sortByMAP() method in the MAPAnalyser class, then use it to sort the array in the MAPAnalysers constructor after loadFromTables() has been called. In this assignment you are required to write the code for the sort method. You are to implement your sortByMAP() method using either the selection sort or insertion sort algorithm we have covered in lectures.

Check that your array has been sorted correctly by outputting the array using option 4.

Phase 4

To complete the assignment you next have to implement (and test) the code for the following options (in no particular order):

Option 1 to find and display a patient record with a specific id (or display the not found message if there is no such record)

Option 2 to find and display all the records with MAP values in a specified range (or display an appropriate message if no such records exist)

Option 3 display the statistics

You should implement and test one option at a time. That means implementation (and testing) of each option is effectively a subphase of phase 4. You can implement these options in whatever order you choose. Remember to save a backup of each subphase.

COIT20245 Programming Assignment 2

(Assessment item 2)

Student ID Student Name This coversheet must be completed with your submission.

Please check (X) to indicate that you have satisfied these requirementsThis work and my programming submission are my original work and no part of it has been copied from any other students work or any other source.

No part of this work or my code has been written for me by any other person/student/software program.

I have taken proper and reasonable care to prevent this work and my code from being copied by another student.

I acknowledge that it is my responsibility to check that the file submitted is readable and complete and that the code submitted can be uploaded in NetBeans and will compile and run correctly.

I understand that plagiarism also includes the act of assisting or allowing another person to plagiarise or to copy my own work.

Instructions

A description of what is required in each section is shown in italics. Please remove all the instructions from your final report.

Description of the Program and Phase Completed

<this is to be a brief description of the completed, working phase you have submitted. It is to describe the functionality of the submitted program. It is not intended to be for a programmer, but for a user or a customer. >

For example:

Phase 2 all phase 2 functionality has been completed. (Although, ideally you should be submitting a completed final phase.)

This program .. <a description of what the program does goes here>

Testing

<This section is to have the description of your test plan and then the results showing the actual behaviour of your program when you carry out the tests. Always show the test data used and if your application uses files, include the data in input/output files.>

Different phases will have different checks/tests that will be required (including a repeat of the checks from earlier phases to make sure earlier functionality is still working when you complete a new phase). As a result, this list of test cases will increase as you develop each phase.

Test Plan

<You are to list all the test cases that you will employ to convince yourself that your program is working correctly (both general/normal and special conditions). Explain how you will perform the test (including any test data used) and the expected behaviour and output / results>

Test Output (result of testing)

<Screenshots of each of your tests to demonstrate the different functions are working as specified and the result of the test (i.e. pass/fail) i.e. was the actual output the same as the expected output for that data). Include test cases that show special cases behave correctly (e.g. screenshots with error/warning messages for the boundary/special conditions and checks that any data validation is carried out correctly as well as general cases. (For e.g. if searching for something in a list you should have cases to test item found, item not found, item is the first element in a list, item is the last element in a list, item is an element in the middle of the list and the program behaves sensibly with an empty list.)>

Bugs and Limitations

Bugs

<Either state no known bugs or describe any bugs you are aware of in your code>

For example, you may have statements similar to the following:

Either

No known bugs

Or

you may still have problem (s)/bugs that you have to report if you did not have time to fix a bug.

Hopefully you will have no known bugs to report, but if you do have bugs and do not report them here, you will lose marks for the bug in the code and you will lose marks for inadequate testing (as well as losing the mark for not documenting known bugs)

Limitations

<any limitations in your program>

Additional Future Work

<What extensions would be useful in this application in the future?>

  • Uploaded By : Pooja Dhaka
  • Posted on : November 22nd, 2024
  • Downloads : 0
  • Views : 170

Download Solution Now

Can't find what you're looking for?

Whatsapp Tap to ChatGet instant assistance

Choose a Plan

Premium

80 USD
  • All in Gold, plus:
  • 30-minute live one-to-one session with an expert
    • Understanding Marking Rubric
    • Understanding task requirements
    • Structuring & Formatting
    • Referencing & Citing
Most
Popular

Gold

30 50 USD
  • Get the Full Used Solution
    (Solution is already submitted and 100% plagiarised.
    Can only be used for reference purposes)
Save 33%

Silver

20 USD
  • Journals
  • Peer-Reviewed Articles
  • Books
  • Various other Data Sources – ProQuest, Informit, Scopus, Academic Search Complete, EBSCO, Exerpta Medica Database, and more