Advertisement
Guest User

input

a guest
Feb 17th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. package com.directory;
  2.  
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5. import java.util.Scanner;
  6.  
  7. public class Input {
  8.  
  9. static void importUsingCsvFile(String filepath, Directory directory) throws IOException {
  10.  
  11. // opens the file provided by user
  12. FileReader fr = new FileReader("com/directory/test_data.csv");
  13.  
  14. // reads the file
  15. Scanner source = new Scanner(fr);
  16.  
  17.  
  18. // while the source has lines to read
  19. while (source.hasNext()) {
  20.  
  21. // splits each line with commas and put them into a string array
  22. String[] s = source.nextLine().split(",");
  23.  
  24. // checks if the extension length is correct
  25. if (s[2].length() == 5) {
  26.  
  27. // new object is created for each new entry. using their surnames, initials, and extension
  28. directory.insertEntry(new Entry(s[0], s[1], s[2]));
  29.  
  30. }
  31.  
  32. }
  33. System.out.println("Entries added to directory successfully!");
  34.  
  35. // closes the the file reader to free the resources.
  36. fr.close();
  37. }
  38.  
  39.  
  40.  
  41.  
  42.  
  43. static void insertStaff(Directory directory) {
  44. System.out.println("Please write the surname>");
  45. String surname = Main.scannerMethod();
  46. System.out.println("Please write the initials>");
  47. String initials = Main.scannerMethod();
  48. System.out.println("Please write the telephone extension>");
  49. String extension = Main.scannerMethod();
  50. directory.insertEntry(new Entry(surname,initials,extension));
  51.  
  52. }
  53.  
  54. static void deleteStaffUsingSurname(Directory directory){
  55.  
  56. }
  57.  
  58. static void deleteStaffUsingExtension(Directory directory){
  59.  
  60. }
  61.  
  62. static void updateEntryExtensionUsingName(Directory directory){
  63.  
  64. }
  65.  
  66. static void lookupUsingExtensin(Directory directory){
  67.  
  68. }
  69.  
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement