Add enum ContactTypes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
Reference in New Issue
Block a user