-
Notifications
You must be signed in to change notification settings - Fork 0
/
Messenger.java
35 lines (29 loc) · 923 Bytes
/
Messenger.java
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
package solitaire;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Messenger {
public static void main(String[] args)
throws IOException {
Solitaire ss = new Solitaire();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter deck file name => ");
Scanner sc = new Scanner(new File(br.readLine()));
ss.makeDeck(sc);
System.out.print("Encrypt or decrypt? (e/d), press return to quit => ");
String inp = br.readLine();
if (inp.length() == 0) {
System.exit(0);
}
char ed = inp.charAt(0);
System.out.print("Enter message => ");
String message = br.readLine();
if (ed == 'e') {
System.out.println("Encrypted message: " + ss.encrypt(message));
} else {
System.out.println("Decrypted message: " + ss.decrypt(message));
}
}
}