File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ public class CaesarShift {
55 private static int key = 25 ; //Initialize and encapsulate the shift key
66 private static String encryptedMsg ; //Create and encapsulate the message container
77
8- public String encrypt (String msg ){
9- String upCased = msg .toUpperCase ();
8+ public String encrypt (String encryptMsg ){
9+ String upCased = encryptMsg .toUpperCase ();
1010 char [] upCasedArrs = upCased .toCharArray ();//split the string to a character array
1111 ArrayList <Character > encryptedChars = new ArrayList <Character >();
1212
@@ -20,4 +20,8 @@ public String encrypt(String msg){
2020 return encryptedMsg ;
2121 }
2222
23+ public String decrypt (String decryptMsg ){
24+ return decryptMsg .toUpperCase ();
25+ }
26+
2327}
Original file line number Diff line number Diff line change 44
55class CaesarShiftTest {
66 @ Test
7- public void caesarShift_convertCase_String () {
8- CaesarShift testCase = new CaesarShift ();
9- assertEquals ("Z" , testCase .encrypt ("a" ));
10- }
11-
12- @ Test
13- public void caesarShift_encryptSingleChar_String (){
14- CaesarShift encryptChar = new CaesarShift ();
15- assertEquals ("Y" , encryptChar .encrypt ("Z" ));
7+ public void caesarShift_encryptCheckCase_Boolean () {
8+ CaesarShift checkCase = new CaesarShift ();
9+ assertEquals (true , Character .isUpperCase (checkCase .encrypt ("a" ).charAt (0 )));
1610 }
1711
1812 @ Test
1913 void caesarShift_encryptString_String () {
2014 CaesarShift encryptString = new CaesarShift ();
2115 assertEquals ("GDKKN" , encryptString .encrypt ("hello" ));
2216 }
17+
18+ @ Test
19+ void caesarShift_decryptCheckCase_Boolean () {
20+ CaesarShift checkCase = new CaesarShift ();
21+ assertEquals (true , Character .isUpperCase (checkCase .decrypt ("z" ).charAt (0 )));
22+ }
23+
24+ @ Test
25+ public void caesarShift_decryptString_String (){
26+ CaesarShift decryptStr = new CaesarShift ();
27+ assertEquals ("HELLO" , decryptStr .decrypt ("GDKKN" ));
28+ }
2329}
You can’t perform that action at this time.
0 commit comments