Create a class ShuffleCipher that implements the interface MessageEncoder, as described in Exercise 15. The constructor should have one parameter caned n. Define the method encode so that the message is snuffled n times. To perform one shuffle, split the message in hair 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 afbgchcie. (Hint. You may wish to define a private method that performs one shuffle.)
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
SURVEY OF OPERATING SYSTEMS
Degarmo's Materials And Processes In Manufacturing
Starting Out with C++ from Control Structures to Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (4th Edition)
- Use Java.arrow_forward53. Write a class with two instance variables, representing an old password and a new password. Write a recursive method that returns the number of places where the two passwords have different characters. The passwords can have different lengths. Write another, nonrecursive method returning whether the two passwords are sufficiently different. The method takes an int parameter indicating the minimum number of differences that qualify the passwords as being sufficiently different. Your program should include a client class to test your class.arrow_forwardFor the programming language Javaarrow_forward
- Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor n / f. This assignment needs a resource class and a driver class; these two classes will need to be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code. The code needs to be written in Java.arrow_forwardWhat is the solution for this question (using java language)arrow_forwardImplement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. Create array of countries called Arab of 22 countries. Write a function fill that fills the array Arab Write a method that finds the city that has the max area in a country Write a method that sorts the cities in a country from the largest to the smallest area Write a function that returns array of countries of the same area of Arab Write a function that compares between two countries. It returns true if country1 area greater than country2 area. Write a function to move a city from one country to another.arrow_forward
- Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. Create array of countries called Arab of 22 countries. Write a function fill that fills the array Arab Write a method that finds the city that has the max area in a country Write a method that sorts the cities in a country from the largest to the smallest area Write a function that returns array of countries of the same area of Arab Write a function that compares between two countries. It returns true if country1 area greater than country2 area. Write a function to move a city from one country to another.arrow_forwardIn java language Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle object by providing the width and length in that order. If no width and length are provided to the constructor, construct a Rectangle with width 0.0 and length 0.0. We want to be able to get and set both the width and the length independently. We also want to be able to ask for the area of the rectangle and the perimeter of the rectangle. What will the object need to remember? width and length - those are the instance variables. Rectangle class has these constructors : public Rectangle() - Constructs a new rectangle with width and length of 0.0. public Rectangle(double width, double length) - Constructs a new rectangle with the given width and length. Remember that the job of the constructor is to initialize the instance variables. It has these methods. public double getWidth() - Gets the width of this Rectangle public double getLength() - Gets the length of this…arrow_forwardIn java language Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle object by providing the width and length in that order. If no width and length are provided to the constructor, construct a Rectangle with width 0.0 and length 0.0. We want to be able to get and set both the width and the length independently. We also want to be able to ask for the area of the rectangle and the perimeter of the rectangle. What will the object need to remember? width and length - those are the instance variables. Rectangle class has these constructors : public Rectangle() - Constructs a new rectangle with width and length of 0.0. public Rectangle(double width, double length) - Constructs a new rectangle with the given width and length. Remember that the job of the constructor is to initialize the instance variables. It has these methods. public double getWidth() - Gets the width of this Rectangle public double getLength() - Gets the length of this…arrow_forward
- Write the definitions of the member functions of the classes arrayListType and unorderedArrayListType that are not given in this chapter. The specific methods that need to be implemented are listed below. Implement the following methods in arrayListType.h: isEmpty isFull listSize maxListSize clearList Copy constructor Implement the following method in unorderedArrayListType.h insertAt Also, write a program (in main.cpp) to test your function.arrow_forwardProblem No. 2 Write a Java class called ContainsInRange. This class defines a method called contains(), which takes as parameters an integer array a, an integer x, an int called start, as well as an int called end, and returns a boolean which is true if and only if x occurs in a at a position which is greater than or equal to start, and less than end. You must validate that start is less than or equal to end, and that both start and end are greater than or equal to 0, and less than or equal to a.length. Repeat the operation often. (please put also the code that the user can enter a value. Thank you)arrow_forwardCreate a class with a method. The method has to decide whether a given year is a leap year or not. Note- A year is a leap year if: • It has an extra day i.e. 366 instead of 365. It occurs in every 4 year e.g. 2008, 2012 are leap years. For every 100 years a special rule applies-1900 is not a leap year but 2000 is a leap year. In those cases, we need to check whether it is divisible by 400 or not. > > ClassAssignmentEx2 ©LeapYearDecider javaclassnotes.assignments javaclassnotes.assignments ClassAssignmentEx2() LeapYearDecider() main(String):void A isLeapYear(int):booleanarrow_forward
- 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