CPS 6, Ramm - Summer Semester I - 6/5/00 #12
- Announce
- Quiz Today
- Lab Tomorrow
- Individual Meetings
7. Class Interfaces, Design, & Implementation
- 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
- Sometimes partial function
- Sometimes announce only
- Sometimes totally empty
teststudent.cpp
question.h
- Other Practical Issues
- Handling different kinds of questions
- String return type for answer
- string tostring(int)
- string tostring(double)
- Question Class
-
mathquest.h
-
mathquest.cpp
- Initializer Lists - Syntax
- ClassName::ClassName()
- :
- myVar1(argument),
- myVar2(argument),
- ...
- myVarN(argument)
- {// begin constructor body ...
- Quiz Program
- Includes Student and Quiz Classes
-
quiz.cpp
- Preprocessor
- #include files, missing?
- #ifndef, #define, #endif
- multiple copies of include files
- Compiler
- Linker
- Undefined symbols
- Missing modules
- Alternate Question Class (State Capitals)
- Includes Student and Quiz Classes
-
capquest.cpp
-
capquest.h
- Frogs that can't make up their minds ...
- Random Walks (1-D)
- Physics
- Statistical
- Coin Toss
- Frog Example
- Gambling Example
- Random Walk Class
- Random Walks (2-D)
- Passing a Class by Value/Reference
- Done for strings many times...
-
scopedice.cpp