-
Notifications
You must be signed in to change notification settings - Fork 0
/
Modify.java
43 lines (41 loc) · 1.9 KB
/
Modify.java
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
package contacts_list;
import java.util.Scanner;
public class Modify extends Contact{
public static void modify() throws InvalidPhoneNumberException {
Scanner in = new Scanner(System.in);
Contacts = ReadFromFile.read();
while (true){
System.out.print("Munkahelyi/Privát szám: ");
String inputNumber = in.nextLine();
if (inputNumber.length() == 0) break;
else{
for (Contact i : Contacts){
if (i.privatePhoneNumber.equals(inputNumber) || i.workPhoneNumber.equals(inputNumber)){
System.out.print("Név: ");
String nameIn = in.nextLine();
String[] namePcs = nameIn.split(" ");
i.lastName = namePcs[0];
i.firstName = namePcs[1];
System.out.print("Becenév: ");
String nicknameIn = in.nextLine();
i.nickname = noData.nothing(nicknameIn);
System.out.print("Cím: ");
String addressIn = in.nextLine();
i.address = noData.nothing(addressIn);
System.out.print("Munkahelyi szám: ");
String workPhoneNumberIn = in.nextLine();
i.workPhoneNumber = noData.nothing(workPhoneNumberIn);
System.out.print("Privát szám: ");
String privateNumberIn = in.nextLine();
i.privatePhoneNumber = noData.nothing(privateNumberIn);
WriteToFile.write(Contacts);
}
else {
throw new InvalidPhoneNumberException(inputNumber);
}
}
}
}
Menu.mainMenu();
}
}