Skip to content

Conversation

@zaina-e
Copy link
Owner

@zaina-e zaina-e commented Oct 11, 2025

No description provided.

Copy link

@greptile-apps greptile-apps bot left a 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
Loading

3 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

fileHandle.writeFile(encryptedData, FillB);
// it is calld Savefill from handler use for reuslt to fillb
}
public static String encryptString(String message) {
Copy link

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) {

Copy link

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) {
Copy link

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.

Comment on lines 1 to 3
import java.util.Scanner;

public class Main {
Copy link

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.

Comment on lines +23 to +24
Scanner scanner = new Scanner(System.in);
String choice = scanner.nextLine().trim();
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants