forked from kindsword/learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditNote.java
More file actions
70 lines (63 loc) · 1.94 KB
/
Copy pathEditNote.java
File metadata and controls
70 lines (63 loc) · 1.94 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package XReply;
import java.util.Scanner;
/**
*
* @author joker
*/
public class EditNote {
private static String TAG_TITLE ="title";
private static String TAG_CONTENT = "Content";
private static int MODE_SAVE = 0;
private static int MODE_EXIT = 1;
public void EditMode() {
boolean editFlag = true;
boolean isTitle = false;
boolean isContent = false;
int mode = MODE_SAVE;
Scanner s = new Scanner(System.in);
NoteStyle note = new NoteStyle();
while (editFlag) {
if (!isTitle) {
Out(TAG_TITLE + ":");
String t = s.nextLine();
note.setTitle(t);
isTitle = true;
}
if (!isContent) {
Out(TAG_CONTENT + "\n");
isContent = true;
}
Out(">");
String con = s.nextLine();
if (con.equals("save")) {
editFlag = false;
mode = MODE_SAVE;
} else if (con.equals("exit")) {
editFlag = false;
mode = MODE_EXIT;
} else {
note.setContent(con);
}
}
String info = note.getNote().toString();
if (mode == MODE_SAVE) {
FileSave f = new FileSave();
f.saveFile(info);
Out(info);
Out("#########################\n");
Out("Write: " + f.getFileName() + " " + (f.getState() ? "success" : "fail")+"\n");
} else if (mode == MODE_EXIT) {
Out(info);
Out("#########################\n");
Out("Exit Not Save File\n");
}
}
private void Out(String s) {
System.out.print((String)s);
}
}