/**
*
* @author hamza
*/
public class Caesar_Chipher {
// This is where I call my functions
public static void main(String[] args) {
userChoice();
}
//User chooses 1 or 2 to encrypt or decrypt
public static void userChoice() {
Scanner input = new Scanner(System.in);
System.out.print("Enter your choice, 1 = encrypt, 2 = decrypt: ");
int userchoice;
userchoice = input.nextInt();
if (userchoice == 1) {
offsetNumber();
message();
System.out.println(plaintext + shift);
}
if (userchoice == 2) {
offsetNumber();
message();
System.out.println(plaintext + shift);
}
else {
userChoice();
}
}
public static void offsetNumber() {
Scanner offset = new Scanner(System.in);
System.out.print("Enter your shift number: ");
int shift;
shift = offset.nextInt();
if (shift < 27) {
message();
}
}
public static void message() {
Scanner Message = new Scanner(System.in);
System.out.print("Enter your message: ");
String plaintext;
plaintext = Message.next();
}
}
我的代码有什么问题?当有人加密时,我希望明文移动 n,而当有人解密时,我希望明文移动 -n。