Java Collections

Objective

Create a menu driven program that will allow the developer and/or team to practice utilizing ArrayLists and HashMaps.

Skills Required

  • Object Oriented Programming
  • ArrayList
  • Hashmaps
  • Console I/O
  • IDE familiarity
  • Basic types
  • If statements
  • Equality operators
  • Loops

Iterations

Build the application in the following small iterations. It should function at completion of each iteration!

  1. Create an application named CollectionsApp

  2. Create a separate class named ArrayListUtils. ArrayListUtils will contain all method functions for the ArrayList menu options

  3. Create a separate class named HashMapUtils. HashMapUtils will contain all method functions for the HashMap menu options

  4. In CollectionsApp, create a menu driven console interface that will allow the user to choose to perform the following functionalities:

    • Give the user the option of ArrayList, HashMap, or Quit.

      • If ArrayList is chosen, give the user the option String or Integer.
      • If Hashmap is chosen, key value pair defaults to Integer String
      • User must be forced to make a choice.
      • Menu options associated with String or Integer should only display for those selections

    ArrayList

    • If option is String, perform the following functionalities as menu selections:

      • Populate an ArrayList with words(min:10, max: 25). This option should be the only option to be available until the ArrayList is populated. Once the ArrayList has been populated, display all the other options
      • Display all the words to the console
      • Display all the words that are plurals and capitalize them
      • Display all the words in reverse order

      Stretch Method Functions:

      • Display all the words that are not plural
      • Add stars in between each word
      • Remove the stars from in between the words.
        This option should become visible only once stars have been placed in between the words
    • If option is Integer, perform the following functionalities as menu selections:

      • Populate an ArrayList with 100 random numbers. This option should be the only option to be available until the ArrayList is populated. Once the ArrayList has been populated, display all the other menu options
      • Display the average of the numbers
      • Display the highest and lowest numbers
      • Filter out all of the even numbers

    HashMap

    • Populate the HashMap with key-value pairs.
      The key should start at 100 and increment each key by 3. The value will be user inputted words(min:10 max:15) This option should be the only option to be available until the HashMap is populated. Once the HashMap has been populated, display all the other menu options

      • Display all the key-value pairs
      • Retrieve a value associated with a given key
      • Check whether a particular key-value pair exists