-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddressBookView.java
More file actions
134 lines (105 loc) · 3.75 KB
/
AddressBookView.java
File metadata and controls
134 lines (105 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package AddressBook.UI;
import AddressBook.dto.Address;
import java.util.List;
/**
*
* @author Kelsey
*/
public class AddressBookView {
UserIO io;
public AddressBookView(UserIO io) {
this.io = io;
}
public int getMenuSelection() {
io.print("Main Menu");
io.print("1.Add an Address");
io.print("2.List all Addresses");
io.print("3.View an Address");
io.print("4.Edit an Address");
io.print("5.Return count of all Addresses");
io.print("6.Find an Address by LastName");
io.print("7.Remove an Address");
io.print("8.Exit");
return io.readInt("Please select your choice", 1, 8);
}
public Address addnewAddress() {
String addressId = io.readString("Enter the Address Number");
String firstName = io.readString("Enter FirstName");
String lastName = io.readString("Enter LastName");
String street = io.readString("Enter street Name");
String city = io.readString("Enter city");
String state = io.readString("Enter state");
String zipCode = io.readString("Enter zipCode");
Address newAddress = new Address(addressId);
newAddress.setFirstName(firstName);
newAddress.setLastName(lastName);
newAddress.setStreet(street);
newAddress.setCity(city);
newAddress.setState(state);
newAddress.setZipCode(zipCode);
return newAddress;
}
public void listAddress(List<Address> addressList) {
for (Address address : addressList) {
io.print(address.getAddressId() + ":"
+ address.getFirstName() + ""
+ address.getLastName() + ""
+ address.getStreet() + ""
+ address.getCity() + ""
+ address.getState() + ""
+ address.getZipCode());
}
io.readString("Hit enter to continue");
}
public String getAddressIdChoice() {
return io.readString("Please enter the Student ID.");
}
public void getAddress(Address address) {
if (address != null) {
io.print(address.getAddressId());
io.print(address.getFirstName() + " " + address.getLastName());
io.print(address.getCity());
io.print(address.getState());
io.print(address.getZipCode());
} else {
io.print("No such Address");
}
io.readString("Please hit enter to continue.");
}
public void unKnownCommand() {
io.print("Unknown Command");
}
public void exitMessage() {
io.print("Good Bye");
}
public String getLastName() {
return io.readString("Please enter the lastName to search");
}
public void createAddressBanner() {
io.print("===Create Address===");
}
public void successBanner() {
io.readString("Address successfully created. Hit Enter to continue");
}
public void editAddressBanner() {
io.print("===Edit Address");
}
public void editSuccessBanner() {
io.readString("Address successfully edited. Hit Enter to continue");
}
public void removeAddressBanner() {
io.print("==Remove Address==");
}
public void removeSuccessBanner() {
io.readString("Address remove successfully");
}
public void displayErrorMessage(String errorMsg) {
io.print("=== ERROR ===");
io.print(errorMsg);
}
}