forked from haonlywan/CodeHS-Java-APCSA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.8.6 Speaking (Part 2)
46 lines (41 loc) · 1.12 KB
/
2.8.6 Speaking (Part 2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class Talker
{
private String speech;
// Constructor
public Talker(String startingText)
{
speech = 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 outdoorVoice()
{
return speech.toUpperCase();
}
// 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 indoorVoice()
{
return speech.toLowerCase();
}
// Reset the instance variable to the new text
public void setSpeech(String text)
{
speech = text;
}
// Returns a String representatin of this object
// The returned String should look like
//
// "Text goes here," said the talker
//
// The quotes should appear in the String
// The text displayed should be the value of the instance variable
public String toString()
{
return "\"" + speech + ",\"" + " said the talker";
}
}