COMP 170
1.0
Index
Site
1. Context
1.1. Motivation for This Book
1.2. Resources Online
1.3. Downloading and Reading Options
1.4. Computer Science, Broadly
1.5. Chapter Review Questions
2. C# Data and Operations
2.1. A Sample C# Program
2.2. Lab: Editing, Compiling, and Running with Xamarin Studio
2.3. Arithmetic
2.4. Variables and Assignment
2.5. Syntax Template Typography
2.6. Strings, Part I
2.7. Writing to the Console
2.8. C# Program Structure
2.9. Combining Input and Output
2.10. String Special Cases
2.11. Substitutions in Console.WriteLine
2.12. Value Types and Conversions
2.13. Learning to Solve Problems
2.14. Lab: Division Sentences
2.15. Chapter Review Questions
3. Defining Functions of your Own
3.1. A First Function Definition
3.2. Multiple Function Definitions
3.3. Function Parameters
3.4. Multiple Function Parameters
3.5. Returned Function Values
3.6. Two Roles: Writer and Consumer of Functions
3.7. Local Scope
3.8. Static Variables
3.9. Not using Return Values
3.10. Library Classes
3.11. Static Function Summary
3.12. Chapter Review Questions
4. Basic String Operations
4.1. String Indexing
4.2. Some Instance Methods and the Length Property
4.3. A Creative Problem Solution
4.4. Lab: String Operations
4.5. Chapter Review Questions
5. Decisions
5.1. Conditions I
5.2. Simple
if
Statements
5.3.
if
-
else
Statements
5.4. More Conditional Expressions
5.5. Multiple Tests and
if
-
else
Statements
5.6. If-statement Pitfalls
5.7. Compound Boolean Expressions
5.8. Nested
if
Statements
5.9. Chapter Review Questions
6. While Loops
6.1. While-Statements
6.2. While-Statements with Sequences
6.3. Interactive
while
Loops
6.4. Short-Circuiting && and ||
6.5. While Examples
6.6. More String Methods
6.7. User Input: UI
6.8. Greatest Common Divisor
6.9. Do-While Loops
6.10. Number Guessing Game Lab
6.11. Chapter Review Questions
7. Foreach Loops
7.1.
foreach
Syntax
7.2.
foreach
Examples
7.3. Chapter Review Questions
8. For Loops
8.1. For-Statement Syntax
8.2. Examples With
for
Statements
8.3. Lab: Loops
8.4. Chapter Review Questions
9. Files, Paths, and Directories
9.1. Files As Streams
9.2. Writing Files
9.3. Reading Files
9.4. Path Strings
9.5. Directory Class
9.6. File Class
9.7. Command Line Execution
9.8. FIO Helper Class
9.9. Chapter Review Questions
10. Arrays
10.1. One Dimensional Arrays
10.2. Musical Scales and Arrays
10.3. Linear Searching
10.4. Sorting Algorithms
10.5. Binary Searching
10.6. Lab: Arrays
10.7. Lab: Performance
10.8. Multi-dimensional Arrays
10.9. Chapter Review Questions
11. Lists
11.1. List Syntax
11.2. .Net Library (API)
11.3. Chapter Review Questions
12. Dictionaries
12.1. Dictionary Syntax
12.2. Dictionary Efficiency
12.3. Dictionary Examples
12.4. Lab: File Data and Collections
12.5. Chapter Review Questions
13. Classes and Object-Oriented Programming
13.1. A First Example of Class Instances: Contact
13.2. Class Instance Examples
13.3. The Rational Class
13.4. Planning A Class Structure
13.5. Classes And Structs
13.6. Defining Operators (Optional)
13.7. Chapter Review Questions
14. Testing
14.1. Assertions
14.2. Attributes
14.3. Testing the Constructor
14.4. Testing Rational Comparisons
14.5. Testing Rational Arithmetic
14.6. Testing Rational Conversions (to other types)
14.7. Testing the Parsing Feature
14.8. Running the NUnit Tests
15. Interfaces
15.1. Rationals Revisited
15.2. Csproject Revisited
15.3. Chapter Review Questions
16. Recursion
17. Data Structures
18. Appendix
18.1. Development Tools
18.2. Xamarin Studio
18.3. Command Line Introduction
18.4. Precedence of Operators
18.5. Homework: Grade Calculation
18.6. Homework: Grade Calculation from Individual Scores
18.7. Homework: Grade File
18.8. Homework: Book List
18.9. Group Project
18.10. Lab: Version Control
18.11. Mercurial and Teamwork
18.12. Acknowledgments
Page
13. Classes and Object-Oriented Programming
Source
13. Classes and Object-Oriented Programming
ΒΆ
13.1. A First Example of Class Instances: Contact
13.1.1. Making a Datatype
13.1.2. Class Syntax
13.1.3. Instance Variables
13.1.4. Constructors
13.1.5. Instance Methods
13.1.6. Getters
13.1.7. This Object
13.1.8. Setters
13.1.9. ToString Override
13.1.10. Local Variables Hiding Instance Variables
13.1.10.1. Lifetime and Scope Exercise/Example
13.2. Class Instance Examples
13.2.1. More Getters and Setters
13.2.1.1. Statistics Exercise
13.2.1.2. Unneeded Constructor Code Exercise
13.2.1.3. Alternate Internal State Exercise
13.2.2. Converting A Static Game To A Game Instance
13.2.3. Animal Class Lab
13.2.4. Clock Example
13.2.4.1. Alternate Clock Constructor Exercise
13.2.4.2. Clock With Seconds Exercise
13.2.4.3. Twelve Hour Time Exercise
13.3. The Rational Class
13.3.1. Method Parameters of the Same Type
13.3.2. Pictorial Playing Computer
13.3.3. ForceMatch Exercise
13.4. Planning A Class Structure
13.5. Classes And Structs
13.6. Defining Operators (Optional)
13.6.1. Operator Overloading
13.6.2. Casts in User-Defined Classes
13.6.2.1. Operator Overloading Exercise
13.7. Chapter Review Questions