|
1 | 1 | package test; |
2 | 2 |
|
| 3 | +import utils.FileUtils; |
| 4 | + |
| 5 | +import java.io.File; |
| 6 | +import java.util.ArrayList; |
| 7 | +import java.util.List; |
| 8 | +import java.util.Locale; |
| 9 | + |
3 | 10 | public class Main { |
4 | 11 |
|
5 | | - static class Value{ |
6 | | - int i; |
| 12 | + static class WdSubject { |
| 13 | + String name; |
| 14 | + String startTime; |
| 15 | + String errorTime; |
| 16 | + int diffMonth; |
7 | 17 | } |
8 | 18 |
|
9 | 19 | public static void main(String[] args) throws Exception { |
10 | | - Main main = new Main(); |
11 | | - main.first(); |
| 20 | + System.out.println(Integer.toHexString(Integer.MAX_VALUE)); |
12 | 21 | } |
13 | 22 |
|
14 | | - private void first() { |
15 | | - int i = 5; |
16 | | - Value v = new Value(); |
17 | | - v.i = 25; |
18 | | - second(v, i); |
19 | | - System.out.println(v.i); |
| 23 | + private static void test() { |
| 24 | + ArrayList<String> strings = FileUtils.readToStringLines(new File("temp/wd.txt")); |
| 25 | + int index = 0; |
| 26 | + WdSubject subject = new WdSubject(); |
| 27 | + assert strings != null; |
| 28 | + List<WdSubject> subjects = new ArrayList<>(); |
| 29 | + for (String string : strings) { |
| 30 | + switch (index) { |
| 31 | + case 2: |
| 32 | + subject.errorTime = string; |
| 33 | + break; |
| 34 | + case 3: |
| 35 | + subject.startTime = string; |
| 36 | + subject.diffMonth = calculateDiff(subject); |
| 37 | + subject = new WdSubject(); |
| 38 | + subjects.add(subject); |
| 39 | + break; |
| 40 | + |
| 41 | + } |
| 42 | + if(index == 6) { |
| 43 | + index = 0; |
| 44 | + } else { |
| 45 | + index ++; |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + int count = 0; |
| 50 | + for (WdSubject sub : subjects) { |
| 51 | + if(sub.diffMonth <= 12) { |
| 52 | + count ++; |
| 53 | + } |
| 54 | + } |
| 55 | + System.out.println(count + " / " + subjects.size()); |
| 56 | + System.out.println(1f*count/subjects.size()*100 + "%"); |
20 | 57 | } |
21 | 58 |
|
22 | | - private void second(Value v, int i) { |
23 | | - i = 0; |
24 | | - v.i = 20; |
25 | | - Value val = new Value(); |
26 | | - v = val; |
27 | | - System.out.println(v.i + "" + i); |
| 59 | + private static int calculateDiff(WdSubject subject) { |
| 60 | + int errorYear = Integer.parseInt(subject.errorTime.split("-")[0]); |
| 61 | + int startYear = Integer.parseInt(subject.startTime.split("-")[0]); |
| 62 | + int errorMonth = Integer.parseInt(subject.errorTime.split("-")[1]); |
| 63 | + int startMonth = Integer.parseInt(subject.startTime.split("-")[1]); |
| 64 | + return (errorYear-startYear)*12+(errorMonth-startMonth); |
28 | 65 | } |
29 | 66 |
|
30 | 67 | } |
0 commit comments