package com.example.pdaplccontrol; final class WeightInputParser { private WeightInputParser() { } static short parseKg(String input) { if (input == null || input.trim().isEmpty()) { throw new IllegalArgumentException("请输入重量"); } int kg; try { kg = Integer.parseInt(input.trim()); } catch (NumberFormatException e) { throw new IllegalArgumentException("重量必须为整数kg"); } if (kg < PlcConfig.MIN_WEIGHT_KG || kg > PlcConfig.MAX_WEIGHT_KG) { throw new IllegalArgumentException("重量范围为 0-30kg"); } return (short) kg; } static String kgToDisplayText(short weightKg) { return String.valueOf(weightKg); } }