CPS 6, Ramm - Summer Semester I - 6/2/00 #11
Chapt 6. Classes, Iterators, and Patterns
- Extrema, Statistics
-
stats1.cc
-
stats2.cc
- Initialize with real data
- Type Casting (coercion)
- Change one type to another
- Only defined where it makes sense
- Several different forms exist
- E.g., changing int to double
- double(n)
- (double) n
- Using Reference Parameters
-
stats3.cc
-
stats4.cc
- Text Processing Example
- Design Issues
- Moving Functionality to Functions
- Use of Reference Parameters
-
format.cpp
-
formatwatch.cpp
- More Reference Parameters (tricky)
-
ref.cpp
Chap 7. Class Interfaces, Design, and Implementation
- Switch Statement
- switch ( expression )
- {
- case constant1:
- statement list;
- break;
- case constant2:
- statement list;
- break;
- ...
- default:
- statement list;
- }
- Example Using the Switch Statement
- Work on Class Design: The Quiz Class
-
First look at traditional style program
-
simpquiz2.cpp
- Consider a Class Design: Requirements
- More than one kind of question
- Several students share keyboard
- More than one chance to answer
- Class Design: Assigning Responsibilities
- Student
- Construct using name
- RespondTo a question
- GetScore
- GetName
- Quiz
- ChooseKindOfQuestion
- AskQuestion of/GiveQuestion to a student
- Question
- Create/Construct question type
- AskQuestion
- Get CorrectAnswer
- Implementing and Using Classes
- Iterative Enhancement
- Using Stubs
teststudent.cpp
- Going for Class