Edit pipeline

This commit is contained in:
2025-10-25 07:16:23 +07:00
parent 240d6e3867
commit c1bbe4f848
20 changed files with 920 additions and 257 deletions

View File

@@ -34,6 +34,7 @@ jobs:
wget https://github.com/checkstyle/checkstyle/releases/download/checkstyle-12.1.0/checkstyle-12.1.0-all.jar
echo "Getting google checkstyle"
wget https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml
export command="java -jar checkstyle-12.1.0-all.jar -c ./google_checks.xml ./app/src/"
$command
test $($command | wc -l) -le 2
java -jar checkstyle-12.1.0-all.jar -c ./google_chec
ks.xml ./app/src/
test $(java -jar checkstyle-12.1.0-all.jar -c ./google_chec
ks.xml ./app/src/ | wc -l) -le 2

View File

@@ -0,0 +1 @@
38dc965e-1d86-4b48-b23d-7b4d8fbc2a1<61>

View File

@@ -0,0 +1 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c`u<><18><44><DCAA>ur<75><72>

Binary file not shown.

View File

@@ -1,296 +1,293 @@
package org.lab.main;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Date;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
public class Main {
static void MenuPrint() {
System.out.println("Выберите пункт из меню:");
System.out.println("1. Выход");
System.out.println("2. Добавить контакт");
System.out.println("3. Удалить контакт");
System.out.println("4. Найти контакт по имени");
System.out.println("5. Показать все контакты");
System.out.println("6. Показать все рабочие контакты");
System.out.println("7. Показать все личные контакты");
System.out.println("8. Сделать звонок");
System.out.println("9. Написать письмо");
System.out.println("Введите символ: ");
static void MenuPrint() {
System.out.println("Выберите пункт из меню:");
System.out.println("1. Выход");
System.out.println("2. Добавить контакт");
System.out.println("3. Удалить контакт");
System.out.println("4. Найти контакт по имени");
System.out.println("5. Показать все контакты");
System.out.println("6. Показать все рабочие контакты");
System.out.println("7. Показать все личные контакты");
System.out.println("8. Сделать звонок");
System.out.println("9. Написать письмо");
System.out.println("Введите символ: ");
}
static void askFavourite(BufferedReader br, HashSet<GenericContact> favourites, int act, GenericContact contact) {
char ch = 0;
if (act == 1) {
System.out.println("Добавить контакт в избранные?");
} else {
System.out.println("Удалить контакт из избранных?");
}
try {
ch = br.readLine().charAt(0);
} catch (IOException readLineException) {
System.out.println("Ошибка ввода");
}
static void askFavourite(BufferedReader br, HashSet<GenericContact> favourites, int act, GenericContact contact) {
char ch = 0;
if(act == 1){
System.out.println("Добавить контакт в избранные?");
if (act == 1) {
if (ch == '1') {
favourites.add(contact);
}
else{
System.out.println("Удалить контакт из избранных?");
}
try{
ch = br.readLine().charAt(0);
} catch(IOException readLineException){
System.out.println("Ошибка ввода");
}
if(act == 1){
if(ch == '1'){
favourites.add(contact);
}
}
else{
if(ch == '1'){
favourites.remove(contact);
}
} else {
if (ch == '1') {
favourites.remove(contact);
}
}
}
public static void main(String[] args) {
PhoneBook<GenericContact> contacts = new PhoneBook<GenericContact>();
public static void main(String[] args) {
PhoneBook<GenericContact> contacts = new PhoneBook<GenericContact>();
HashSet<GenericContact> favourites = new HashSet<GenericContact>();
ArrayList<String> callHistory = new ArrayList<String>();
HashSet<GenericContact> favourites = new HashSet<GenericContact>();
ArrayList<String> callHistory = new ArrayList<String>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, System.console().charset()));
MatchyMatcher matcher = new MatchyMatcher("(\\+*)\\d{11}");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, System.console().charset()));
MatchyMatcher matcher = new MatchyMatcher("(\\+*)\\d{11}");
char ch = 0;
char ch = 0;
while (true) {
MenuPrint();
while (true) {
MenuPrint();
do {
do {
try {
ch = br.readLine().charAt(0);
} catch (StringIndexOutOfBoundsException consoleInputOutOfBounds) {
System.out.println("Ввод, вероятно, пуст");
} catch (IOException readLineException) {
System.out.println("Не удалось считать строку");
}
if (ch < '1' || ch > '9') {
System.out.println("\nНеизвестный символ!\n");
MenuPrint();
continue;
}
} while (ch < '1' || ch > '9');
switch (ch) {
case ('1'): { // Exit program
System.exit(0);
break;
}
case ('2'): { // Add contact
String type = "";
String name = "";
String number = "";
System.out.println("Выберите тип контакта (1. Персональный), (2. Деловой): ");
try {
ch = br.readLine().charAt(0);
} catch (StringIndexOutOfBoundsException consoleInputOutOfBounds) {
System.out.println("Ввод, вероятно, пуст");
} catch (IOException readLineException) {
System.out.println("Не удалось считать строку");
type = br.readLine().charAt(0) == '1' ? "Personal" : "Work";
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Пустой ввод");
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
if (ch < '1' || ch > '9') {
System.out.println("\nНеизвестный символ!\n");
MenuPrint();
continue;
System.out.println("Введите имя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
} while (ch < '1' || ch > '9');
switch (ch) {
case ('1'): { // Exit program
System.exit(0);
break;
}
case ('2'): { // Add contact
String type = "";
String name = "";
String number = "";
System.out.println("Выберите тип контакта (1. Персональный), (2. Деловой): ");
do {
System.out.println("Введите корректный номер телефона: ");
try {
type = br.readLine().charAt(0) == '1' ? "Personal" : "Work";
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Пустой ввод");
number = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
} while (matcher.Match(number) == false);
System.out.println("Введите имя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
switch (type) {
case ("Personal"): {
String birthdate = "";
String commentary = "";
String address = "";
do {
System.out.println("Введите корректный номер телефона: ");
System.out.println("Введите день рождения: ");
try {
birthdate = br.readLine();
} catch (IOException e) {
}
System.out.println("Введите комментарий: ");
try {
commentary = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Введите адрес: ");
try {
number = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
} while (matcher.Match(number) == false);
switch (type) {
case ("Personal"): {
String birthdate = "";
String commentary = "";
String address = "";
PersonalContact user = new PersonalContact(name, number, birthdate, commentary, address);
System.out.println("Введите день рождения: ");
try {
birthdate = br.readLine();
} catch (IOException e) {
askFavourite(br, favourites, favourites.contains(user) ? 0 : 1 , user);
}
System.out.println("Введите комментарий: ");
try {
commentary = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Введите адрес: ");
try {
number = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
PersonalContact user = new PersonalContact(name, number, birthdate, commentary, address);
askFavourite(br, favourites, favourites.contains(user) ? 0 : 1 , user);
contacts.add(name, user);
break;
}
case ("Work"): {
String company = "";
String duty = "";
String email = "";
System.out.println("Введите принадлежность к компании: ");
try {
company = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Введите служебное положение: ");
try {
duty = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Введите адрес электронной почты: ");
try {
email = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
WorkContact user = new WorkContact(name, number, company, duty, email);
askFavourite(br, favourites, favourites.contains(user) ? 0 : 1 , user);
contacts.add(name, user);
break;
}
}
break;
}
case ('3'): { // Delete contact
String name = "";
System.out.println("Введите имя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
contacts.remove(name);
favourites.remove(contacts.get(name));
break;
}
case ('4'): { // Find contact by name
String name = "";
System.out.println("Введите имя искомого пользователя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
GenericContact contact = contacts.get(name);
if (contact != null)
System.out.println(contact.getInfo());
askFavourite(br, favourites, favourites.contains(contacts.get(name)) ? 0 : 1 , contacts.get(name));
break;
}
case ('5'): { // Show all contacts
contacts.printSorted();
break;
}
case ('6'): { // Show all work contacts
for (var x : contacts.contacts.values()) {
if(x instanceof WorkContact)
x.getInfo();
}
break;
}
case ('7'): { // Show all personal contacts
for (var x : contacts.contacts.values()) {
if(x instanceof PersonalContact)
x.getInfo();
}
break;
}
case ('8'): {
String name = "";
Callable target = null;
System.out.println("Введите имя пользователя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
target = (Callable) contacts.get(name);
target.call();
callHistory.add("Совершён звонок " + new Date().toString() + "контакту" + name);
break;
}
case ('9'): {
String name = "";
String message = "";
Emailable target = null;
System.out.println("Введите имя пользователя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Текст сообщения: ");
try {
message = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
try {
target = (Emailable) contacts.get(name);
} catch (ClassCastException exc) {
System.out.println("Нет такого контакта");
contacts.add(name, user);
break;
}
case ("Work"): {
String company = "";
String duty = "";
String email = "";
try {
target.SendEmail(message);
} catch (NullPointerException nullpEx) {
System.out.println("Пользователь не найден или не рабочий контакт");
}
System.out.println("Введите принадлежность к компании: ");
try {
company = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Введите служебное положение: ");
try {
duty = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Введите адрес электронной почты: ");
try {
email = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
WorkContact user = new WorkContact(name, number, company, duty, email);
askFavourite(br, favourites, favourites.contains(user) ? 0 : 1 , user);
contacts.add(name, user);
break;
}
}
}
case ('3'): { // Delete contact
String name = "";
System.out.println("Введите имя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
contacts.remove(name);
favourites.remove(contacts.get(name));
break;
}
case ('4'): { // Find contact by name
String name = "";
System.out.println("Введите имя искомого пользователя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
GenericContact contact = contacts.get(name);
if (contact != null)
System.out.println(contact.getInfo());
askFavourite(br, favourites, favourites.contains(contacts.get(name)) ? 0 : 1 , contacts.get(name));
break;
}
case ('5'): { // Show all contacts
contacts.printSorted();
break;
}
case ('6'): { // Show all work contacts
for (var x : contacts.contacts.values()) {
if(x instanceof WorkContact)
x.getInfo();
}
break;
}
case ('7'): { // Show all personal contacts
for (var x : contacts.contacts.values()) {
if(x instanceof PersonalContact)
x.getInfo();
}
break;
}
case ('8'): {
String name = "";
Callable target = null;
System.out.println("Введите имя пользователя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
target = (Callable) contacts.get(name);
target.call();
callHistory.add("Совершён звонок " + new Date().toString() + "контакту" + name);
break;
}
case ('9'): {
String name = "";
String message = "";
Emailable target = null;
System.out.println("Введите имя пользователя: ");
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
System.out.println("Текст сообщения: ");
try {
message = br.readLine();
} catch (IOException e) {
System.out.println("Ошибка чтения");
}
try {
target = (Emailable) contacts.get(name);
} catch (ClassCastException exc) {
System.out.println("Нет такого контакта");
break;
}
try {
target.SendEmail(message);
} catch (NullPointerException nullpEx) {
System.out.println("Пользователь не найден или не рабочий контакт");
}
break;
}
}
}
}
}
}
}

View File

@@ -650,7 +650,7 @@ code + .copy-button {
<script type="text/javascript">
function configurationCacheProblems() { return (
// begin-report-data
{"diagnostics":[{"locations":[{"path":"/home/maksytka/work/IdeaProjects/java_lab1/app/src/main/java/org/lab/main/Main.java"},{"taskPath":":app:compileJava"}],"problem":[{"text":"/home/maksytka/work/IdeaProjects/java_lab1/app/src/main/java/org/lab/main/Main.java uses unchecked or unsafe operations."}],"severity":"ADVICE","problemDetails":[{"text":"Note: /home/maksytka/work/IdeaProjects/java_lab1/app/src/main/java/org/lab/main/Main.java uses unchecked or unsafe operations."}],"contextualLabel":"/home/maksytka/work/IdeaProjects/java_lab1/app/src/main/java/org/lab/main/Main.java uses unchecked or unsafe operations.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.unchecked.filename","displayName":"/home/maksytka/work/IdeaProjects/java_lab1/app/src/main/java/org/lab/main/Main.java uses unchecked or unsafe operations."}]},{"locations":[{"path":"/home/maksytka/work/IdeaProjects/java_lab1/app/src/main/java/org/lab/main/Main.java"},{"taskPath":":app:compileJava"}],"problem":[{"text":"Recompile with -Xlint:unchecked for details."}],"severity":"ADVICE","problemDetails":[{"text":"Note: Recompile with -Xlint:unchecked for details."}],"contextualLabel":"Recompile with -Xlint:unchecked for details.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.unchecked.recompile","displayName":"Recompile with -Xlint:unchecked for details."}]}],"problemsReport":{"totalProblemCount":2,"requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.1/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
{"diagnostics":[{"locations":[{"path":"/home/maksytka/work/java/java_lab1/app/src/main/java/org/lab/main/Main.java","line":181,"column":21,"length":6},{"taskPath":":app:compileJava"}],"problem":[{"text":"unreachable statement"}],"severity":"ERROR","problemDetails":[{"text":"/home/maksytka/work/java/java_lab1/app/src/main/java/org/lab/main/Main.java:181: error: unreachable statement\n break;\n ^"}],"contextualLabel":"unreachable statement","error":{"parts":[{"text":"org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler output below.\n/home/maksytka/work/java/java_lab1/app/src/main/java/org/lab/main/Main.java:181: error: unreachable statement\n break;\n ^\n1 error\n"},{"internalText":"\tat org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:89)\n\tat org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)\n\tat org.gradle.api.internal.tasks.compile.daemon.AbstractIsolatedCompilerWorkerExecutor$CompilerWorkAction.execute(AbstractIsolatedCompilerWorkerExecutor.java:78)\n\tat org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)\n\tat org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:54)\n\tat org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:48)\n\tat org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)\n\tat org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:48)\n\tat org.gradle.workers.internal.FlatClassLoaderWorker.run(FlatClassLoaderWorker.java:32)\n\tat org.gradle.workers.internal.FlatClassLoaderWorker.run(FlatClassLoaderWorker.java:22)\n\tat org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:108)\n\tat org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:77)\n\tat org.gradle.process.internal.worker.request.WorkerAction.lambda$run$1(WorkerAction.java:150)\n\tat org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)\n\tat org.gradle.process.internal.worker.request.WorkerAction.lambda$run$2(WorkerAction.java:150)\n\tat org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:85)\n\tat org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:142)\n\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)\n\tat org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)\n\tat org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)\n\tat org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)\n\tat org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)\n\tat org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)\n\tat org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)\n\tat org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)\n"}]},"problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.err.unreachable.stmt","displayName":"unreachable statement"}],"solutions":[[{"text":"Check your code and dependencies to fix the compilation error(s)"}]]}],"problemsReport":{"totalProblemCount":1,"requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.1/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
// end-report-data
);}
</script>