Reference no: EM132362124
Assignment
1. Objectives
The purpose of this assessment item is to assess your skills attributable to the following learning outcomes and achieving the expected graduate attributes of advanced level knowledge, cognitive, technical, and creative skills, and self-management.
Design and implement appropriate data structures for application development
Analyse, develop and implement software solutions with the focus on data structures and algorithms
Apply classes, inheritance, polymorphism, and exception handling
2. Assessment Task
In this assignment, you are required to write a Java Application that uses an interactive Graphical User Interface (GUI) based on the JFrame class using SWING GUI components. You will also be designing and implementing the software solution using appropriate data structures and application of classes, inheritance, and exception handling. The case study for developing a solution is given below.
The food consumption of a person is to meet the daily energy requirements. The energy requirement is estimated using a person’s age group, gender, height, weight, basal metabolic rate (BMR), and physical activity level (PAL). There are data available on estimated energy requirements for various Pals and BMR. So, by choosing the correct age group, gender, height and PAL, the energy requirements can be found from the data set.
Your task is to develop a Java Application that lets the user enter height and choose gender, age group, and the most suitable PAL so that the application displays the energy requirements in Mega Joules. The application should contain a GUI as outlined below. The GUI components should consist of the following panels.
i. A top panel that contains four (4) Text Fields, one Password Field, two ComboBoxes (drop down list), seven Labels, and two Radio Buttons and a Login command button.
ii. A middle panel that contains a Text area to display the user’s estimated energy requirement details.
iii. A bottom panel that contains four buttons which are Load Data button, Display Energy button, Clear Display button and Quit button.
The functions of the four buttons are described below.
A. Load Data
Initially the Load Data button remains disabled; in order to enable it, the user needs to click on the Login button after entering the name and the password to the designated fields on the GUI. You may use a suitable name such as Smith or something and a password. You should clearly mention your password in your report and java file comment so that your program can be tested for marking.
Screenshots are not provided so that you can interpret the requirements and specification, sketch the design, and implement the design precisely. The Load Data button can be used to read the data file which contains height, weight, BMR, and energy requirements for various PALs for males and females in the age groups of 19-30 and 31-50.
The data file is Data provided for you in the moodle. After loading the data file upon the user’s click on the Load Data button, the ComboBox on the GUI needs to be filled with the description of PAL as given in the table below. Also, the Age group ComboBox on the GUI needs to be filled with the list of age groups read from the file. One row in the file contains data for one age group, but for both genders. Reading the assignment specification and contemplating over the data file content will give you insight to sketch the design for proper implementation.
B. Display Energy
Before clicking on the Display Energy button, the user has to enter his/her height, for example, 1.7 meter in the Text Field; choose the gender, for example, male by clicking the Radio button; and select the age group, for example, 31-50. This should display the ‘Expected Average Weight’ of 63.6 kg in the Text Field for that height as provided in the data file.
When the user clicks the Display Energy button after selecting a suitable PAL description, for example, Vigorous from the drop down list, the corresponding PAL number such as 2.2 should be displayed on the Text Field; and energy requirements of 14.8 Mega joules along with age group of 31-50, PAL description of Vigorous, PAL number of 2.2, and expected average weight of 63.6 kg should be well-worded, well-indented, and displayed in the Text Area. For the clarity, the above description uses a running example; however your program should appropriately output for any input.
C. Clear Display
Clicking on the Clear Display button should clear all contents from the display area and set the TextFields and ComboBoxes to their default values.
D. Quit
The Quit button should allow the user to exit from the application.
3. Data Structures
You can use the classes given below as a guideline for your design.
i. enum PAL -Physical Activity Level
The descriptions and corresponding values of PALs are modelled as an enum.
This is provided for your use in the moodle as PAL.java.
ii. PALdata class
This is to store the PAL and corresponding energy requirement. This class is already provided for your use in the moodle as PALdata.java
iii. BMRdata class
The purpose of this class is to store the values of age group, gender, height, weight, and bmr read from each row of the file.
a. Include appropriate fields to store:
height, weight, bmr which are real numbers to be stored in double data type, age group and gender which are strings.
b. A constructor and necessary accessor and mutator methods to get and set values
c. A toString() method that displays the BMRdata attributes.
iv. EnergyData class
a. This class should have the fields to store:
BMRdata, and set of energy needs for various PALs corresponding to the BMRdata. This could be stored as an ArrayList of PALdata.
b. It should also include constructor, mutator, and accessor methods
c. A toString()method for displaying the stored data.
v. User class–an abstract class
This class should have
a. Fields to store user-entered values such as name, gender, age group, and height.
b. Constructor, accessor and mutator methods
c. A toString() method for displaying the User details.
vi. UserEnergyNeeds class
This class extends the User class. This class should have member fields to store expected average weight, bmr corresponding to the user’s age group, gender and height, and the PALdata to store chosen PAL and corresponding energy requirement. The height entered should be between 1.5 and 2m inclusive. Use validation and exception handling to handle this error.
vii. GUI Components class
This class should have the GUI components listed above.
a. It should have the methods to set up the GUI components and the event handling methods.
b. This class should have method to read data from the file and load data structures appropriately.
c. This also contains main method.
4. Coding
You can build your application using NetBeans. It is highly recommended that you create the GUI components using code rather than 'designer' and 'click and drag' of the NetBeans. This ('designer' and 'click and drag' of the NetBeans) creates code which is not maintainable.
Remember, this is a good prototyping tool, but not recommended for coding. Commence with one class at a time, test it and then incrementally add the next.
Follow good coding practices by using meaningful names, camel case notation for naming, constants to avoid numbers inside the body of the methods, as necessary. You should follow the Java Coding Standards that you can find under the section of Unit Resources. Include
meaningful comments.
Attachment:- Data File.rar