/
nikolay470
/
algorithm_implementation
Обзор
Документация
Войти
/
nikolay470
/
algorithm_implementation
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/ru/gitflic/classes/StandardRack.java
51 строка
1 KB
nikolay94
Рефакторинг: разделил метод Main.main() на несколько методов по принципу один метод-одно действие
13 июн 2026, 10:38
13 июн 2026, 10:38
a95fc8d
Код
Авторство
О чём код?
package ru.gitflic.classes; import ru.gitflic.exceptions.InvalidFormat; import java.util.HashMap; public class StandardRack { public final int hall; public int number; public int quantTiers; public int quantPlacesInTier; public HashMap<String, StandardCell> cells; public StandardRack( int hall, int number, int quantTiers, int quantPlacesInTier ) { this.hall = hall; this.number = number; this.quantTiers = quantTiers; this.quantPlacesInTier = quantPlacesInTier; this.cells = new HashMap<>(quantTiers * quantPlacesInTier); } public void init() { String address; for ( int i = 1; i <= quantTiers; i++ ) { for ( int j = 1; j <= quantPlacesInTier; j++ ) { address = this.hall + "-" + this.number + "-" + i + "-" + j; try { this.cells.put( address, new StandardCell( Address.ofString( address ) ) ); } catch ( InvalidFormat e ) { System.out.println("Адрес в виде строки в некорректном формате."); } } } } public boolean equals( StandardRack other ) { if ( other == null ) { return false; } return ( this.hall == other.hall && this.number == other.number ); } public String toString() { return String.format( "Зал №%d, стеллаж %d", this.hall, this.number ); } }