Question
Text message abbreviation decoder (Java) (1) Complete the following method: /** * Decodes the text abbreviation. * * @param textAbbr Text abbreviation. * @return The
Text message abbreviation decoder (Java)
(1) Complete the following method:
/** * Decodes the text abbreviation. * * @param textAbbr Text abbreviation. * @return The decoded abbreviation if known. Otherwise, returns Unknown. */ public static String decTextAbbr(String textAbbr) { // FILL IN BODY }
If the parameter matches a known text message abbreviation, return the unabbreviated form, else return: Unknown. Support two abbreviations:
LOL -- laughing out loud, and
IDK -- I don't know.
For example:
decTextAbbr("LOL")
returns
laughing out loud
(2) Write a testing method to verify this method works for all expected inputs:
/** * Runs tests on the decTextAbbr method. */ public static void testDecTextAbbr() { System.out.println( "decTextAbbr(\"LOL\") expected 'laughing out loud', actual '" + decTextAbbr("LOL") + "'"); System.out.println( /* FIX ME */); System.out.println( /* FIX ME */); }
Run this test method from the main method to verify the decTextAbbr method is working correctly.
(3) Expand the method to also decode these abbreviations.
- IMHO -- in my humble opinion
- TMI -- too much information
- BFF -- best friends forever
- ROFL -- rolling on floor laughing
- LMK -- let me know
extend the testDecTextAbbr() method to also verify these cases work correctly. When complete, your testDecTextAbbr() method should have at least 6 tests.
TextMsgExpander.java
public class TextMsgExpander { /* Add your methods here */ public static void main(String[] args) { } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started