Question
Write a Java GUI program that contains the following class, i.e., class SecretCode. Please refer to the given UAL diagram for the minimum required class's
Write a Java GUI program that contains the following class, i.e., class SecretCode. Please refer to the given UAL diagram for the minimum required class's data fields and methods. You arc free to add additional class members as you see fit.
The GUI program allows the user to Input a String literal, and the program shall display an encoded String literal as an output.
The method shift char ( ) handles the encoding process by executing the following steps:
Step 1: Accept a string literal, i.e., inputString.
Step 2: Perform a check (using method checkstringvalidity()} to ensure the String literal ONLY contain 'a' to 'z' or whitespace. If thls condition is not met, prompt user fora new input.
Step 3: Compute the number of characters inside inputString, excluding whitespace(s).
Step 4: For each character in inputString, shift it forward n position(s), with n equals to the number of characters (excluding whitespace (s)) inside inputString. The characters are arranged inside a cyclic structure, see Figure 2.
For example, a String literal “zoo kch” has a length of 6 characters. Thus, the encoded output is:
The encoded String literal: “euufqin”
Step 5: the method returns the encoded string literal for display.
SecretCode -inputstring: string -stringLength: int. -outputstring: String +Secretcode(O +Secretode(inputstring: String) +getstringlength(inputString: String): int +checkstringvlidity(inputstring: string): boolean +shiftChar(inputString: String, stringLength: int): String
Step by Step Solution
3.45 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
SOURCE CODE package comyourname import javautilScanner import javautilregexPattern public class Secr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started