CPS 1 - Spring, 1998 - Ramm 2/2 #8
- Announce
- Quiz Wednesday
- Will try to put some kind sample test on web today or tomorrow.
- Begin Reading Chapter 3
Chapt 2. Text Manipulation and Algorithm Design
- Went Over Methods for Text Manipulation
- Most important ones were: length(), indexOf(), substring()
- Getting String Data from the User
- The TextField class has getText() method.
- Can use:
message = mg.getText();
where mg is a TextField and message is a String.
- An Algorithm: The Exchange Problem
- at start:
-
x contains "milk"
-
y contains "juice"
- how do we interchange contents?
- need
temp
- String x, y, temp;
- ...
- x = ____.getText();
- y = ____.getText();
- _____.setText(x + " and " + y " before");
- ...
- temp = x;
- x = y;
- y = temp;
- ...
- _____.setText(x + " and " + y " after");
- ...
- Example: Pig Latin
PigLatin.java,
PigLatin.html
- Another String Manipulation Example
StringPlay.java,
StringPlay.html
- Add More Functions
- Last name first format
- All Capitals (
String toUpperCase())
- Does last name contain first?
- Reading in Numbers