Class ZooProcessing

Object
ZooProcessing

public class ZooProcessing extends Object
This class is where all zoo database processing occurs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) ArrayList<Fauna>
    ArrayList that holds Fauna, which includes all classes that extend the Fauna class.
    (package private) ArrayList<Flora>
    ArrayList that holds Flora, which includes all classes that extend the Flora class.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addOrganism(String organismLine)
    Add an organism object depending on what kind of organism it is.
    void
    After the ArrayLists have been populated, users can interact with the lists by displaying a random fact, or the current organism counts by type, or they can exit.
    void
    This function displays the counts for flora and fauna in the CSV file.
    void
    This is just a helper method to display user options.
    void
    processFile(String fileName)
    Reads a local CSV file, using the fileName parameter.
    void
    Randomly selects the flora or fauna list, the selects a random entry and prints its species and fun fact!

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • floraList

      ArrayList<Flora> floraList
      ArrayList that holds Flora, which includes all classes that extend the Flora class.
    • faunaList

      ArrayList<Fauna> faunaList
      ArrayList that holds Fauna, which includes all classes that extend the Fauna class.
  • Constructor Details

    • ZooProcessing

      public ZooProcessing()
  • Method Details

    • processFile

      public void processFile(String fileName)
      Reads a local CSV file, using the fileName parameter. For each line in the CSV file, a new organism is created and added to either the Flora or Fauna list. The creation and addition of organisms is handled by addOrganism();
      Parameters:
      fileName -
    • interact

      public void interact()
      After the ArrayLists have been populated, users can interact with the lists by displaying a random fact, or the current organism counts by type, or they can exit.
    • addOrganism

      public void addOrganism(String organismLine)
      Add an organism object depending on what kind of organism it is. Do this by extracting information about the organism from the CSV file. Using a line that was read in from the CSV file, the values in-between the comma's in this line hold important information, such as whether the organism is a Flora/Fauna, the species, and category to name a few.

      An example of a provided organismLine parameter:

            Fauna,Fish,Blind Cave Fish,Astyanax mexicanus,Central America,To compensate for their lack of sight, these fish have a more sensitive lateral line system to detect vibrations.
            Flora/Fauna,Category,Species,Scientific name,Continent of origin,A fun fact!
       
      As you can see, each piece of information is seperated by a comma, so our commas will function as our delimiters! Once you have identified whether the organism is a flora or fauna then find the category that organism belongs to, such as if a listing is a flora, it must be an angiosperm, fern, gymnosperm, or moss. Depending on the category, use the corresponding class constructor to create that object and add it to the floraList or faunaList. The parameter you provide to the Angiosperm, Moss, Bird, Invertebrate will be the provided organismLine.
      Parameters:
      organismLine -
    • randFact

      public void randFact()
      Randomly selects the flora or fauna list, the selects a random entry and prints its species and fun fact!
    • listCounts

      public void listCounts()
      This function displays the counts for flora and fauna in the CSV file. The total number of each organism category is also displayed. So for each organism that belongs to a certain category or class, the number of angiosperms, fish, etc. is incremented for however many exist in each ArrayList. Each CSV file will contain a list of flora organisms you should iterate through as well as a list of fauna organisms you should iterate through.

      If a CSV file contained 3 entries of Ferns and one of each Fauna, the output from this method would look like so:

            Flora Count: 3
            Angiosperm count: 0
            Fern count: 3
            Gymnosperm count: 0
            Moss count: 0
      
            Fauna Count: 6
            Amphibian count: 1
            Bird count: 1
            Fish count: 1
            Invertebrate count: 1
            Mammal count: 1
            Reptile count: 1
       
      The additional information section may have some assistance if you find yourself stuck.
    • printSelections

      public void printSelections()
      This is just a helper method to display user options.