From 901b9a702d1006e4972fddea887a8123fd89a54d Mon Sep 17 00:00:00 2001 From: owleyeview Date: Thu, 13 Oct 2022 21:16:09 -0700 Subject: [PATCH] initial commit --- .gitignore | 29 ++++++++++++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ .idea/workspace.xml | 92 +++++++++++++++++++++++++++++++++++++ phone-book.iml | 11 +++++ src/PhoneBookManager.java | 92 +++++++++++++++++++++++++++++++++++++ src/PhoneBookNode.java | 96 +++++++++++++++++++++++++++++++++++++++ src/TestClass.java | 11 +++++ 9 files changed, 351 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 phone-book.iml create mode 100644 src/PhoneBookManager.java create mode 100644 src/PhoneBookNode.java create mode 100644 src/TestClass.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e0844bc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0dba06f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..5bb54d2 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1665714511306 + + + + + + + \ No newline at end of file diff --git a/phone-book.iml b/phone-book.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/phone-book.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/PhoneBookManager.java b/src/PhoneBookManager.java new file mode 100644 index 0000000..0dc7e4e --- /dev/null +++ b/src/PhoneBookManager.java @@ -0,0 +1,92 @@ +import java.util.*; + +public class PhoneBookManager { + + + + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + + displayIntroMessage(); + String command; // input variable + boolean done = false; // boolean flag + do { + displayMenu(); + command = s.nextLine().toLowerCase(); // accept an input command + switch (command) { + case "a": + addEntry(s); + break; + case "m": + modifyEntry(s); + break; + case "b": + displayBellingham(); + break; + case "s": + displaySeattle(); + break; + case "q": + done = true; + break; + default: // valid input commands not found + System.out.println("Invalid command. Select from the commands above."); + break; + } + } while (!done); + } + + // introduction to the program + public static void displayIntroMessage() { + System.out.println("============================================"); + System.out.println("===== WELCOME TO YOUR LOCAL JAVA PAGES ====="); + System.out.println("============================================"); + System.out.println("==== Your directory of all that matters ===="); + System.out.println("============================================"); + System.out.println(); + } + + // displays the user menu + public static void displayMenu() { + System.out.println(); + System.out.printf("(A)dd a new entry \n(M)odify an existing entry \n" + + "(B)ellingham phone book list \n(S)eattle phone book list \n(Q)uit \n"); + System.out.println(); + System.out.print("Enter a command from the list above: "); + } + + // method to add a phone book entry + public static void addEntry(Scanner s) { + System.out.println(); + System.out.println("Adding an entry:"); + System.out.print("Enter a FIRST NAME: "); + String firstName = s.nextLine(); + System.out.print("Enter a LAST NAME: "); + String lastName = s.nextLine(); + System.out.print("Enter a CITY: "); + String city = s.nextLine(); + System.out.print("Enter a PHONE NUMBER: "); + String phoneNumber = s.nextLine(); + System.out.print("Enter an EMAIL ADDRESS: "); + String emailAddress = s.nextLine(); + System.out.println("--Entry created--"); + } + + // method to modify a phone book entry + public static void modifyEntry(Scanner s) { + System.out.println(); + // allow the user to select which entry to modify + // then display a menu that allows th user to select + // which field of the entry to modify + } + + // search the phone book list and print the entries with Bellingham in the city field + public static void displayBellingham() { + + } + + // search the phone book list and print the entries with Seattle in the city field + public static void displaySeattle() { + + } +} diff --git a/src/PhoneBookNode.java b/src/PhoneBookNode.java new file mode 100644 index 0000000..7a8d09a --- /dev/null +++ b/src/PhoneBookNode.java @@ -0,0 +1,96 @@ +public class PhoneBookNode { + + // Object fields + private String firstName; + private String lastName; + private String address; + private String city; + private String phoneNumber; + private String emailAddress; + protected PhoneBookNode next; + + // A 6 argument constructor + public PhoneBookNode(String firstName, String lastName, String address, String city, + String phoneNumber, String emailAddress) { + this.firstName = firstName; + this.lastName = lastName; + this.address = address; + this.city = city; + this.phoneNumber = phoneNumber; + this.emailAddress = emailAddress; + this.next = null; + } + + // A 7 argument constructor that includes the next node + public PhoneBookNode(String firstName, String lastName, String address, String city, + String phoneNumber, String emailAddress, PhoneBookNode next) { + this.firstName = firstName; + this.lastName = lastName; + this.address = address; + this.city = city; + this.phoneNumber = phoneNumber; + this.emailAddress = emailAddress; + this.next = next; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public PhoneBookNode getNext() { + return next; + } + + public void setNext(PhoneBookNode next) { + this.next = next; + } + + public String toString() { + return this.firstName + " " + this.lastName + " | " + this.address + " " + this.city + " | " + + this.phoneNumber + " | " + this.emailAddress; + } +} diff --git a/src/TestClass.java b/src/TestClass.java new file mode 100644 index 0000000..f8c1c0b --- /dev/null +++ b/src/TestClass.java @@ -0,0 +1,11 @@ +public class TestClass { + + public static void main(String[] args) { + PhoneBookNode person1 = new PhoneBookNode("Joe", "Schmoe", "123 Coal Valley Ln", "Bellingham", "360-555-1212", "yes@no.com"); + System.out.println(person1); + person1.setFirstName("Jill"); + System.out.println(person1); + PhoneBookNode person2 = new PhoneBookNode("Jane", "Doe", "321 Gold Hill Rd", "Seattle", "555-555-1212", "no@yes.com", person1); + System.out.println(person2); + } +}