title: Does this contain Polymorphic references? If not, how could it be implemented?
body: <p>I am not too familiar with polymorphism, and was wondering if I have it used in my code?</p>
  <p>If this doesn't contain a polymorphic reference, could you lead me in a direction of where I would need to go? The files that the program is using are not included, as I am mainly curious about whether or not any polymorphic references are used.</p>
  <p>java file 1 - this file runs the program</p>
  <pre><code>import java.util.Scanner;
  
  public class ADTDemo {
  
     ADTDictionary dictionary;
     
     public static void menu() {
  
         System.out.println(&quot;Welcome the Faculty Directory Program&quot;);
         System.out.println(&quot;  Use commands:&quot;);
         System.out.println(&quot;  list all&quot;);
         System.out.println(&quot;  list DEPT_NAME&quot;);
         System.out.println(&quot;  add DEPT_NAME, FIRST LAST&quot;);
         System.out.println(&quot;  remove DEPT_NAME, FIRST LAST&quot;);
         System.out.println(&quot;  exit&quot;);
     }
  
     public static void main(String[] args) {
         menu();
         String command;
         ADTDemo dictObj = new ADTDemo();
         dictObj.dictionary = new ADTDictionary();
         dictObj.dictionary.read();
         Scanner scanner = new Scanner(System.in);
         
         do {
             System.out.println(&quot;&quot;);
  
             System.out.print(&quot;&gt;&gt;&quot;);
             command = scanner.nextLine().trim();
  
             if (!command.equals(&quot;exit&quot;)) {
                 dictObj.action(command);
             } else {
                 dictObj.dictionary.saveEntries();
                 System.out.println(&quot;Goodbye! Have a nice day!&quot;);
             }
  
         } while (!command.equalsIgnoreCase(&quot;exit&quot;));
     }
  
     public void action(String command) {
         if (command.equalsIgnoreCase(&quot;LIST ALL&quot;)) {
  
             dictionary.listAll();
             return;
         }
         else if (command.toUpperCase().contains(&quot;LIST&quot;)) {
             if (command.length() == 4){
                 System.out.println(&quot;Command needed.&quot;);
                 return;
             }
             command = command.substring(5, command.length());
             dictionary.listDeptName(command);
             return;
         }
         else if (command.toUpperCase().contains(&quot;ADD&quot;)) {
             command = command.substring(4, command.length());
             dictionary.add(command);
             return;
         }
         else if (command.toUpperCase().contains(&quot;REMOVE&quot;)) {
             command = command.substring(6, command.length());
             dictionary.remove(command);
         }
     }
  }
  </code></pre>
  <p>java file 2</p>
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import java.util.Scanner;
  
  public class ADTDictionary {
     Map&lt;String, List&lt;String&gt;&gt; adtDictionary;
     
     public void read() {
         try {
             File facultyFile = new File(&quot;faculty.txt&quot;);
             File departmentFile = new File(&quot;departments.txt&quot;);
             
             Scanner departmentScanner = new Scanner(departmentFile);
             Scanner facultyScanner = new Scanner(facultyFile);
  
             adtDictionary = new HashMap&lt;String, List&lt;String&gt;&gt;();
  
             while (departmentScanner.hasNextLine()) {
                 String department = departmentScanner.nextLine().trim();
                 adtDictionary.put(department, new ArrayList&lt;String&gt;());
             }
  
             while (facultyScanner.hasNextLine()) {
                 String faculty = facultyScanner.nextLine();
                 String[] values = faculty.split(&quot;,&quot;);
                 adtDictionary.get(values[1].trim()).add(values[0]);
             }
  
         } catch (FileNotFoundException ex) {
              System.out.println(&quot;ERROR: File not found.&quot;);
         }
     }
  
     public void listAll() {
         for (String key : adtDictionary.keySet()) {
             for (String value : adtDictionary.get(key)) {
                 System.out.println(value + &quot;, &quot; + key);
             }
         }
     }
     
     public void listDeptName(String department) {
         if (null != adtDictionary.get(department)) {
             for (String name : adtDictionary.get(department)) {
                 System.out.println(name);
             }
         }
         else{
             System.out.println(&quot;Unknown entry made.&quot;);
         }
     }
  
     public void add(String value) {
         if(!value.contains(&quot;,&quot;)){
             System.out.println(&quot;Incorrect entry.&quot;);
             return;
         }
         String[] values = value.split(&quot;,&quot;);
         String dept = values[0].trim();
         String faculty = values[1].trim();
         
         String[] facName = faculty.split(&quot; &quot;);
         
         if (!(facName.length == 2)){
             System.out.println(&quot;Please only enter First and Last name of faculty member.&quot;);
             return;
         }
          
          if (!(null != adtDictionary.get(dept))) {
              if(adtDictionary.containsKey(dept.toUpperCase())){
                  System.out.println(&quot;Incorrect departtment entry.&quot;);
                  return;
              }
              else if (dept == dept.toUpperCase()){
                  adtDictionary.put(dept, new ArrayList&lt;String&gt;());
              }
              else{
                  System.out.println(&quot;Incorrect department entry.&quot;);
                  return;
              }
          }
          
         for (String name : adtDictionary.get(dept)) {
             if (name.equalsIgnoreCase(faculty)) {
                 System.out.println(&quot;Cannot add &quot; + name + &quot; to &quot; + dept + &quot; because they already exist there.&quot;);
                 return;
             }
         }
         adtDictionary.get(dept).add(faculty);
         System.out.println(&quot;OK, added &quot; + faculty);
     }
  
     public void remove(String value) {
         String[] values = value.split(&quot;,&quot;);
         String dept = values[0].trim();
         String faculty = values[1].trim();
         
         adtDictionary.get(dept).remove(faculty);
         System.out.println(&quot;OK, removed &quot; + faculty + &quot; from &quot; + dept);
     }
     
     public void saveEntries(){
         try {
              File facultyFile = new File(&quot;faculty.txt&quot;);
              File departmentFile = new File(&quot;departments.txt&quot;);
              
              PrintWriter facWriter = new PrintWriter(facultyFile);
              PrintWriter deptWriter = new PrintWriter(departmentFile);
              
              for (Object s : adtDictionary.keySet()) {
                  deptWriter.println(s);
              }
              deptWriter.close();
                  
                  
              for (String key : adtDictionary.keySet()) {
                  for (String value : adtDictionary.get(key)) {
                      facWriter.println(value + &quot;, &quot; + key);
                  }
              }
              facWriter.close();
          }
          catch (IOException ex){
                  System.out.println(&quot;ERROR saving file.&quot;);
          }
     }
  }
  
  </code></pre>