Tugas Array dan Inheritance Kelompok 09


KELOMPOK 9 KELAS SI4003

IRENE IRAWATY (1202160043)

STEFI MUTIA SARI (1202160051)

KARINA TARIGAN (1202164188)

NO 2.
a. Soal

Create an interface MessageDecoder that has a single abstract method decode(cipherText), where cipherText is the message to be decoded. The method will return the decoded message. Modify the classes SubstitutionCipher and ShuffleCipher, as described in Exercises 16 and 17, so that they implement MessageDecoder 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.

b. Penjelasan soal

Jadi ini adalah untuk membuat MessageDecoder antarmuka yang memiliki metode abstrak tunggal decode (ciphertext),Memodifikasi kelas SubstitutionCipher dan ShuffleCipher, dan bagaimana menerapkan MessageDecoder serta MessageEncoder

c. Script kode

package javaapplication49;

/**
*
* @author KARINA
*/
public class JavaApplication49 {

public static void main(String[] args) {

private int shift;
{
public interface Message Decoder
{
public String decode(String cipher text);
{
}
}
public interface Message Encoder
{
public String encode(String plain text);
{ character c;
String ciher text = ” “;
for (int i = 0, i < plaintext.length, i++)
{c = plaintext char At(i);
cipher text = cipher text + code character
}
return cipher text;
}
private character code character (character, 6)
{
return (char)(ct shift)j;
}
}


Leave a Reply