/
nikolay470
/
algorithm_implementation
Обзор
Документация
Войти
/
nikolay470
/
algorithm_implementation
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/ru/gitflic/classes/Address.java
122 строки
3 KB
nikolay94
Коммит перед сменой ОС
21 июн 2026, 19:09
21 июн 2026, 19:09
24ae6bf
Код
Авторство
О чём код?
package ru.gitflic.classes; import ru.gitflic.enums.ZonesTypes; import ru.gitflic.exceptions.InvalidFormat; import java.util.Arrays; public class Address { private static Address addressNull = new Address(); private int hall = 0; private int rack = 0; private int tier = 0; private int place = 0; private ZonesTypes zone = ZonesTypes.NULL; private boolean inProblem = false; private boolean inShipment = false; public static Address NULL() { return Address.addressNull; } public static Address ofString(String addressOfString) throws InvalidFormat { int hall = 0; int rack = 1; int tier = 2; int place = 3; try { int[] res = Arrays.stream(addressOfString.replace(" ", "") .split("-")).mapToInt( Integer::parseInt ).toArray(); return new Address(res[hall], res[rack], res[tier], res[place]); } catch (NumberFormatException e) { throw new InvalidFormat("Некорректный формат адреса."); } } public Address(int hall, int rack, int tier, int place) { this.hall = hall; this.rack = rack; this.tier = tier; this.place = place; this.zone = null; } public Address(ZonesTypes zone) { this.zone = zone; } public Address() {} public int getHall() { return this.hall; } public int getRack() { return this.rack; } public int getTier() { return this.tier; } public int getPlace() { return this.place; } public Address cellProblem() { this.hall = 0; this.rack = 0; this.tier = 0; this.place = 0; this.zone = null; this.inProblem = true; this.inShipment = false; return this; } public boolean isCellProblem() { return this.inProblem; } public Address cellShipment() { this.hall = 0; this.rack = 0; this.tier = 0; this.place = 0; this.zone = null; this.inProblem = false; this.inShipment = true; return this; } public boolean isCellShipment() { return this.inShipment; } public ZonesTypes getZone() { return this.zone; } public String toString() { return this.hall + "-" + this.rack + "-" + this.tier + "-" + this.place; } public boolean equals( Address other ) { if ( other == null ) { return false; } return ( this.hall == other.hall && this.rack == other.rack && this.tier == other.tier && this.place == other.place && this.zone.equals( other.zone ) ); } }