Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Talker
- {
- private String text;
- // Constructor
- public Talker(String startingText)
- {
- text = startingText;
- }
- // Returns the text in all uppercase letters
- // Find a method in the JavaDocs that
- // will allow you to do this with just
- // one method call
- public String yell()
- {
- String sub = text.toUpperCase();
- return sub;
- }
- // Returns the text in all lowercase letters
- // Find a method in the JavaDocs that
- // will allow you to do this with just
- // one method call
- public String whisper()
- {
- String sub = text.toLowerCase();
- return sub;
- }
- // Reset the instance variable to the new text
- public void setText(String newText)
- {
- text = newText;
- System.out.println(text);
- }
- // Returns a String representatin of this object
- // The returned String should look like
- //
- // I say, "text"
- //
- // The quotes should appear in the String
- // text should be the value of the instance variable
- public String toString()
- {
- return "I say, \""+text+"\"";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement