Add enum ContactTypes
Some checks failed
Java laboratory work CI / build (push) Failing after 1m13s
Java laboratory work CI / checkstyle (push) Failing after 9s

This commit is contained in:
2025-10-25 09:58:44 +07:00
parent 5ab5f3109e
commit 34ce9191b7
8 changed files with 14 additions and 6 deletions

View File

@@ -11,6 +11,15 @@ import java.util.HashSet;
* {@summary Lab's Main class.}
*/
public class Main {
static enum ContactTypes {
personal("personal"), work("work");
final String type;
ContactTypes(String type) {
this.type = type;
}
}
static void menuPrint() {
System.out.println("Выберите пункт из меню:");
System.out.println("1. Выход");
@@ -94,17 +103,16 @@ public class Main {
case ('2'):
{ // Add contact
String type = "";
String name = "";
System.out.println("Выберите тип контакта (1. Персональный), (2. Деловой): ");
try {
type = br.readLine().charAt(0) == '1' ? "Personal" : "Work";
type = br.readLine().charAt(0) == '1' ? ContactTypes.personal.type : ContactTypes.work.type;
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Пустой ввод");
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
String name = "";
System.out.println("Введите имя: ");
try {
name = br.readLine();
@@ -123,7 +131,7 @@ public class Main {
} while (matcher.match(number) == false);
switch (type) {
case ("Personal"):
case ("personal"):
{
String birthdate = "";
System.out.println("Введите день рождения: ");
@@ -158,7 +166,7 @@ public class Main {
break;
}
case ("Work"):
case ("personal"):
{
String company = "";
System.out.println("Введите принадлежность к компании: ");

File diff suppressed because one or more lines are too long