
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
Please help solve this Java problem. Source code for MessageEncoder.java and MessageDecoder.Java is below.
Filename: MessageEncoder.java
public interface MessageEncoder {
/**
* The method that encodes text
* @param plainText the text to encode
* @return the encoded text
*/
public abstract String encode(String plainText);
}
Filename: MessageDecoder.Java
public interface MessageDecoder {
/**
* This method will decode the cypher text
* @param cipherText the encoded message
* @return the decoded text
*/
public abstract String decode(String cipherText);
}

Transcribed Image Text:Create the classes SubstitutionCipher and ShuffleCipher, as described below:
1. SubstitutionCipher implements the interfaces MessageEncoder and MessageDecoder.
The constructor should have one parameter called shift. Define the method encode so that
each letter is shifted by the value in shift. For example, if shift is 3, a will be replaced
by d, b will be replaced by e, c will be replaced by f, and so on. (Hint: You may wish to
define a private method that shifts a single character.)
2. ShuffleCipher that implements the interface MessageEncoder and MessageDecoder. The
constructor should have one parameter called n. Define the method encode so that the
message is shuffled n times. To perform one shuffle, split the message in half and then
take characters from each half alternately. For example, if the message is abcdefghi, the
halves are abcde and fghi. The shuffled message is afbgchdie. (Hint: You may wish to
define a private method that performs one shuffle.)
3. Create a JavaFX application that uses a TextField to get a message and encode or decode
it using the classes described above. Use buttons to control the kind of cipher used and to
specify whether to encode or decode the message. Also use a TextField to get the number
used in the constructor for the ciphers. Also include a counter to show the number of
messages encoded or decoded.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In Java can you help me fix what is missing MailBox- client:String- emails: Email[]- actualSize: int+ Mailbox()+ Mailbox(client:String)+ getClient(): String+ getEmail(int index): Email+ getActualSize(): int+ addEmail(email: Email): void+ sortEmailsByDate(): void+ findEmail(year:int: Email+ countUrgent():int+ toString(): String public class Mailbox { private String bradsInbox; private Email[] emails; privateintactualSize; public Mailbox() { Email[] emails = new Email[15]; actualSize = 0; } public Mailbox(String bradsInbox) { this.bradsInbox = bradsInbox; } public String getBradsInbox() { returnbradsInbox; } public Email[] getEmails() { returnemails; } publicint getActualSize() { returnactualSize; } publicvoid addEmail(Email email) { if (this.actualSize >= 15) { System.out.println("You have reached maximum capacity. Upgrade your account. "); } } publicvoid sortEmailsByDate() { } public Email findEmail(intyear) { for (inti = 0; i < this.actualSize; i++) {…arrow_forwardHow should I add a main to the Java code? import java.util.*; import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10]; } // overloaded parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = castMembers.length; this.castMembers = new String[numCastMembers]; for (int i = 0; i < castMembers.length; i++) { this.castMembers[i] = castMembers[i]; } } // set the number of minutes public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } // set the movie name public void setMovieName(String…arrow_forwardIn Java MailBox- client:String- emails: Email[]- actualSize: int+ Mailbox()+ Mailbox(client:String)+ getClient(): String+ getEmail(int index): Email+ getActualSize(): int+ addEmail(email: Email): void+ sortEmailsByDate(): void+ findEmail(year:int: Email+ countUrgent():int+ toString(): String Write java code for all the methods shown on the class diagram. Below arethe details needed for the different methods:a. The default constructor will assign the client a default name (any value ofyour choice). Keep in mind that a single mailbox (e.g., gmail) can handle amaximum of 15 emails, but it can hold less, which is the actual size of theemails array. So, the constructor should instantiate the emails arrayinstance variable by creating an array of size 15. It should also set theactualSize variable to 0.b. The MailBox (String client) constructor should call the default constructorusing chaining. It should then initialize the client variable using the clientparameter.c. The toString method…arrow_forward
- using java programming code the followingarrow_forwardHow do I fix the code? import java.util.*; import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10]; } // overloaded parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = castMembers.length; this.castMembers = new String[numCastMembers]; for (int i = 0; i < castMembers.length; i++) { this.castMembers[i] = castMembers[i]; } } // set the number of minutes public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } // set the movie name public void setMovieName(String movieName) { this.movieName…arrow_forwardIn Java: Write a program that removes all spaces from the given input. Ex: If the input is: Hello my name is John. the output is: HellomynameisJohn. Your program must define and call the following method. The method should return a string representing the input string without spaces.public static String removeSpaces (String userString) import java.util.Scanner; public class LabProgram {/* Define your method here */public static void main(String[] args) {/* Type your code here. */}}arrow_forward
- How do I make the code work? Code: import java.util.*; import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10]; } // overloaded parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) {this.movieName = movieName;this.numMinutes = numMinutes;this.isKidFriendly = isKidFriendly;this.numCastMembers=0;this.castMembers=new String[castMembers.length];for(int i=0;i<castMembers.length;++i){this.castMembers[i] = castMembers[i];if(castMembers[i]!=null)this.numCastMembers++;} }// set the number of minutes public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } // set the movie name public void setMovieName(String…arrow_forwardprogram that takes a first name as the input, and outputs a welcome message to that name. Ex: If the input is: Chrystal the output is: Hey Chrystal! Welcome to zyBooks!arrow_forwardWrite a java program with a method that reverses a string The method must accept one parameter of type String (string to reverse), and returns every second element from the end to the beginning. For example: String: thisisstringResult is: g i t s s harrow_forward
- How do I make the code output Java? import java.util.Arrays; public class Movie { String movieName; int numMinutes; boolean isKidFriendly; int numCastMembers; String castMembers[] = new String[10]; // Non-parameterized constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; } // Parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, int numCastMembers, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = numCastMembers; this.castMembers = castMembers; } // getter and setters public String getMovieName() { return movieName; } public void setMovieName(String movieName) { this.movieName = movieName; } public int getNumMinutes() { return numMinutes; } public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } public boolean isKidFriendly() { return…arrow_forwardjava programming I have a Java program with a restaurant/store menu. Can you please edit my program when displaying the physical receipt? I would like the physical receipt to export a PDF file, not printing the order receipt in the console. import java.util.*; public class Restaurant2 { publicstaticvoidmain(String[] args) { // Define menu items and pricesString[] menuItems= {"Apple", "Orange", "Pear", "Banana", "Kiwi", "Strawberry", "Grape", "Watermelon", "Cantaloupe", "Mango"};double[] menuPrices= {1.99, 2.99, 3.99, 4.99, 5.99, 6.99, 7.99, 8.99, 9.99, 10.99};StringusersName; // The user's name, as entered by the user.ArrayList<String> arr = new ArrayList<>(); // Define scanner objectScanner input=new Scanner(System.in); // Welcome messageSystem.out.println("Welcome to AppleStoreRecreation, what is your name:");usersName = input.nextLine(); System.out.println("Hello, "+ usersName +", my name is Patrick nice to meet you!, May I Take Your Order?"); // Display menu items…arrow_forwardJAVA Practice Question for Midterm Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the number of vowels in the string, and another method that returns the number of consonants in the string. Demonstrate the class in a program by invoking the methods that return the number of vowels and consonants. Print the counts returned. Imagine you are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: The password should be at least six characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. a program that asks the user to enter a password, then displays a message indicating whether it is valid or not.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education