A Computer Science Tapestry / Edition 2

A Computer Science Tapestry / Edition 2

2.3 3
by Owen L. Astrachan
     
 

ISBN-10: 0072322039

ISBN-13: 9780072322033

Pub. Date: 09/28/1999

Publisher: McGraw-Hill Companies, The

A Computer Science Tapestry is designed for use in a first course in computer science (CS1) that uses C++ as its programming language. This book covers basic concepts in programming, program design and computer science along with giving students a good introduction to the C++ language.

In the new edition, Astrachan has put more emphasis on object-oriented

Overview

A Computer Science Tapestry is designed for use in a first course in computer science (CS1) that uses C++ as its programming language. This book covers basic concepts in programming, program design and computer science along with giving students a good introduction to the C++ language.

In the new edition, Astrachan has put more emphasis on object-oriented programming by introducing a graphics library and including a new chapter on object-oriented techniques. He has also added new case studies and "design tips."

Product Details

ISBN-13:
9780072322033
Publisher:
McGraw-Hill Companies, The
Publication date:
09/28/1999
Series:
McGraw-Hill Computer Science Series
Edition description:
2ND
Pages:
880
Product dimensions:
7.36(w) x 9.11(h) x 1.11(d)

Table of Contents

List of Programs
xvii
Preface xxiii
Computer Science and Programming
3(26)
What Is Computer Science?
3(2)
The Tapestry of Computer Science
4(1)
Algorithms
5(3)
Arranging 13 Cards
6(1)
Arranging 100,000 exams
7(1)
Computer Science Themes and Concepts
8(4)
Theory, Language, and Architecture
8(1)
Abstractions, Models, and Complexity
9(3)
Language, Architecture, and Programs
12(3)
High-and Low-Level Languages
12(3)
Creating and Developing Programs
15(3)
Language and Program Design
18(2)
Off-the-Shelf Components
19(1)
Using Components
20(1)
Chapter Review
20(1)
Exercises
21(8)
1 FOUNDATIONS OF C++ PROGRAMMING
C++ Programs: Form and Function
29(38)
Simple C++ Programs
30(5)
Syntax and Semantics
31(4)
How a Program Works
35(2)
Flow of Control
36(1)
What Can Be Output?
37(3)
Using Functions
40(4)
Functions with Parameters
44(7)
What Is a Parameter?
44(1)
An Example of Parameterization: Happy Birthday
45(3)
Passing Parameters
48(3)
Functions with Several Parameters
51(9)
Program Style
60(1)
Indentifiers
61(1)
Chapter Review
61(2)
Exercises
63(4)
Program Design and Implementation
67(32)
The Input Phase of Computation
68(5)
The Input Stream, cin
69(1)
Variables
69(4)
Processing Numbers
73(10)
Numeric Data
75(2)
Arithmetic Operators
77(2)
Evaluating Expressions
79(3)
The Type char
82(1)
Case Study: Pizza Slices
83(3)
Pizza Statistics
83(3)
Classes and Types: An Introduction
86(7)
Member Functions
88(1)
Reading Programs
89(2)
Private and Public
91(2)
Compiling and Linking
93(1)
Chapter Review
94(1)
Exercises
95(4)
Control, Functions, and Classes
99(54)
The Assignment Operator
100(3)
Choices and Conditional Execution
103(4)
The if/else Statement
105(2)
Operators
107(7)
Relational Operators
108(3)
Logical Operators
111(1)
Short-Circuit Evaluation
112(1)
Arithmetic Assignment Operators
113(1)
Block Statements and Defensive Programming
114(9)
Defensive Programming Conventions
115(3)
Cascaded if/else Statements
118(5)
Functions That Return Values
123(14)
The Math Library <cmath>
126(2)
Pre- and Postconditions
128(1)
Function Return Types
129(8)
Class Member Functions
137(7)
string Member Functions
137(3)
Calling and Writing Functions
140(3)
The Date Class
143(1)
Using Boolean Operators: De Morgan's Law
144(2)
Chapter Review
146(2)
Exercises
148(5)
Iteration with Programs and Classes
153(60)
The while Loop
153(24)
Infinite Loops
156(1)
Loops and Mathematical Functions
157(1)
Computing Factorials
158(4)
Computing Prime Numbers
162(4)
Kinds of Loops
166(1)
Efficiency Considerations
166(1)
Exponentiation: A Case Study in Loop Development
167(6)
Numbers Written in English
173(2)
Fence Post Problems
175(2)
Alternative Looping Statements
177(12)
The for Loop
178(1)
The Operators ++ and --
179(1)
The do-while Loop
180(1)
Pseudo-Infinite Loops
181(2)
Choosing a Looping Statement
183(1)
Nested Loops
183(5)
Defining Constants
188(1)
Variable Scope
189(2)
Using Classes
191(11)
The Date Class
191(4)
The Dice Class
195(3)
Testing the Dice Class
198(4)
Chapter Review
202(1)
Exercises
203(10)
2 PROGRAM AND CLASS CONSTRUCTION: EXTENDING THE FOUNDATION
Classes, Iterators, and Patterns
213(64)
Classes: From Use to Implementation
213(9)
Class Documentation: The Interface (.h File)
213(1)
Comments in .h Files
214(2)
Class Documentation: The Implementation or .cpp File
216(3)
Member Function Implementation
219(1)
Scope of Private Variables
220(2)
Program Design with Functions
222(12)
Evaluating Classes and Code: Coupling and Cohesion
224(1)
Toward a Class-Based Quiz Program
225(1)
Reference Parameters
226(3)
Pass by Value and Pass by Reference
229(2)
const Reference Parameters
231(3)
Reading Words: Stream Iteration
234(15)
Recommended Problem-Solving and Programming Steps
235(1)
A Pseudocode Solution
235(3)
Solving a Related Problem
238(2)
The Final Program: Counting Words
240(3)
Streams Associated with Files
243(2)
Type Casting
245(2)
A Word-Reading Class Using ifstream
247(2)
Finding Extreme Values
249(10)
Largest/Smallest Values
251(1)
Initialization: Another Fence Post Problem
252(2)
Word Frequencies
254(2)
Using the CTimer class
256(3)
Case Study: Iteration and String Sets
259(7)
Iterators and the strutils.h Library
261(1)
The Type ofstream
261(2)
Sets and Word Counting
263(3)
Chapter Review
266(1)
Exercises
267(10)
Class Interfaces, Design, and Implementation
277(62)
Designing Classes: From Requirements to Implementation
277(23)
Requirements
278(1)
Nouns as Classes
278(1)
Verbs as Member Functions (Methods)
279(1)
Finding Verbs Using Scenarios
279(2)
Assigning Responsibilities
281(1)
Implementing and Testing Classes
282(3)
Implementing the Class Quiz
285(2)
Implementing the Class Question
287(2)
Sidebar: Converting int and double Values to strings
289(11)
A Conforming Interface: A New Question Class
300(9)
Using the New Question Class
300(1)
Creating a Program
301(1)
The Preprocessor
302(2)
The Compiler
304(1)
The Linker
305(1)
A New Question Class
306(3)
Random Walks
309(20)
One-Dimensional Random Walks
310(2)
Selection with the switch Statement
312(2)
A RandomWalk Class
314(7)
A Two-Dimensional Walk Class
321(6)
The Common Interface in RandomWalk and RandomWalk2D
327(2)
structs as Data Aggregates
329(5)
structs for Storing Points
331(2)
Operators for structs
333(1)
Chapter Review
334(1)
Exercises
335(4)
Arrays, Data, and Random Access
339(58)
Arrays and Vectors as Counters
340(7)
An Introduction to the Class tvector
343(1)
Counting with tvectors
344(3)
Defining and Using tvectors
347(10)
tvector Definition
347(1)
tvector Initialization
348(1)
tvector Parameters
348(4)
A tvector Case Study: Shuffling CD Tracks
352(5)
Collections and Lists Using tvectors
357(23)
Size and Capacity
358(1)
Using push_back, resize, and reserve
358(5)
Vector Idioms: Insertion, Deletion, and Searching
363(3)
Insertion into a Sorted Vector
366(2)
Deleting an Element Using pop_back
368(1)
Searching a Vector
369(5)
Binary Search
374(1)
Comparing Sequential and Binary Search
375(5)
Built-in Arrays
380(6)
Defining an Array
380(1)
Initializing an Array
381(1)
Arrays as Parameters
382(4)
Chapter Review
386(2)
Exercises
388(9)
3 DESIGN, USE, AND ANALYSIS: EXTENDING THE FOUNDATION
Strings, Streams, and Operators
397(244)
Characters: Building Blocks for Strings
398(8)
The Type char as an Abstraction
398(3)
The Library <cctype>
401(2)
Strings as char Sequences
403(3)
Streams and Files as Lines and Characters
406(11)
Input Using getline ()
407(4)
Parsing Line-Oriented Data Using istringstream
411(2)
Output Using ostringstream
413(1)
Strings, Streams, and Characters
414(3)
Case Study: Removing Comments with State Machines
417(215)
Counting Words
417(2)
Problem Specification: What Is a Comment?
419(1)
A State Machine Approach to I/O
419(213)
Chapter Review
632(2)
Exercises
634(7)
Inheritance for Object-Oriented Design
641(64)
Essential Aspects of Inheritance
641(14)
The Inheritance Hierarchy for Streams
642(2)
An Inheritance Hierarchy: Math Quiz Questions
644(3)
Implementing Inheritance
647(2)
Public Inheritance
649(1)
Virtual Functions
650(4)
Protected Data Members
654(1)
Using an Abstract Base Class
655(13)
Abstract Classes and Pure Virtual Functions
657(4)
When Is a Method virtual?
661(7)
Advanced Case Study: Gates, Circuits, and Design Patterns
668(28)
An Introduction to Gates and Circuits
668(2)
Wires, Gates, and Probes
670(2)
Composite Gates and Connectors
672(8)
Implementation of the Wire and Gate Classes
680(2)
Gates and Wires: Observers and Observables
682(2)
Encapsulating Construction in WireFactory
684(2)
Refactoring: Creating a BinaryGate Class
686(4)
Interactive Circuit Building
690(5)
SimpleMap: Mapping Names to Gates
695(1)
Chapter Review
696(1)
Exercises
697(8)
A How to: Use Basic C++ Syntax and Operators 705(14)
Syntax
705(6)
The Function main
705(1)
Built-in and Other Types
705(1)
Variable Definition and Assignment
706(2)
C++ Keywords
708(1)
Control Flow
708(3)
Functions and Classes
711(8)
Defining and Declaring Functions and Classes
711(2)
Importing Classes and Functions: #include
713(1)
Namespaces
713(3)
Operators
716(1)
Characters
716(1)
Command-Line Parameters
716(3)
B How to: Format Output and Use Streams 719(12)
Formatting Output
719(8)
General and Floating-Point Formatting
719(1)
Manipulators
720(6)
Stream Functions
726(1)
Random Access Files
727(3)
I/O Redirection
730(1)
C How to: Use the Class string 731(6)
The Class string
731(1)
Basic Operations
731(1)
Conversion to/from C-Style Strings
732(1)
String Member Functions
732(5)
Adding Characters or Strings
732(1)
Using Substrings
733(2)
Finding (Sub)strings and Characters
735(2)
D How to: Understand and Use const 737(8)
Why const?
737(1)
Literal Arguments
738(1)
const Member Functions
738(3)
Overloading on const
740(1)
mutable Data
741(2)
Pointers and const
743(1)
Summary
744(1)
E How to: Overload Operators 745(12)
Overloading Overview
745(1)
Arithmetic Operators
745(5)
Binary Operators
746(2)
Arithmetic Assignment Operators
748(2)
Relational Operators
750(3)
I/O Operators
753(2)
The Function tostring ()
754(1)
Constructors and Conversions
755(2)
F How to: Understand and Use Standard Libraries 757(8)
Functions
757(1)
The Library <cmath>
757(1)
The Library <cctype>
758(1)
Constants and Limits
758(7)
Limits in <climits>
759(1)
double Limits in <cfloat>
760(1)
Limits in <limits>
761(2)
ASCII Values
763(2)
G How to: Understand and Use Tapestry Classes 765(30)
A Library of Useful Classes
765(2)
Summary of Classes and Functions
765(1)
Implementations of Tapestry Classes
766(1)
Header Files for Tapestry Classes
767(28)
Prompting Functions in prompt.h
767(2)
The Class Date
769(2)
The Class Dice
771(1)
The Class RandGen
772(1)
The Class CTimer
773(1)
The Class WordStreamIterator
773(2)
The Class StringSet
775(1)
The String Functions in strutils .h
776(1)
The Math Helper Functions in mathutils .h
776(1)
The struct Point
777(1)
The Classes in directory .h
778(3)
The Class CList
781(3)
The Class Poly
784(1)
The Sorting Functions in sortall .h
785(2)
Header Files from Circuit Simulation
787(5)
The Map Class SimpleMap
792(3)
H How to: Use the Graphics Classes in canvas .h 795(22)
The Graphics Library: TOOGL 1.0
795(1)
Using the Canvas Class
796(5)
Canvas Basics
796(1)
Drawing Styles, and Colors
796(2)
Drawing Shapes and Text
798(3)
Using the AnimatedCanvas Class
801(16)
The Shape Hierarchy
801(1)
Properties of Shape Objects
802(1)
Using Shapes: addShape and clone
803(2)
The CompositeShape Class
805(2)
Processing Mouse and Key Events
807(3)
Animations with Bouncer and Mover
810(3)
Canvas Iterator
813(2)
Specifying Color with Class CanvasColor
815(1)
The Class Key in key.h
816(1)
I How to: Cope with C++ Environments 817(4)
Coping with Compilers
817(1)
Keeping Current
818(1)
Creating a C++ Program
818(3)
The Preprocessor
818(2)
The Compiler
820(1)
The Linker
820(1)
Bibliography 821(4)
Photo Credits 825(1)
Index 826

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >

A Computer Science Tapestry 2.3 out of 5 based on 0 ratings. 3 reviews.
Guest More than 1 year ago
The author is clearly a scholar and is able to write a highly useful computer science text by avoiding the mind-numbing boredom that plagues all the others of its kind. The approach to teaching computer science is as unique as Dr. Astrachan's writing style. As an experienced C++ programmer, I thoroughly enjoyed the book and recommend it without reservation.
Guest More than 1 year ago
I am a professor from MIT, I normally check up on the books available for teaching C++;I came across this book and decided to read it. This book is very unorganized. It has no clear structure and the explanations are vague. I would not recommend this book to anyone serious about learning C++. You will have to use another book in order to fully comprehend this book.
Guest More than 1 year ago
I teach an AP CS class and the math chair ordered this book. It is the most useless computer science book I have ever used. None of his examples are assembled in a cogent, useful fashion. The author opines that it is better to teach computer science than C++, but this leaves the begining programmer with no way to express what they are learning with code. I told my students to use the book for kindling. We went with a more unorthadox approach and ordered an ORA book which the students love.