-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
84 lines (56 loc) · 3 KB
/
Copy pathSolution.java
File metadata and controls
84 lines (56 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//I Jesus have sent mine angel to testify unto you these things in the churches. I am the root and the offspring of David, and the bright and morning star. (Revelation 22:16)
package com.javarush.task.task29.task2901;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
/*
Рефакторинг в соответствии с Naming and Code Convention
*/
public class Solution {
public static final String DEFAULT_FILE_NAME = "C:/tmp/file_strange_name.tmp";
private final String localFileName;
private List<String> contentAslines;
private boolean fileLoaded;
public Solution(String firstFileName) {
localFileName = firstFileName == null ? DEFAULT_FILE_NAME : firstFileName;
}
public static void main(String[] args) throws FileNotFoundException {
String fileName = Solution.class.getResource("Solution.java").getPath();
Solution solution = new Solution(fileName);
solution.downloadFileContent();
if (solution.isFileLoaded()) {
System.out.println(solution.hasFileExpectedLine("public class Solution {")); //expected true
System.out.println(solution.hasFileExpectedLine(" public class Solution {")); //expected false
}
}
public boolean isFileLoaded() {
return fileLoaded;
}
public void downloadFileContent() {
try {
contentAslines = Files.readAllLines((new File(localFileName)).toPath(), Charset.defaultCharset());
fileLoaded = true;
} catch (IOException e) {
System.out.println("Unsuccessful. What a surprise!");
}
}
public boolean hasFileExpectedLine(String expectedLine) {
return contentAslines.contains(expectedLine);
}
}
/*
Рефакторинг в соответствии с Naming and Code Convention
Исправить код в соответствии с Naming and Code Convention (Shift+F6 для рефакторинга).
Подсказка:
IDEA не умеет правильно переименовывать имена классов, если меняется только регистр.
Переименуй имя класса во вспомогательное имя, а потом в это же в правильном регистре.
Требования:
1. Переименуй константу defaultFileName в соответствии с Naming and Code Convention.
2. Переименуй метод getFileLoaded в соответствии с Naming and Code Convention.
3. Переименуй метод DownloadFileContent в соответствии с Naming and Code Convention.
4. Переименуй метод isfileexpectedline в соответствии с Naming and Code Convention.
5. Переименуй параметр expectedline метода принимающего String в соответствии с Naming and Code Convention.
*/