-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/console io v2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR refactors the Atbash cipher demo application to add console-based string processing capabilities alongside the existing file-based operations. The changes introduce a menu-driven interface that replaces single-character commands with numbered options, and adds a new "console mode" that allows users to encrypt/decrypt strings directly without file I/O. Two new methods (encryptString and decryptString) were added to the Encryption and Decryption classes to support this functionality, both leveraging the existing Mapping.applyAtbashCipher method. The Main class was significantly restructured to provide a more user-friendly interface with proper menu navigation and organized the code into reusable methods like runMenu() and consoleMode(). These changes align with the PR title "Fix/console io v2" and make the application more accessible for interactive use while maintaining compatibility with existing file-based operations.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Encryption.java |
4/5 | Added encryptString method for direct string encryption without file I/O |
AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Decryption.java |
4/5 | Added decryptString method for direct string decryption without file I/O |
AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Main.java |
3/5 | Major refactor to menu-driven interface with console mode, but has resource management issues |
Confidence score: 3/5
- This PR requires careful review due to potential resource leaks and missing method dependencies
- Score lowered due to Scanner objects being created in loops without proper closure, missing package declaration, and assumptions about method existence that need verification
- Pay close attention to Main.java for resource management issues and verify that all referenced methods exist in the fileHandle and Testing classes
Sequence Diagram
sequenceDiagram
participant User
participant Main
participant Scanner
participant Encryption
participant Decryption
participant Mapping
User->>Main: "Start application"
Main->>Main: "runMenu()"
loop Menu Loop
Main->>User: "Display menu options (1-5)"
User->>Scanner: "Enter choice"
Scanner->>Main: "Return choice"
alt Choice is "4" (Console Mode)
Main->>Main: "handleConsoleMode(scanner)"
Main->>User: "Enter string to process:"
User->>Scanner: "Input string"
Scanner->>Main: "Return input string"
alt Input validation passes
Main->>Encryption: "encryptString(input)"
Encryption->>Mapping: "applyAtbashCipher(input)"
Mapping->>Encryption: "Return encrypted string"
Encryption->>Main: "Return encrypted result"
Main->>Decryption: "decryptString(encrypted)"
Decryption->>Mapping: "applyAtbashCipher(encrypted)"
Mapping->>Decryption: "Return decrypted string"
Decryption->>Main: "Return decrypted result"
Main->>User: "Display Original/Encrypted/Decrypted"
else Input is empty
Main->>User: "Input cannot be empty"
end
else Choice is "5" (Exit)
Main->>User: "Exiting the utility"
Main->>Main: "return (exit loop)"
else Other choices (1,2,3)
Main->>Main: "Handle file operations/tests"
else Invalid choice
Main->>User: "Invalid option. Please try again."
end
end
3 files reviewed, 5 comments
| fileHandle.writeFile(encryptedData, FillB); | ||
| // it is calld Savefill from handler use for reuslt to fillb | ||
| } | ||
| public static String encryptString(String message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Inconsistent indentation - method should align with the existing method above
Prompt To Fix With AI
This is a comment left during a code review.
Path: AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Encryption.java
Line: 20:20
Comment:
**style:** Inconsistent indentation - method should align with the existing method above
How can I resolve this? If you propose a fix, please make it concise.| // it is calld Savefill from handler use for reuslt to fillb | ||
| } | ||
| public static String encryptString(String message) { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Empty line not needed here
Prompt To Fix With AI
This is a comment left during a code review.
Path: AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Encryption.java
Line: 21:21
Comment:
**style:** Empty line not needed here
How can I resolve this? If you propose a fix, please make it concise.| fileHandle.writeFile(decryptedData, FillB); | ||
| // Save the decrypted data to FillB | ||
| } | ||
| public static String decryptString(String message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Inconsistent indentation - should align with other method declarations
Prompt To Fix With AI
This is a comment left during a code review.
Path: AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Decryption.java
Line: 18:18
Comment:
**style:** Inconsistent indentation - should align with other method declarations
How can I resolve this? If you propose a fix, please make it concise.| import java.util.Scanner; | ||
|
|
||
| public class Main { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Package declaration was removed - this may cause compilation issues if other classes expect this to be in the com.example package
Prompt To Fix With AI
This is a comment left during a code review.
Path: AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Main.java
Line: 1:3
Comment:
**logic:** Package declaration was removed - this may cause compilation issues if other classes expect this to be in the com.example package
How can I resolve this? If you propose a fix, please make it concise.| Scanner scanner = new Scanner(System.in); | ||
| String choice = scanner.nextLine().trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Scanner is created inside the loop but never closed, causing resource leaks. Create one Scanner outside the loop and reuse it
Prompt To Fix With AI
This is a comment left during a code review.
Path: AtbashCipher/cipher2/cipher2/demo/src/main/java/com/example/Main.java
Line: 23:24
Comment:
**logic:** Scanner is created inside the loop but never closed, causing resource leaks. Create one Scanner outside the loop and reuse it
How can I resolve this? If you propose a fix, please make it concise.
No description provided.