-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delete.java
26 lines (24 loc) · 961 Bytes
/
Delete.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
package contacts_list;
import java.util.Scanner;
public class Delete extends Contact{
public static void delete() 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;
for(int i = 0; i < Contacts.size(); i++){
if (Contacts.get(i).privatePhoneNumber.equals(inputNumber) || Contacts.get(i).workPhoneNumber.equals(inputNumber)){
Contacts.remove(i);
System.out.println("Névjegy törölve!");
}
else{
throw new InvalidPhoneNumberException(inputNumber);
}
}
}
WriteToFile.write(Contacts);
Menu.mainMenu();
}
}