Skip to content

Commit

Permalink
header comments and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
owleyeview committed Oct 26, 2022
1 parent ba86a63 commit 2ab3079
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
25 changes: 17 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions src/PhoneBookMain.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@


/*
Rashaan, Derek, Cece and Nathan
10/25/2022
CS 145
Phone Book Assignment
PhoneBookMain.java
*/

// A program for creating, viewing and manipulating a phone book linked list
import java.util.*;
public class PhoneBookMain {


public static void main(String[] args) {
Scanner s = new Scanner(System.in);
PhoneBookManager javaPages = new PhoneBookManager();
Expand Down Expand Up @@ -40,7 +46,8 @@ public static void main(String[] args) {
done = true;
break;
default: // valid input commands not found
System.out.println("Invalid command. Select from the commands above.");
System.out.println("Invalid command. " +
"Select from the commands above.");
break;
}
} while (!done); // end of do while loop
Expand All @@ -59,8 +66,10 @@ public static void displayIntroMessage() {
// displays the user menu
public static void displayMenu() {
System.out.println();
System.out.print("(A)dd a new entry \n(M)odify an existing entry \n(D)isplay complete phone book list " +
"\n(B)ellingham phone book list \n(S)eattle phone book list \n(Q)uit \n");
System.out.print("(A)dd a new entry \n(M)odify an existing entry " +
"\n(D)isplay complete phone book list " +
"\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: ");
}
Expand All @@ -82,7 +91,8 @@ public static void addEntry(Scanner s, PhoneBookManager javaPages) {
System.out.print("Enter an EMAIL ADDRESS: ");
String emailAddress = s.nextLine();
System.out.println("--Entry created--");
PhoneBookNode newEntry = new PhoneBookNode(firstName, lastName, address, city, phoneNumber, emailAddress);
PhoneBookNode newEntry = new PhoneBookNode(firstName, lastName,
address, city, phoneNumber, emailAddress);
javaPages.append(newEntry);
}

Expand Down Expand Up @@ -129,7 +139,8 @@ public static void modifyEntry(Scanner s, PhoneBookManager javaPages) {
current = current.next;
}
// user menu for modifications
System.out.println("(F)irst name, (L)ast name, (A)ddress, (C)ity, (P)hone number, (E)mail address");
System.out.println("(F)irst name, (L)ast name, (A)ddress, " +
"(C)ity, (P)hone number, (E)mail address");
System.out.println("Select a field to modify: ");

command = s.nextLine().toLowerCase(); // accept an input command
Expand Down Expand Up @@ -166,7 +177,8 @@ public static void modifyEntry(Scanner s, PhoneBookManager javaPages) {
current.setEmailAddress(emailAddress);
break;
default: // valid input commands not found
System.out.println("Invalid command. Select from the commands above.");
System.out.println("Invalid command. " +
"Select from the commands above.");
break;
}
done = true;
Expand All @@ -180,6 +192,7 @@ public static void modifyEntry(Scanner s, PhoneBookManager javaPages) {
public static void displayList(PhoneBookManager javaPages) {
javaPages.printList();
}

// search the phone book list and print the entries with Bellingham in the city field
public static void displayBellingham(PhoneBookManager javaPages) {
System.out.println();
Expand Down
11 changes: 9 additions & 2 deletions src/PhoneBookManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@


/*
Rashaan, Derek, Cece and Nathan
10/25/2022
CS 145
Phone Book Assignment
PhoneBookManager.java
*/

// A class for creating and managing a linked list of phone book nodes
public class PhoneBookManager {
PhoneBookNode head;

Expand Down
15 changes: 11 additions & 4 deletions src/PhoneBookNode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@


/*
Rashaan, Derek, Cece and Nathan
10/25/2022
CS 145
Phone Book Assignment
PhoneBookNode.java
*/

// A class for creating node objects for a phone book linked list
public class PhoneBookNode {

// Object fields
Expand Down Expand Up @@ -103,7 +110,7 @@ public void setNext(PhoneBookNode next) {
}

public String toString() {
return this.firstName + " " + this.lastName + " | " + this.address + " " + this.city + " | " +
this.phoneNumber + " | " + this.emailAddress;
return this.firstName + " " + this.lastName + " | " + this.address
+ " " + this.city + " | " + this.phoneNumber + " | " + this.emailAddress;
}
}

0 comments on commit 2ab3079

Please sign in to comment.