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
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…
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.
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
Notice the definition of the member function input of the class Money given in Display 11.3. If the user enters...
Problem Solving with C++ (10th Edition)
Practice Problem 8.5 (solution page 797) Write a wrapper function for sleep, called snooze, with the following ...
Computer Systems: A Programmer's Perspective (3rd Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
In Exercises 1 through 52, determine the output produced by the lines of code. DimintRate,doublingTimeAsDecimal...
Introduction To Programming Using Visual Basic (11th Edition)
A static member variable is declared in a class. Where is the static member variable defined?
Starting Out with C++ from Control Structures to Objects (9th Edition)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
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
- Write 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_forwardWrite 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_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
- Declare 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_forwardDesign 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_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 - 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_forwardWrite a program in java language  Create an interface EnhancedShape that extends Shape (From question 3) and also requires a method public double perimeter( ) to be implemented by any class that uses the interface.  Question 3 Define an interface named Shape with a single method named area thatcalculates the area of the geometric shape: public double area(); Next,define a class named Circle that implements Shape . The Circle class shouldhave an instance variable for the radius, a constructor that sets the radius,accessor/ mutator methods for the radius, and an implementation of thearea method. Also define a class named Rectangle that implements Shape .The Rectangle class should have instance variables for the height andwidth, a constructor that sets the height and width, accessor and mutatormethods for the height and width, and an implementation of the areamethod.arrow_forwardwrite a program to implement the above interface using Lambda Expression to accept “ Hello World” and print it 10 times.  write a program to implement the above interface using Inner Class to accept “ Hello World” and print it 10 times   This is my code    interface interf1 {  publicvoidrepeat(Strings1); }    public class Main {    public static void main(String[] args) {   interf1 obj = (s1)-> { //using lambda expression    for(int i=0;i<10;i++) {        System.out.println(s1);    }        };       obj.repeat("Hello World");  } }  public class Assignment {   public static void main(String[] args) {  interf1 obj = new interf1() { //inner class       public void repeat(String s1){        for(int i=0;i<10;i++){        System.out.println(s1);             }      }        };    obj.repeat("Hello World"); //function call  } }   But i keep getting this errorarrow_forward
- Write a java interface code class that will work on moodle code runner according to the instructions below: 1. Write an interface name InterfaceSet with the following components:  Attribute: max an integer variable initialize to 10, static and final  Method signatures:  - public void add(int e) -> this method adds e in an array., e is not added in the array if e already exists in the array. Attribute count in increment every successful add of e. - public void display( ) -> display the contents of the array (NOTE: the array is an attribute in the class later) - public int count( ) -> returns the value of count (NOTE: count is an attribute in the class later) - public boolean isElementOf(int e) -> returns true if e is in the array false if not - public int getElement(int index) -> returns the value in array at index - public Set union(Set s) -> returns the union    Example:   current Object set[] ={1,2,3};    Set s[] = {1,3,10,5};   returns: Set…arrow_forwardwrite a program to implement the above interface using Lambda Expression to accept “ Hello World” and print it 10 times.  write a program to implement the above interface using Inner Class to accept “ Hello World” and print it 10 times This is my code interface interf1 { publicvoidrepeat(Strings1); }  public class Main {  public static void main(String[] args) {   interf1 obj = (s1)-> { //using lambda expression    for(int i=0;i<10;i++) {        System.out.println(s1);    }        };       obj.repeat("Hello World");  } } public class Assignment {  public static void main(String[] args) {  interf1 obj = new interf1() { //inner class       public void repeat(String s1){        for(int i=0;i<10;i++){        System.out.println(s1);             }      }        };    obj.repeat("Hello World"); //function call  } } But i keep getting this error Exception in thread "main" java.lang.NoClassDefFoundError:…arrow_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