008-001-011
Method Definition: Method Collaboration
Hard
Problem Description
method Definition: method Collaboration
In this problem, you will create a StringProcessor class where process() calls both addPrefix() and addSuffix(), then read a string from standard input and print the decorated result.
Learning Objective: Understand how to call one method from another
Overview
Create a class where multiple methods work together.
Specifications
- Create a
StringProcessorclass addPrefix(String s)adds '>>' to the beginning of the string and returns itaddSuffix(String s)adds '<<' to the end of the string and returns itprocess(String s)calls bothaddPrefixandaddSuffixand returns the combined result- In the
Mainclass, read one line from standard input and print the result ofprocess()
Input
A string (one line)
Output
>>string<<
Input/Output Examples
Input: Hello
Output: >>Hello<<
Input: World
Output: >>World<<
Input: (empty string)
Output: >><<
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up