Answered step by step
Verified Expert Solution
Link Copied!

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:

  1. 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:
  1. A constructor that accepts the information about one item and assigns it to the instance data of the method.
  2. 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.
  3. Keep all of the Gets and Sets. There should be one of each for each field in the Unit of One Class.
  1. Create another Class that instantiates an array of the Unit of One Objects with the following methods:
  1. Create an array of the Objects from the Class of the Unit of One.
  2. Create a constructor to initialize the number of items in the array to zero.
  3. Create a method to add one item at a time to the array.
  4. Create a method to display the contents of the entire array. Call this method toString.
  5. Create a method to increase the size of the array if it is getting full.
  6. Include the method that reads the data from the external file and populates the Array of Objects.
    1. Remember - when the program first executes - open the file, read from the file and populate the array, then close the file.
  7. 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.
    1. 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:

  1. Add a method that will Sort the data in your Array of Objects.
    1. Write your code from the Selection Sort algorithm in the lecture.
    2. Pick one default field to sort the data by.
  2. Display a menu that will allow the User to select at least one other field to sort the data by.
  3. 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:
    1. Add an item to the array.
    2. Update an item in the array.
    3. Print out the list of all items.
    4. Sort the list.
    5. 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

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions