Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java, Using the included program below: Create a Class for the Unit of One of your database. The information for this Class must include
In Java,
Using the included program below:
- Create a Class for the Unit of One of your database. The information for this Class must include a minimum of 3 fields. Within the Class, include the following methods:
- A constructor that accepts the information about one item and assigns it to the instance data of the method.
- A method that prints the information about one item of your collection. Name this method toString. NOTE: It is important that you name this method toString because it's one of Java's built-in methods that allows you print out your Object.
- Keep all of the Gets and Sets. There should be one of each for each field in the Unit of One Class.
- Create another Class that instantiates an array of the Unit of One Objects with the following methods:
- Create an array of the Objects from the Class of the Unit of One.
- Create a constructor to initialize the number of items in the array to zero.
- Create a method to add one item at a time to the array.
- Create a method to display the contents of the entire array. Call this method toString.
- Create a method to increase the size of the array if it is getting full.
- Include the method that reads the data from the external file and populates the Array of Objects.
- Remember - when the program first executes - open the file, read from the file and populate the array, then close the file.
- Include the method that writes the Array of Objects to the same external file. Remember - do not use toString when writing the data to the external file.
- Remember - when the user selects Exit from the menu - open the file, write to the file, then close the file.
B. Add the following requirements:
- Add a method that will Sort the data in your Array of Objects.
- Write your code from the Selection Sort algorithm in the lecture.
- Pick one default field to sort the data by.
- Display a menu that will allow the User to select at least one other field to sort the data by.
- DO NOT use any of Java's built-in sorting methods. YOU MUST write your own using the Selection Sort algorithm discussed in the lecture.
C. Be sure to also include the following:
- Create a Driver Class with a Menu with the following options displayed like so:
- Add an item to the array.
- Update an item in the array.
- Print out the list of all items.
- Sort the list.
- Exit.
- Include a sub-menu for Sort option that allows the User to select which field they wish to sort by.
- When your program is first executed, read data from an external file and place it in your array. Include a minimum of 5 sets of data in the file. Submit the external file with your program.
- Save the data back to the external file when the Exit option is chosen from the menu in the Driver.
NOTE: You MUST read your data from an external file! You MUST save your data back to that SAME external file when done.
Download link to program: https://www.dropbox.com/s/eqp42kdh694m0fn/Dog.zip?dl=0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started