File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/main/java/com/back/domain/user/support Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .back .domain .user .support ;
2+
3+ public final class AbvView {
4+
5+ private AbvView (){}
6+
7+ // 0~100%를 6단계로 매핑
8+ public static int levelOf (Double percent ) {
9+ if (percent == null ) return 1 ;
10+
11+ double x = Math .max (0 , Math .min (100 , percent ));
12+ int p = (int ) x ;
13+
14+ if (p <= 10 ) return 1 ; // 0~10
15+ if (p <= 25 ) return 2 ; // 11~25
16+ if (p <= 45 ) return 3 ; // 26~45
17+ if (p <= 65 ) return 4 ; // 46~65
18+ if (p <= 85 ) return 5 ; // 66~85
19+ return 6 ; // 86~100
20+ }
21+
22+ // 화면용 "23.5%" 라벨
23+ public static String percentLabel (Double percent ) {
24+ if (percent == null ) return "0%" ;
25+ double x = Math .max (0.0 , Math .min (100.0 , percent ));
26+ return (x % 1.0 == 0.0 ) ? String .format ("%.0f%%" , x ) : String .format ("%.1f%%" , x );
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments