Learn Java strings, index parsing and custom methods

This commit is contained in:
Евгений
2026-06-18 16:45:38 +03:00
parent 8c12a55684
commit b2b8606422
+12 -20
View File
@@ -1,27 +1,19 @@
public class Main {
public static void main(String[] args) {
MetodDemo.sayHelloByName("Евгений");
MetodDemo.sayHelloByName("Алексей");
String branch = getBranchName("java-touchBoard-main");
System.out.println(" Результат работы метода: " + branch);
int sum = MetodDemo.plus(22, 23);
U.pl("Результат сложения: " + sum);
int[] myArr = {12, 45, 78, 23, 9};
int maximum = MetodDemo.finMax(myArr);
U.pl("Самое большое число " + maximum);
int phonePrice = MetodDemo.calculatedDiscount(50000, 10);
U.pl("Цена телефона со скидкой: " + phonePrice);
int laptopPrice = MetodDemo.calculatedDiscount(120000, 20);
U.pl("Цена ноутбука со скидкой: " + laptopPrice);
int userAge = 17;
if (MetodDemo.checkAsses(userAge)) {
U.pl("Доступ запрещен, вам нет 18! ");
} else {
U.pl("Доступ разрешен.Добро пожаловать!");
}
public static String getBranchName(String repo) {
int lastSlash = repo.lastIndexOf("-");
if (lastSlash != -1) {
String result = repo.substring(lastSlash + 1);
return result;
}
return repo;
}
}