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.

SecretCode -inputstring: string -stringLength: int. -outputstring: String +Secretcode(O +Secretode(inputstring: String) +getstringlength(inputString: String):

  

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.

int +checkstringvlidity(inputstring: string): boolean +shiftChar(inputString: String, stringLength: int): String

 

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

1 Expert Approved Answer
Step: 1 Unlock

To create a Java GUI program with the SecretCode class that encodes a given string well design both the class and a simple GUI Lets break this into st... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!