Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Star Trek Java program You have been tasked with implementing Star Trek's Universal Translator for today's cell phones. Your assignment is to allow a Trekkie

Star Trek Java program

You have been tasked with implementing Star Trek's Universal Translator for today's cell phones.

Your assignment is to allow a Trekkie to send a text message in any language and have it received it any language.

So far, you only need to be able to translate from Earth languages to Vulcan, Klingon, Ferrengi. However, you need to make your design flexible enough to add additional languages.

Since the main purpose of the assignment is File I/O, Exception Handling and the Adapter Pattern, we will not be coding a complete Universal Translator. All you will need to be able to do is send messages from Earth cell phones to other Earth cell phones, and from Earth cell phones to the Federation Alien languages mentioned above.

You will also need to create a custom exception for languages that are not supported should they be requested.

To simulate the interaction, you will read/write text messages from a file.

You can use any process you would like to do the translation. You might load a small dictionary file(s) and read them into your program. You can maniuplate the words or characters using any algorithm you might like. Remember, the emphasis of this assignment is the exception handling and using the Adapter Design Pattern.

For all programs, catch and handle the Exceptions appropriately and validate the input data where needed.

Also, create your own exception to handle "unknown language" exceptions.

Hints:

Use the Media Adapter example as a template.

You will need both the EarthCellPhone and AlienCellPhone that are provided:

public interface EarthCellPhone { public void sendMessage(String languageType, String fileName) throws InvalidLanguageException; public void readMessage(String languageType, String fileName); } 
public interface AlienCellPhone { public void sendText(String languageType, String fileName); public void readText(String languageType, String fileName); public void translateText(String languageType, String fileName); } 

You will need classes that implement these interfaces.

The Alien cell phones do not need to be able to send messages but must be able to read and translate.

After you translate an Earth message to the appropriate Alien language, have the translate method call the Alien readMessage method. The implementation details for methods were not provided.

Recommendations:

In your user interface, ask the Earth user if he wants to read a message or send a message. If the user wants to send a message, he will need to specify the type of language understood by the recipient. In either case, he will need to specify a filename to save/ read the message.

To send a message, prompt the user for the text and write it to a file.

To read a message, read it from a file.

To send a message to a recipient that speaks an Alien language, it must be translated first before it can be read.

Along with reading/writing to a file, print the contents to the console for verification.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+and reduction in force, and intellectual property.

Answered: 1 week ago