Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.directory;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Scanner;
- public class Input {
- static void importUsingCsvFile(String filepath, Directory directory) throws IOException {
- // opens the file provided by user
- FileReader fr = new FileReader("com/directory/test_data.csv");
- // reads the file
- Scanner source = new Scanner(fr);
- // while the source has lines to read
- while (source.hasNext()) {
- // splits each line with commas and put them into a string array
- String[] s = source.nextLine().split(",");
- // checks if the extension length is correct
- if (s[2].length() == 5) {
- // new object is created for each new entry. using their surnames, initials, and extension
- directory.insertEntry(new Entry(s[0], s[1], s[2]));
- }
- }
- System.out.println("Entries added to directory successfully!");
- // closes the the file reader to free the resources.
- fr.close();
- }
- static void insertStaff(Directory directory) {
- System.out.println("Please write the surname>");
- String surname = Main.scannerMethod();
- System.out.println("Please write the initials>");
- String initials = Main.scannerMethod();
- System.out.println("Please write the telephone extension>");
- String extension = Main.scannerMethod();
- directory.insertEntry(new Entry(surname,initials,extension));
- }
- static void deleteStaffUsingSurname(Directory directory){
- }
- static void deleteStaffUsingExtension(Directory directory){
- }
- static void updateEntryExtensionUsingName(Directory directory){
- }
- static void lookupUsingExtensin(Directory directory){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement