CPS 6, Ramm - Summer Semester I - 5/28/99 #7
- Announce
- Random Quiz #4
- Individual Meeting Signup
Chapt 4. Building Programs & Solving Problems
- The
string Member Functions
string demo = "Monday morning";
- length:
int length()
demo.length() == 14
- Substring:
string substr(int pos, int len)
demo.substr(7,4) == "morn"
- Contains:
bool Contains(string s)
demo.Contains("day") == true
- Find:
int find(string s)
demo.find("y m") == 5
- Lower Case:
string Downcase()
demo.Downcase() == "monday morning"
- Upper Case:
string Upcase()
demo.Upcase() == "MONDAY MORNING"
Chapt 5. Iteration with Programs and Classes
- Random Numbers & N-sided Dice:
Simulations
- Class:
dice
- Using dice
roll.cc
- Class Diagram
- Public
- constructor
- member functions
- Private
- Constructors
- The Dice Interface
dice.h
"Declaration" not code (not Definition)
- Dice Implementation
dice.cc
- Iteration (pre-tested)
- initialization
- loop test
- loop body
- update
-
while Loop Syntax
while ( test expression )
{
statement list
}
- While Example
blastoff.cc
- Dice/While Example
roll300.cc
- Diamonds are for Fun
diamonds.cc
- More Looping: Math Tables
formerly got PhD for better tables
pow1.cc
pow2.cc
-
for Loop Syntax
for ( initialization; test expression; update
)
{
statement list
}
- Pre-tested and Post-tested Loops
- Iteration (post-tested)
- initialization
- loop body
- update
- loop test
-
do-while Loop Syntax
do
{
statement list
}
while ( test expression )