-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 901b9a7
Showing
9 changed files
with
351 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", "[email protected]"); | ||
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", "[email protected]", person1); | ||
System.out.println(person2); | ||
} | ||
} |