Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO NOT USE ARRAYLISTS. KEEP IN MIND THAT I AM COMPILING THE CODE ON A MACBOOK. Imagine you work for the Federal Department of Health

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

DO NOT USE ARRAYLISTS. KEEP IN MIND THAT I AM COMPILING THE CODE ON A MACBOOK.

Imagine you work for the Federal Department of Health and Human Services and you are their lead data manager. One day the Secretary of HSS comes to you with a .csv file of records of some people and wants you to store them in the system. The .csv file contains the names of some citizens, their sex, age, height in inches, and weight in pounds. You have to read the .csv file and store all the data in an array (DO NOT use an ArrayList). The .csv file is provided to you with the pdf on blackboard. The one provided to you is different from the ones we will use for testing! The file is sorted by name. You have to read the file, print after storing it and giving options to manipulate it, and lastly, save it to a .csv type file to be processed again. Make a program that can run on its own and does not crash. Use exception handling as required. If the program does not compile, you will receive a 0 for it. You have to write all the CODE BY YOURSELF. Any form of plagiarism will result in 0 in the homework and possibly even a Q for the course. Required Classes: The following classes are required for this assignment. Each class provides a description and the specifications necessary to complete its implementation. If you feel that additional methods or variables would be useful, feel free to add them during your implementation as you see fit. However, all the variables and methods in the following specifications must be included in your homework. You should declare the data fields of the classes as private and should provide the public getter and setter methods if required. 1. Person Write a fully documented class named Person that contains biological statistics of each person in the .csv file provided. The Person class should contain variables for the person's name, age, gender, height, and weight. In addition, it should also implement the toString () method, which should print all of the person's data in tabular form. - public Person( ) constructor and also public Person(...parameters as needed...) - One int variables: o age - Two double variables: height weight - Two String variables: - name 0 gender - public String toString( - returns string of data members in tabular form. - Getters and setters for all members. 2. PersonDataManager Write a fully documented class named PersonDataManager that reads the .csv file and creates Person objects that are later stored in an array. In addition to that, you should print the data from the array as a table. - An array: Person[] people; (base the size on the number of people in the document to be read) - public static void buildFromFile (String location) throws IllegalArgumentException - Brief: - Uses the File class to read the .csv file and store the information in a data structure (Person[] people) Parameters: - location - File path of the file to be read as a String. Preconditions: - Valid file path Postconditions: - None. Returns: - The PersonDataManager constructed from the .csv file. Throws: - IllegalArgumentException: Thrown if the data entered is in the wrong format. For example, there is a letter in height or a number in the person's name. - public void addPerson (Person newPerson) throws PersonAlreadyExistsException Brief: - Adds the Person object in the data structure chosen in the correct alphabetical order that the list is in. If the array you are using is entirely full, create a new array with more space and copy the elements in the other array to this array. Use the bigger assay as the new array. Parameters: - newPerson - Person object to be added. Preconditions: - The person does not exist in the list. Postconditions: - The person is added to the list. Returns: - None. Throws: - PersonAlreadyExistsException: Thrown if a person with all the same biological statistics already exists in the list. - public void getPerson (String name) throws PersonDoesNotExistsException Brief: - Retrieves and prints the data of the Person object from the data structure chosen. Parameters: - name - Name of the Person object to be printed. Preconditions: - The person with the given name exists. Postconditions: - None. Returns: - None. Throws: - PersonDoesNotExistsException: Thrown if a person with the given name does not exist. - public void removePerson (String name) throws PersonDoesNotExistsException Brief: - Removes the Person from the data structure chosen. Parameters: - name - Name of the Person object to be removed. Preconditions: - The person with the given name exists. Postconditions: - None. Returns: - None. Throws: - PersonDoesNotExistsException: Thrown if a person with the given name does not exist. - public void printTable() Brief: - Prints the PersonDataManager in tabular form. 3. PersonManager Write a fully documented class named PersonManager. This class will allow the user to interact with the database by listing the people, adding to the list, removing, and retrieving people from the list. - A PersonDataManager variable: - personDataManager - public static void main (String [] args) - Brief: - This method should implement the following menu options: (I) - Import from File - (A) - Add Person - (R)-Remove Person - (G) - Get Info on Person - (P) - Print Table - (S)-Save to File - (Q)-Quit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions