Files
kr_1/CurrencyAnalyzer.java
2026-05-31 13:36:33 +05:00

35 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
public class CurrencyAnalyzer {
private static double last_value = -1;
public static void analyze(double current) {
if (last_value == -1) {
last_value = current;
String start_msg = "<b>Мониторинг курса USD запущен</b>\n" +
"Текущий курс: <b>" + current + "</b> ₽";
TelegramNotifier.sendMessage(start_msg);
System.out.println("Начальное значение USD: " + current);
return;
}
String msg = "";
if (current > last_value) {
msg = "Курс доллара <b>вырос ↑</b>";
} else if (current < last_value) {
msg = "Курс доллара <b>упал ↓</b>";
} else {
return;
}
String telegram_msg = msg + "\n" +
"Было: <b>" + last_value + "</b> ₽\n" +
"Стало: <b>" + current + "</b> ₽";
TelegramNotifier.sendMessage(telegram_msg);
System.out.println(msg.replace("<b>", "").replace("</b>", "") +
" (было " + last_value + ", стало " + current + ")");
last_value = current;
}
}