Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8, Problem 15E
Create an interface MessageEncoder that has a single abstract method encode(plainText), where, plaintext is the message to be encoded. The method will return the encoded message.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
15. Create an interface MessageEncoder that has a single abstract method
encode (plainText), where plainText is the message to be encoded. The
method will return the encoded message.
Create an interface MessageDecoder that has a single abstract method decode(cipherText), where cipherText is the message to be decoded.The method will returnthe decoded message.
Create a class SubstitutionCipher that implements the interface MessageDecoder as described above. The constructorshould have one parameter called shift. Define the method decode so that each letter is shifted by the value in the shif. For example, if shift is 3, a will be replaced by d, b will be replaced bt e, c will be replaced by f, and so on. Hint: You may wish to define a private methodthat shifts a single character.
Create a class ShuffleCipher that implements the interface MessageDecoder. The constructor should haveone parameter called n. Define the method decode so that the message is shuffledn times.To perform one shuffle, split the message in half and then take the charactersfrom each half alternatively. For example, if the messsage is "abcdefghi", the halves are "abcde" and "fghi". The shuffled…
5. Create an interface MessageDecoder that has a single abstract method
decode (cipherText), where cipher Text is the message to be decoded.
The method will return the decoded message. Modify the classes
8.5 Graphics Supplement
SubstitutionCipher and ShuffleCipher, as described in Exercises 16
and 17, so that they implement Message Decoder as well as the interface
MessageEncoder that Exercise 15 describes. Finally, write a program that
allows a user to encode and decode messages entered on the keyboard.
703
Chapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 8.1 - Prob. 1STQCh. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Can a derived class directly access by name a...Ch. 8.1 - Can a derived class directly invoke a private...Ch. 8.1 - Prob. 6STQCh. 8.1 - Suppose s is an object of the class Student. Base...Ch. 8.2 - Give a complete definition of a class called...Ch. 8.2 - Add a constructor to the class Student that sets...Ch. 8.2 - Rewrite the definition of the method writeoutput...
Ch. 8.2 - Rewrite the definition of the method reset for the...Ch. 8.2 - Can an object be referenced by variables of...Ch. 8.2 - What is the type or types of the variable(s) that...Ch. 8.2 - Prob. 14STQCh. 8.2 - Prob. 15STQCh. 8.2 - Consider the code below, which was discussed in...Ch. 8.2 - Prob. 17STQCh. 8.3 - Prob. 18STQCh. 8.3 - Prob. 19STQCh. 8.3 - Is overloading a method name an example of...Ch. 8.3 - In the following code, will the two invocations of...Ch. 8.3 - In the following code, which definition of...Ch. 8.4 - Prob. 23STQCh. 8.4 - Prob. 24STQCh. 8.4 - Prob. 25STQCh. 8.4 - Prob. 26STQCh. 8.4 - Prob. 27STQCh. 8.4 - Prob. 28STQCh. 8.4 - Are the two definitions of the constructors given...Ch. 8.4 - The private method skipSpaces appears in the...Ch. 8.4 - Describe the implementation of the method drawHere...Ch. 8.4 - Is the following valid if ShapeBaSe is defined as...Ch. 8.4 - Prob. 33STQCh. 8.5 - Prob. 34STQCh. 8.5 - What is an advantage of having the main...Ch. 8.5 - What Java construct allows us to define and...Ch. 8 - Consider a program that will keep track of the...Ch. 8 - Implement your base class for the hierarchy from...Ch. 8 - Draw a hierarchy for the components you might find...Ch. 8 - Suppose we want to implement a drawing program...Ch. 8 - Create a class Square derived from DrawableShape,...Ch. 8 - Create a class SchoolKid that is the base class...Ch. 8 - Derive a class ExaggeratingKid from SchoolKid, as...Ch. 8 - Create an abstract class PayCalculator that has an...Ch. 8 - Derive a class RegularPay from PayCalculator, as...Ch. 8 - Create an abstract class DiscountPolicy. It should...Ch. 8 - Derive a class BulkDiscount from DiscountPolicy,...Ch. 8 - Derive a class BuyNItemsGetOneFree from...Ch. 8 - Prob. 13ECh. 8 - Prob. 14ECh. 8 - Create an interface MessageEncoder that has a...Ch. 8 - Create a class SubstitutionCipher that implements...Ch. 8 - Create a class ShuffleCipher that implements the...Ch. 8 - Define a class named Employee whose objects are...Ch. 8 - Define a class named Doctor whose objects are...Ch. 8 - Create a base class called Vehicle that has the...Ch. 8 - Create a new class called Dog that is derived from...Ch. 8 - Define a class called Diamond that is derived from...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PPCh. 8 - Prob. 4PPCh. 8 - Create an interface MessageDecoder that has a...Ch. 8 - For this Programming Project, start with...Ch. 8 - Modify the Student class in Listing 8.2 so that it...Ch. 8 - Create a JavaFX application that uses a TextField...Ch. 8 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Determine the angle between the force and the line OA.
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
How much time will be required to drill the hole in Problem 1 using the HSS drill?
Degarmo's Materials And Processes In Manufacturing
Big data Big data describes datasets with huge volumes that are beyond the ability of typical database manageme...
Management Information Systems: Managing The Digital Firm (16th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
What is the advantage of making frequent checkpoints of a database?
Database Concepts (8th Edition)
ICA 8-18
You have been working to develop a new fictitious compound in the lab. Determine the amount in units o...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
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
- Design ADT for a cave and a cave system. An archeologist should be able to add a newly discovered cave to a cave system and to connect two caves together by a tunnel. Duplicate caves—based on GPS coordinates—are not permitted. Archeologists should also be able to list the caves in a given cave system. Specify each ADT operation by stating its purpose, describing its parameters, and writing a pseudocode version of its header. Then Java interface for a cave's methods and one for the methods of a cave system. Include javadoc-style comments in your code. Java programarrow_forwardWrite a Program in Java Create an interface EnhancedShape that extends Shape and also requires a method public double perimeter( ) to be implemented by any class that uses the interface. (Note: Interfaces can inherit other interface just like a class by using extends keyword. Create a class file, an interface ehancedshape extends shape, and an interface shape file).arrow_forwardonly in java not in java c++ Create an interface EnhancedShape that extends Shape and also requires a method public double perimeter( ) to be implemented by any class that uses the interface. Create a class file, an interface ehancedshape extends shape, and an interface shape file.arrow_forward
- Write a Program in java Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area(); Implement the Shape interface for Rectangle, Circle and Triangle class. Implement a class CalculateAreas that has a function that takes shape type array of objects and builds an array of (double values) values for each corresponding shapesarrow_forwardDeclare an interface IA with two method Me() and You() in JAVA . Define two classes CA and CB which implement IA such that Me in CA displays it is me in CA and You in CA displays how are you from CA. The same message should be displayed from CB. Use the reference variable of the IA to implement runtime polymorphism.arrow_forwardWtite a program in java language also give source code and output also.arrow_forward
- Design a Java interface called Priority that includes two methods: setPriority and getPriority. This interface would define a way to establish numeric priority among a set of objects. Your numeric priority values should be on a scale. For easy comparing of priorities, make 1 the lowest priority. It should be more complex than just 1, 2, 3 (low, medium, high). Define constants in the interface for the low, medium, and high priority values. Design and implement a class called Task that represents a task (e.g., something on a to-do list) that implements the Priority interface from above, as well as the Comparable interface from the Java standard class library. A task should have some sort of description. Illustrate your design with a UML class diagram. Create a driver whose main method exercises some Task objects. Make sure you have enough tasks to produce comparisons where a given task is higher, lower, or equal in priority to some other task. Implement the interface such that the tasks…arrow_forwardJava provides one interface to sort objects of user defined types. What is the name of this interface type. Use an example to describe how to implement this interface.arrow_forwardYour assignment for this course is to implement a beginner level Book Management System (BMS) in Java language. BMS contains 2 classes: Bookand BookList. The Book class has the following attributes: code: a String object, that hold the book’s code. title: a String object, that hold the book’s title. qua: int variable, that hold the number of books with the same code in the library. price: a double variable, that hold the book’s price. The BookList class contains only one data member: ArrayList<Book> t. When running the program display the menu as below:1. Input & add book(s) to the end.2. Display all books.3. Search a book for given code.4. Update the book’s price for given code.5. Find the (first) max price value.6. Sort the list ascendingly by code.7. Remove the book having given code.8. Load data from file.0. Exit.Notes:(1) The book’s code must be unique in the list.(2) Display all books in format (code, title, quantity, price).(5)…arrow_forward
- Java programarrow_forwardJava - Interface 1. Create an interface Employee which has the attribute: rate, and the method getSalary(). 2. Implement the Employee interface with two classes: Hourly and Commissioned. 3. Hourly employee has the following additional attribute: hoursWorked. Hourly wage is 300 money. 4. Commissioned employee has the following additional attribute: itemSold. Commissioned employees get 200 money per item sold. If item sold is greater than 100, any items sold after 100 has +10 money bonus. Inputs 1. First line contains the type of Employee (H or C) 2. Second line is for the hours worked or the items sold depending on the type of employee Sample Output Enter type of employee: H Enter hours worked: 10 Salary: 3000arrow_forwardThe Doctor program described in Chapter 5 combines the data model of a doctor and the operations for handling user interaction. Restructure this program according to the model/view pattern so that these areas of responsibility are assigned to separate sets of classes. The program should include a Doctor class with an interface that allows one to obtain a greeting, a signoff message, and a reply to a patient’s string. To implement the greeting, define a method named greeting for the Doctor class. To implement the signoff message, define a method named farewell for the Doctor class. Both greeting and farewell should return a string with a greeting or farewell message respectively. The reply function is defined for you, it should be added as a method for the Doctor class. The rest of the program, in a separate main program module, handles the user’s interactions with the Doctor object. Develop this program with a terminal-based user interface. Note: The program should output in the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License