You are on page 1of 53

Building Java Programs: A Back to

Basics Approach Stuart Reges


Visit to download the full and correct content document:
https://textbookfull.com/product/building-java-programs-a-back-to-basics-approach-st
uart-reges/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Building Java Programs - A Back to Basics Approach


Stuart Reges

https://textbookfull.com/product/building-java-programs-a-back-
to-basics-approach-stuart-reges-2/

Building Java Programs: A Back to Basics Approach, 5th


Edition Stuart Reges

https://textbookfull.com/product/building-java-programs-a-back-
to-basics-approach-5th-edition-stuart-reges/

Building Python Programs 1st Edition Stuart Reges

https://textbookfull.com/product/building-python-programs-1st-
edition-stuart-reges/

Simpler Living Back to Basics Guides 2nd Edition Jeff


Davidson

https://textbookfull.com/product/simpler-living-back-to-basics-
guides-2nd-edition-jeff-davidson/
College physics : a strategic approach 4th Edition
Stuart Field

https://textbookfull.com/product/college-physics-a-strategic-
approach-4th-edition-stuart-field/

Artificial Intelligence: A Modern Approach 4th Edition


Stuart Russell

https://textbookfull.com/product/artificial-intelligence-a-
modern-approach-4th-edition-stuart-russell/

RESTful Java Web Services A pragmatic guide to


designing and building RESTful APIs using Java 3rd
Edition Balachandar

https://textbookfull.com/product/restful-java-web-services-a-
pragmatic-guide-to-designing-and-building-restful-apis-using-
java-3rd-edition-balachandar/

A Functional Approach to Java: Augmenting Object-


Oriented Java Code with Functional Principles 1st
Edition Ben Weidig

https://textbookfull.com/product/a-functional-approach-to-java-
augmenting-object-oriented-java-code-with-functional-
principles-1st-edition-ben-weidig/

Back Trouble A New Approach to Prevention and Recovery


based on the Alexander Technique Deborah Caplan

https://textbookfull.com/product/back-trouble-a-new-approach-to-
prevention-and-recovery-based-on-the-alexander-technique-deborah-
caplan/
Building Java Programs
A Back to Basics Approach

Fourth Edition

Stuart Reges

University of Washington

Marty Stepp

Stanford University

Boston Columbus Indianapolis New York San Francisco Hoboken


Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal
Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore
Taipei Tokyo
Vice President, Editorial Director: Marcia Horton

Acquisitions Editor: Matt Goldstein

Editorial Assistant: Kristy Alaura

VP of Marketing: Christy Lesko

Director of Field Marketing: Tim Galligan

Product Marketing Manager: Bram Van Kempen

Field Marketing Manager: Demetrius Hall

Marketing Assistant: Jon Bryant

Director of Product Management: Erin Gregg

Team Lead, Program and Project Management: Scott Disanno

Program Manager: Carole Snyder

Project Manager: Lakeside Editorial Services L.L.C.

Senior Specialist, Program Planning and Support: Maura Zaldivar-Garcia

Cover Design: Joyce Wells

R&P Manager: Rachel Youdelman

R&P Project Manager: Timothy Nicholls

Inventory Manager: Meredith Maresca

Cover Art: Matt Walford/Cultura/Getty Images

Full-Service Project Management: Apoorva Goel/Cenveo Publisher


Services
Composition: Cenveo® Publisher Services

Printer/Binder: Edwards Brothers Malloy

Cover Printer: Phoenix Color

Text Font: Monotype

The authors and publisher of this book have used their best efforts in
preparing this book. These efforts include the development, research, and
testing of the theories and programs to determine their effectiveness. The
authors and publisher make no warranty of any kind, expressed or implied,
with regard to these programs or to the documentation contained in this book.
The authors and publisher shall not be liable in any event for incidental or
consequential damages in connection with, or arising out of, the furnishing,
performance, or use of these programs.

Copyright © 2017, 2014 and 2011 Pearson Education, Inc. or its affiliates.
All rights reserved. Printed in the United States of America. This publication
is protected by copyright, and permission should be obtained from the
publisher prior to any prohibited reproduction, storage in a retrieval system,
or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise. For information regarding
permissions, request forms and the appropriate contacts within the Pearson
Education Global Rights & Permissions department, please visit
www.pearsonhighed.com/permissions/.

Acknowledgements of third party content appear on pages 1193–1194, which


constitute an extension of this copyright page.

PEARSON, and MYPROGRAMMINGLAB are exclusive trademarks in the


U.S. and/or other countries owned by Pearson Education, Inc. or its affiliates.

Unless otherwise indicated herein, any third-party trademarks that may


appear in this work are the property of their respective owners and any
references to third-party trademarks, logos or other trade dress are for
demonstrative or descriptive purposes only. Such references are not intended
to imply any sponsorship, endorsement, authorization, or promotion of
Pearson's products by the owners of such marks, or any relationship between
the owner and Pearson Education, Inc. or its affiliates, authors, licensees or
distributors.

Library of Congress Cataloging-in-Publication Data

Names: Reges, Stuart, author. | Stepp, Martin, author.

Title: Building Java programs : a back to basics approach / Stuart Reges,


University of Washington; Marty Stepp, Stanford University.

Description: Fourth Edition. | Hoboken, NJ : Pearson, 2016.

Identifiers: LCCN 2015049340 | ISBN 9780134322766 (alk. paper)

Subjects: LCSH: Java (Computer program language)

Classification: LCC QA76.73.J38 R447 2016 | DDC 005.13/3—dc23 LC


record available at http://lccn.loc.gov/2015049340

10 9 8 7 6 5 4 3 2 1

ISBN 10: 0-13-432276-2

ISBN 13: 978-0-13-432276-6


Preface
The newly revised fourth edition of our Building Java Programs textbook is
designed for use in a two-course introduction to computer science. We have
class-tested it with thousands of undergraduates, most of whom were not
computer science majors, in our CS1-CS2 sequence at the University of
Washington. These courses are experiencing record enrollments, and other
schools that have adopted our textbook report that students are succeeding
with our approach.

Introductory computer science courses are often seen as “killer” courses with
high failure rates. But as Douglas Adams says in The Hitchhiker's Guide to
the Galaxy, “Don't panic.” Students can master this material if they can learn
it gradually. Our textbook uses a layered approach to introduce new syntax
and concepts over multiple chapters.

Our textbook uses an “objects later” approach where programming


fundamentals and procedural decomposition are taught before diving into
object-oriented programming. We have championed this approach, which we
sometimes call “back to basics,” and have seen through years of experience
that a broad range of scientists, engineers, and others can learn how to
program in a procedural manner. Once we have built a solid foundation of
procedural techniques, we turn to object-oriented programming. By the end
of the course, students will have learned about both styles of programming.

Here are some of the changes that we have made in the fourth edition:

New chapter on functional programming with Java 8. As explained


below, we have introduced a chapter that uses the new language features
available in Java 8 to discuss the core concepts of functional
programming.

New section on images and 2D pixel array manipulation. Image


manipulation is becoming increasingly popular, so we have expanded
our DrawingPanel class to include features that support manipulating
images as two-dimensional arrays of pixel values. This extra coverage
will be particularly helpful for students taking an AP/CS A course
because of the heavy emphasis on two-dimensional arrays on the AP
exam.

Expanded self-checks and programming exercises. Many chapters have


received new self-check problems and programming exercises. There
are roughly fifty total problems and exercises per chapter, all of which
have been class-tested with real students and have solutions provided for
instructors on our web site.

Since the publication of our third edition, Java 8 has been released. This new
version supports a style of programming known as functional programming
that is gaining in popularity because of its ability to simply express complex
algorithms that are more easily executed in parallel on machines with
multiple processors. ACM and IEEE have released new guidelines for
undergraduate computer science curricula, including a strong
recommendation to cover functional programming concepts.

We have added a new Chapter 19 that covers most of the functional concepts
from the new curriculum guidelines. The focus is on concepts, not on
language features. As a result, it provides an introduction to several new Java
8 constructs but not a comprehensive coverage of all new language features.
This provides flexibility to instructors since functional programming features
can be covered as an advanced independent topic, incorporated along the
way, or skipped entirely. Instructors can choose to start covering functional
constructs along with traditional constructs as early as Chapter 6. See the
dependency chart at the end of this section.

The following features have been retained from previous editions:

Focus on problem solving. Many textbooks focus on language details


when they introduce new constructs. We focus instead on problem
solving. What new problems can be solved with each construct? What
pitfalls are novices likely to encounter along the way? What are the most
common ways to use a new construct?

Emphasis on algorithmic thinking. Our procedural approach allows us to


emphasize algorithmic problem solving: breaking a large problem into
smaller problems, using pseudocode to refine an algorithm, and
grappling with the challenge of expressing a large program
algorithmically.

Layered approach. Programming in Java involves many concepts that


are difficult to learn all at once. Teaching Java to a novice is like trying
to build a house of cards. Each new card has to be placed carefully. If
the process is rushed and you try to place too many cards at once, the
entire structure collapses. We teach new concepts gradually, layer by
layer, allowing students to expand their understanding at a manageable
pace.

Case studies. We end most chapters with a significant case study that
shows students how to develop a complex program in stages and how to
test it as it is being developed. This structure allows us to demonstrate
each new programming construct in a rich context that can't be achieved
with short code examples. Several of the case studies were expanded
and improved in the second edition.

Utility as a CS1+CS2 textbook. In recent editions, we added chapters


that extend the coverage of the book to cover all of the topics from our
second course in computer science, making the book usable for a two-
course sequence. Chapters 12–19 explore recursion, searching and
sorting, stacks and queues, collection implementation, linked lists,
binary trees, hash tables, heaps, and more. Chapter 12 also received a
section on recursive backtracking, a powerful technique for exploring a
set of possibilities for solving problems such as 8 Queens and Sudoku.

Layers and Dependencies


Many introductory computer science books are language-oriented, but the
early chapters of our book are layered. For example, Java has many control
structures (including for-loops, while-loops, and if/else-statements), and
many books include all of these control structures in a single chapter. While
that might make sense to someone who already knows how to program, it can
be overwhelming for a novice who is learning how to program. We find that
it is much more effective to spread these control structures into different
chapters so that students learn one structure at a time rather than trying to
learn them all at once.

The following table shows how the layered approach works in the first six
chapters:

Control Programming
Chapter Data Input/Output
Flow Techniques
procedural
1 methods String literals println, print
decomposition
definite variables, local variables, class
2 loops expressions, constants,
(for) int, double pseudocode
console input, 2D
return
3 using objects parameters graphics
values
(optional)
conditional char pre/post conditions, printf
4
(if/else) throwing exceptions
indefinite
assertions, robust
5 loops boolean
programs
(while)
token/line-based file
6 Scanner file I/O
processing

Chapters 1–6 are designed to be worked through in order, with greater


flexibility of study then beginning in Chapter 7. Chapter 6 may be skipped,
although the case study in Chapter 7 involves reading from a file, a topic that
is covered in Chapter 6.

The following is a dependency chart for the book:


Supplements
http://www.buildingjavaprograms.com/

Answers to all self-check problems appear on our web site and are accessible
to anyone. Our web site has the following additional resources for students:

Online-only supplemental chapters, such as a chapter on creating


Graphical User Interfaces

Source code and data files for all case studies and other complete
program examples

The DrawingPanel class used in the optional graphics Supplement 3G

Our web site has the following additional resources for teachers:

PowerPoint slides suitable for lectures

Solutions to exercises and programming projects, along with homework


specification documents for many projects

Sample exams and solution keys

Additional lab exercises and programming exercises with solution keys

Closed lab creation tools to produce lab handouts with the instructor's
choice of problems integrated with the textbook

To access protected instructor resources, contact us at


authors@buildingjavaprograms.com. The same materials are also available at
http://www.pearsonhighered.com/cs-resources. To receive a password for this
site or to ask other questions related to resources, contact your Pearson sales
representative.

MyProgrammingLab
MyProgrammingLab is an online practice and assessment tool that helps
students fully grasp the logic, semantics, and syntax of programming.
Through practice exercises and immediate, personalized feedback,
MyProgrammingLab improves the programming competence of beginning
students who often struggle with basic concepts and paradigms of popular
high-level programming languages. A self-study and homework tool, the
MyProgrammingLab course consists of hundreds of small practice exercises
organized around the structure of this textbook. For students, the system
automatically detects errors in the logic and syntax of code submissions and
offers targeted hints that enable students to figure out what went wrong, and
why. For instructors, a comprehensive grade book tracks correct and
incorrect answers and stores the code inputted by students for review.

For a full demonstration, to see feedback from instructors and students, or to


adopt MyProgrammingLab for your course, visit the following web site:
http://www.myprogramminglab.com/

VideoNotes

We have recorded a series of instructional videos to accompany the textbook.


They are available at the following web site: www.pearsonhighered.com/cs-
resources

Roughly 3–4 videos are posted for each chapter. An icon in the margin of the
page indicates when a VideoNote is available for a given topic. In each video,
we spend 5–15 minutes walking through a particular concept or problem,
talking about the challenges and methods necessary to solve it. These videos
make a good supplement to the instruction given in lecture classes and in the
textbook. Your new copy of the textbook has an access code that will allow
you to view the videos.
Acknowledgments
First, we would like to thank the many colleagues, students, and teaching
assistants who have used and commented on early drafts of this text. We
could not have written this book without their input. Special thanks go to
Hélène Martin, who pored over early versions of our first edition chapters to
find errors and to identify rough patches that needed work. We would also
like to thank instructor Benson Limketkai for spending many hours
performing a technical proofread of the second edition.

Second, we would like to thank the talented pool of reviewers who guided us
in the process of creating this textbook:

Greg Anderson, Weber State University

Delroy A. Brinkerhoff, Weber State University

Ed Brunjes, Miramar Community College

Tom Capaul, Eastern Washington University

Tom Cortina, Carnegie Mellon University

Charles Dierbach, Towson University

H.E. Dunsmore, Purdue University

Michael Eckmann, Skidmore College

Mary Anne Egan, Siena College

Leonard J. Garrett, Temple University

Ahmad Ghafarian, North Georgia College & State University

Raj Gill, Anne Arundel Community College


Michael Hostetler, Park University

David Hovemeyer, York College of Pennsylvania

Chenglie Hu, Carroll College

Philip Isenhour, Virginia Polytechnic Institute

Andree Jacobson, University of New Mexico

David C. Kamper, Sr., Northeastern Illinois University

Simon G.M. Koo, University of San Diego

Evan Korth, New York University

Joan Krone, Denison University

John H.E.F. Lasseter, Fairfield University

Eric Matson, Wright State University

Kathryn S. McKinley, University of Texas, Austin

Jerry Mead, Bucknell University

George Medelinskas, Northern Essex Community College

John Neitzke, Truman State University

Dale E. Parson, Kutztown University

Richard E. Pattis, Carnegie Mellon University

Frederick Pratter, Eastern Oregon University

Roger Priebe, University of Texas, Austin

Dehu Qi, Lamar University


John Rager, Amherst College

Amala V.S. Rajan, Middlesex University

Craig Reinhart, California Lutheran University

Mike Scott, University of Texas, Austin

Alexa Sharp, Oberlin College

Tom Stokke, University of North Dakota

Leigh Ann Sudol, Fox Lane High School

Ronald F. Taylor, Wright State University

Andy Ray Terrel, University of Chicago

Scott Thede, DePauw University

Megan Thomas, California State University, Stanislaus

Dwight Tuinstra, SUNY Potsdam

Jeannie Turner, Sayre School

Tammy VanDeGrift, University of Portland

Thomas John VanDrunen, Wheaton College

Neal R. Wagner, University of Texas, San Antonio

Jiangping Wang, Webster University

Yang Wang, Missouri State University

Stephen Weiss, University of North Carolina at Chapel Hill

Laurie Werner, Miami University


Dianna Xu, Bryn Mawr College

Carol Zander, University of Washington, Bothell

Finally, we would like to thank the great staff at Pearson who helped produce
the book. Michelle Brown, Jeff Holcomb, Maurene Goo, Patty Mahtani,
Nancy Kotary, and Kathleen Kenny did great work preparing the first edition.
Our copy editors and the staff of Aptara Corp, including Heather Sisan, Brian
Baker, Brendan Short, and Rachel Head, caught many errors and improved
the quality of the writing. Marilyn Lloyd and Chelsea Bell served well as
project manager and editorial assistant respectively on prior editions. For
their help with the third edition we would like to thank Kayla Smith-Tarbox,
Production Project Manager, and Jenah Blitz-Stoehr, Computer Science
Editorial Assistant. Mohinder Singh and the staff at Aptara, Inc., were also
very helpful in the final production of the third edition. For their great work
on production of the fourth edition, we thank Louise Capulli and the staff of
Lakeside Editorial Services, along with Carole Snyder at Pearson. Special
thanks go to our lead editor at Pearson, Matt Goldstein, who has believed in
the concept of our book from day one. We couldn't have finished this job
without all of their hard work and support.

Stuart Reges

Marty Stepp
Break through
To Improving results

MyProgammingLab™
Through the power of practice and immediate personalized feedback,
MyProgrammingLab helps improve your students' performance.

Programming Practice
With MyProgrammingLab, your students will gain firs-hand programming
experience in an interactive online environment.

Immediate, Personalized Feedback


MyProgrammingLab automatically detects errors in the logic and syntax of
their code submission and offers targeted hints that enables students to figure
out what went wrong and why.

Graduated Complexity
MyProgrammingLab breaks down programming concepts into short,
understandable sequences of exercises. Within each sequence the level and
sophistication of the exercises increase gradually but steadily.
Dynamic Roster
Students' submissions are stored in a roster that indicates whether the
submission is correct, how many attempts were made, and the actual code
submissions from each attempt.

Pearson eText
The Pearson eText gives students access to their textbook anytime, anywhere

Step-By-Step Videonote Tutorials


These step-by-step video tutorials enhance the programming concepts
presented in select Pearson textbooks.
For more information and titles available with MyProgrammingLab, please
visit www.myprogramminglab.com.

Copyright © 2016 Pearson Education, Inc. or its affiliate(s). All rights


reserved. HELO88173 · 11/15

LOCATION OF VIDEO NOTES IN THE TEXT

www.pearsonhighered.com/cs-resources

Chapter 1 Pages 31, 40


Chapter 2 Pages 65, 74, 89, 97, 110
Chapter 3 Pages 141, 156, 161, 167
Chapter 3G Pages 197, 215
Chapter 4 Pages 243, 251, 278
Chapter 5 Pages 324, 327, 329, 333, 356
Chapter 6 Pages 396, 409, 423
Chapter 7 Pages 458, 465, 484, 505
Chapter 8 Pages 535, 547, 555, 568
Chapter 9 Pages 597, 610, 626
Chapter 10 Pages 672, 677, 686
Chapter 11 Pages 716, 729, 737
Chapter 12 Pages 764, 772, 809
Chapter 13 Pages 834, 837, 843
Chapter 14 Pages 889, 896
Chapter 15 Pages 930, 936, 940
Chapter 16 Pages 972, 979, 992
Chapter 17 Pages 1037, 1038, 1048
Chapter 18 Pages 1073, 1092
Brief Contents
1. Chapter 1 Introduction to Java Programming 1

2. Chapter 2 Primitive Data and Definite Loops 63

3. Chapter 3 Introduction to Parameters and Objects 137

4. Supplement 3G Graphics (Optional) 196

5. Chapter 4 Conditional Execution 238

6. Chapter 5 Program Logic and Indefinite Loops 315

7. Chapter 6 File Processing 387

8. Chapter 7 Arrays 443

9. Chapter 8 Classes 530

10. Chapter 9 Inheritance and Interfaces 587

11. Chapter 10 ArrayLists 662

12. Chapter 11 Java Collections Framework 715

13. Chapter 12 Recursion 754

14. Chapter 13 Searching and Sorting 832

15. Chapter 14 Stacks and Queues 884

16. Chapter 15 Implementing a Collection Class 922

17. Chapter 16 Linked Lists 965

18. Chapter 17 Binary Trees 1017


19. Chapter 18 Advanced Data Structures 1071

20. Chapter 19 Functional Programming with Java 1107

1. Appendix A Java Summary 1149

2. Appendix B The Java API Specification and Javadoc Comments 1164

3. Appendix C Additional Java Syntax 1170


Contents
1. Chapter 1 Introduction to Java Programming 1

1. 1.1 Basic Computing Concepts 2

1. Why Programming? 2

2. Hardware and Software 3

3. The Digital Realm 4

4. The Process of Programming 6

5. Why Java? 7

6. The Java Programming Environment 8

2. 1.2 And Now—Java 10

1. String Literals (Strings) 14

2. System.out.println 15

3. Escape Sequences 15

4. print versus println 17

5. Identifiers and Keywords 18

6. A Complex Example: DrawFigures1 20

7. Comments and Readability 21

3. 1.3 Program Errors 24

1. Syntax Errors 24
2. Logic Errors (Bugs) 28

4. 1.4 Procedural Decomposition 28

1. Static Methods 31

2. Flow of Control 34

3. Methods That Call Other Methods 36

4. An Example Runtime Error 39

5. 1.5 Case Study: DrawFigures 40

1. Structured Version 41

2. Final Version without Redundancy 43

3. Analysis of Flow of Execution 44

2. Chapter 2 Primitive Data and Definite Loops 63

1. 2.1 Basic Data Concepts 64

1. Primitive Types 64

2. Expressions 65

3. Literals 67

4. Arithmetic Operators 68

5. Precedence 70

6. Mixing Types and Casting 73

2. 2.2 Variables 74

1. Assignment/Declaration Variations 79
2. String Concatenation 82

3. Increment/Decrement Operators 84

4. Variables and Mixing Types 87

3. 2.3 The for Loop 89

1. Tracing for Loops 91

2. for Loop Patterns 95

3. Nested for Loops 97

4. 2.4 Managing Complexity 99

1. Scope 99

2. Pseudocode 105

3. Class Constants 108

5. 2.5 Case Study: Hourglass Figure 110

1. Problem Decomposition and Pseudocode 111

2. Initial Structured Version 113

3. Adding a Class Constant 114

4. Further Variations 117

3. Chapter 3 Introduction to Parameters and Objects 137

1. 3.1 Parameters 138

1. The Mechanics of Parameters 141

2. Limitations of Parameters 145


3. Multiple Parameters 148

4. Parameters versus Constants 151

5. Overloading of Methods 151

2. 3.2 Methods That Return Values 152

1. The Math Class 153

2. Defining Methods That Return Values 156

3. 3.3 Using Objects 160

1. String Objects 161

2. Interactive Programs and Scanner Objects 167

3. Sample Interactive Program 170

4. 3.4 Case Study: Projectile Trajectory 173

1. Unstructured Solution 177

2. Structured Solution 179

4. Supplement 3G Graphics (Optional) 196

1. 3G.1 Introduction to Graphics 197

1. DrawingPanel 197

2. Drawing Lines and Shapes 198

3. Colors 203

4. Drawing with Loops 206

5. Text and Fonts 210


6. Images 213

2. 3G.2 Procedural Decomposition with Graphics 215

1. A Larger Example: DrawDiamonds 216

3. 3G.3 Case Study: Pyramids 219

1. Unstructured Partial Solution 220

2. Generalizing the Drawing of Pyramids 222

3. Complete Structured Solution 223

5. Chapter 4 Conditional Execution 238

1. 4.1 if/else Statements 239

1. Relational Operators 241

2. Nested if/else Statements 243

3. Object Equality 250

4. Factoring if/else Statements 251

5. Testing Multiple Conditions 253

2. 4.2 Cumulative Algorithms 254

1. Cumulative Sum 254

2. Min/Max Loops 256

3. Cumulative Sum with if 260

4. Roundoff Errors 262

3. 4.3 Text Processing 265


1. The char Type 265

2. char versus int 266

3. Cumulative Text Algorithms 267

4. System.out.printf 269

4. 4.4 Methods with Conditional Execution 274

1. Preconditions and Postconditions 274

2. Throwing Exceptions 274

3. Revisiting Return Values 278

4. Reasoning about Paths 283

5. 4.5 Case Study: Body Mass Index 285

1. One-Person Unstructured Solution 286

2. Two-Person Unstructured Solution 289

3. Two-Person Structured Solution 291

4. Procedural Design Heuristics 295

6. Chapter 5 Program Logic and Indefinite Loops 315

1. 5.1 The while Loop 316

1. A Loop to Find the Smallest Divisor 317

2. Random Numbers 320

3. Simulations 324

4. do/while Loop 325


2. 5.2 Fencepost Algorithms 327

1. Sentinel Loops 329

2. Fencepost with if 330

3. 5.3 The boolean Type 333

1. Logical Operators 335

2. Short-Circuited Evaluation 338

3. boolean Variables and Flags 342

4. Boolean Zen 344

5. Negating Boolean Expressions 347

4. 5.4 User Errors 348

1. Scanner Lookahead 349

2. Handling User Errors 351

5. 5.5 Assertions and Program Logic 353

1. Reasoning about Assertions 355

2. A Detailed Assertions Example 356

6. 5.6 Case Study: NumberGuess 361

1. Initial Version without Hinting 361

2. Randomized Version with Hinting 363

3. Final Robust Version 367

7. Chapter 6 File Processing 387


Another random document with
no related content on Scribd:
all. We thus have light discharges and severe discharges at different times, or, as the habit is
established, only the light or only the severe, the manifestation depending probably upon the number of
discharging cells and the importance of the exciting cause.
31 Traité de l'Épilepsie, etc., Paris, 1845, p. 55 et seq.

When the attacks occur in alarming frequency, as they sometimes do, the condition is known as the
status epilepticus. Leuret had a patient who had eighty in two hours, and Delasiauve reports the case of
a young man fifteen years old who had twenty-five hundred in one month. They may be so numerous as
to be apparently continuous. The patient remains in a state of coma (the status epilepticus), with very
high temperature. If he be not restored, he sinks into a deeper coma, and all the signs of collapse
manifest themselves. Bed-sores form, œdema of the lungs ensues, and the patient dies. Happily, this
condition of affairs is rare.

Delasiauve calls attention to the fact that the first two or three attacks that usher in this state do not
usually attract much attention, but the succeeding ones are so violent as to immediately suggest violent
consequences. In one of my cases the attacks, when they had once become numerous, were readily
excited by the least jarring, noise, or handling, just as we find in strychnine-poisoning or tetanus.

Irregular Forms.—There are occasional cases of psychical or masked epilepsy, the study of which is
intensely interesting. Such forms are characterized by perverted consciousness and a low degree of
volitional direction which may vary from automatism to the undoubted exercise of complex functions of
the mind, though badly co-ordinated. Mesnet's soldier, when subject to a paroxysm and apparently
unconscious, would perform a number of suggested acts in a rhythmical manner and with no
subsequent knowledge of the previous event: when started off by the word of command to march, he
would blindly go on, marking time when he met with an obstruction until stopped, or when a paper and
tobacco were placed in his hands he would proceed to roll an unlimited number of cigarettes.

Two cases of a more complex exercise of certain intellectual powers, while others were dormant, came
under my observation some time ago. One of them was a young man of twenty-three, who had had
irregular epileptic seizures for some years. He went to bed one evening as usual, arose, and
breakfasted with his family without creating any suspicion that he was at all unwell. He then went down
to his place of business, and after his arrival was sent to a distant part of the city for some tool. On his
return down town he stopped at a tobacconist's and became involved in a quarrel with one of the
persons in the shop. A policeman was called, who, more intelligent than many of his class, immediately
detected something queer about the man, arrested him, and afterward took him to Bellevue Hospital.
There he remained three days, and suddenly returned to consciousness and a knowledge of his
surroundings, but was entirely ignorant of his unfortunate experience. It is unnecessary to say his habits
were perfectly good and he was not drunk at the time of the quarrel or arrest. His last recollection was
that of going to bed the night before the day of his arrest.

Another case of unusual interest which came under my care, illustrating a phase of sensory epilepsy, is
worthy of reproduction:

C. O——, aged twenty-two, is a reporter attached to one of the New York afternoon papers, who
received a severe injury of the head when but three years old. He fell from the second story of an
unfinished building to the cellar, striking the upper and back part of his head upon a beam. He was
rendered unconscious, and remained so for a day or more. He recovered from the immediate bad effect,
but has suffered from severe general headaches, which recur every week or so, with an increase in the
amount of urine excreted. About six months ago he began to have epileptic convulsions of a violent
character almost every day, and sometimes more often. These were precipitated by excitement, and he
had a great many when worried about his wife at the time of her delivery. Upon one occasion he fell
down stairs and injured himself quite severely. The attacks were, as a rule, preceded by an epigastric
aura of long duration, and occasionally by a visual aura, and, according to the testimony of his
associates, he became strange and queer. When in such a dazed condition he would restlessly wander
about his office, and suddenly, without any cry, become convulsed. After the attack he slept soundly.
The bromides of sodium and ammonium and digitalis did little or no good, but the bromide of nickel
appeared to have some influence. During the past month he has had only two or three attacks, but
these have been of a quite irregular character. He told me that there were times when he felt like doing
himself an injury, and that he had impulses to kill some one else. His companions said he was irritable,
pugnacious, and easily thwarted, and his brother-in-law stated that upon several occasions he had
queer turns, when he would raise his hand to strike some member of the family—that he subsequently
knew nothing of his conduct, and when it was detailed to him he appeared greatly astonished.

Mr. O—— came to my office in company with a friend at ten o'clock in the morning of December 27,
1883. He had had one of his attacks at the newspaper office, of rather more severe character than
usual, at eight o'clock, with a psychical aura, during the existence of which he was very morose and
sullen. Upon recovery he was speechless, though he could communicate by signs. Upon his arrival at
my office his manner was composed and he appeared somewhat dazed. His pupils were dilated, but
contracted readily to light. I asked him one or more questions regarding his inability to speak, which he
perfectly understood, and when I gave him a pencil and a piece of paper he replied without difficulty in
writing. When told to make a great effort to speak he did so, and I thought I detected the word ‘To day,’
but he could not repeat it, though he tried and expressed great annoyance. He was unable to utter any
sound except a sort of groan, which could not in any way be taken as an element of speech. I examined
his larynx, but found nothing which could explain his impaired phonation, and I sent him to Dr. Asch,
who found absolutely no abnormal appearances to account for the speech difficulty. The patient could
not phonate, and though he made attempts to enunciate the vowel-sounds, and the vocal cords were
approximated, he made no orderly sound. Asch found a slight laryngitis of no importance.

The patient went home, and remained speechless all day, and was seen by my associate, G. de Forrest
Smith, in the evening. What occurred during and after that gentleman's visit is contained in his notes: “I
was called to see patient about 8.15 P.M. He was lying upon the bed, but had not slept; recognized me
and motioned that he could not speak, and I found that he could only say one or two words, and this
with the greatest effort, and so all my questions were put so that he could answer them by nodding or
shaking his head. He knew that he had had an attack in the morning, that he had seen Hamilton and
Asch, and recalled various incidents of the day, answering intelligently my questions in regard to them.
He indicated by motions that his inability to speak was due to a lump in his throat. When asked if he had
any trouble to think of the word he wanted, he shook his head, but shortly afterward hesitated in an
answer, and when asked if this was due to his inability to think of the word, said ‘Yes.’ Was asked if he
had any loss of power in either side, and he motioned to his right arm and leg, and said that he felt a
numbness and pricking on that side. On his grasping my hands with his, the right was perceptibly
weaker.

“At one time he seemed confused as to which was his right or left side, and put up both hands, and after
looking at first one and then the other in a puzzled manner, at last decided correctly, then smiled
apparently at his confusion.

“All this time he had been half lying on the bed. He now intimated that he was tired, put his head down
on the pillow and began to belch up wind, and as he appeared about to vomit I called for a basin; but
this was only the beginning of an attack; the muscles of the neck and right side assumed a state of tonic
spasm, the extensors predominating, so that the head was turned a little to the left and forcibly thrust
back into the pillow, and the right arm and leg were firmly extended. He remained in this position about
one minute; then, taking two or three full inspirations, put his hand to his throat and said plainly,
‘Something has fallen from there.’ On being asked ‘What?’ he replied, ‘A bone has fallen from my
throat.’ I told him it was well that the bone had fallen, as now he could speak. ‘Why,’ said he, ‘I have had
no difficulty in talking.’ On being asked why he had seen Asch, he said ‘Who is Dr. Asch? I never saw
any such person.’ Further questioning showed that all the occurrences of the day (except those which
had taken place immediately before the first attack) were an absolute blank, and he thought it still
morning. He asked the time, and I told him half-past eight o'clock in the evening. At this he seemed
much surprised and said, ‘Why, I went to work this morning; how did I come here?’ I then explained to
him that he had been ill. After further conversation he said he felt sleepy, and, after resting a few
minutes, he arose, put on his slippers, and came out into the room. He walked with difficulty, because of
the loss of power in the right side, which he said felt numb and sore, as if it had been pounded, also a
sensation of pins and needles. After the attack his mind was perfectly clear, and he could talk as well as
ever, and all that had happened before the attack in the morning he could remember perfectly well, but
the interval between the two was a complete blank. His inability to speak seemed due, not to lack of
knowledge of what he wanted to say, but rather to want of power to form the words, although there was
no paralysis of the vocal muscles. When he did manage to say a word, it was invariably the correct one,
but it was always done with the greatest effort. The day after the attacks he remained at home; the next
day he went to work, but his head felt heavy and confused. Two days after he complained of a pressure
on the left side and back part of the head; otherwise he was all right. At this visit he said that after I had
left him on the night of the attacks he intently thought, striving to recall the incidents of the day, and after
a time concluded he could remember being at Thirty-third street, but did not know how he got there. He
thought he could recall going to see Asch, but would not know him if he should see him. I then asked
him how questions were answered by him on that day; he answered he did not know, as he had not
thought of that; then, after a few moments' reflection, said he must have written the answers. He was
then shown some of the answers he had written, which he recognized, and by an effort of memory could
recall some of the incidents of writing them. He was still unable to remember anything that occurred
after his arrival home previous to the last convulsion.”

January 27, 1885: This patient subsequently suffered from several attacks in which the psychical
element predominated. His head presented a remarkable deformity, there being a prominence
posteriorly which might be compared to a caput succedaneum, only it was entirely osseous. The upper
margin was separated from the anterior parts by a deep sulcus.

Under such circumstances we find very often that acts of great violence are committed by such
epileptics for which they are entirely irresponsible. Two or three cases of the kind occur to me now. One
of them was a boy who always bit every one and everything—his family, the domestic animals, and
inanimate objects; another, a most dignified and lady-like woman, who violently struck different
members of her family; and within the past week a woman was brought to me who hurled a kerosene
lamp at a perfect stranger with whom she was quietly talking before the seizure was precipitated.
Numerous instances are related where individuals while in the masked epileptic state have wandered
for long distances and committed a variety of purposeless acts, and undoubtedly many of the
mysterious disappearances are of this order.

SENSORY EPILEPSY.—Some years ago Hammond referred to certain peculiar epileptic attacks in which
sensory manifestations were very pronounced. To this condition he gave the name thalamic epilepsy,
believing the condition to be one of the optic thalamus. Among the large number of unclassified and
irregular cases reported by various authors there are many so much resembling each other that I think
they should be relegated to a special place.32 The notable examples of Sommers, Bergmann, Tagges,
Guislain, and others belong to this category.
32 I shortly afterward, believing the term a misnomer, invented that in use: “On Cortical Sensory Discharging Lesions or Sensory
Epilepsy,” New York Med. Journal and Obstetrical Review, June, 1882; also see “A Contribution to the Study of Several Unusual
Forms of Sensory Epilepsy which are probably Dependent upon Lesions of the Occipital Cortex,” New York Med. Record, April 4,
1885.

The features of this form of epilepsy are (1) the expression of some hallucination (prodromal stage), or
hemiopia; (2) supraorbital neuralgia; (3) aphasia, formication; (4) slight loss of consciousness, and little
if any motor disturbance.

I may present two illustrative cases:

A few months ago I was consulted by a medical gentleman in regard to a patient who had for years
presented a curious train of nervous symptoms, which afterward assumed a form leading me to think
she might have sensory epilepsy. She would, in the presence of the gentleman who consulted me, who
was a personal friend of the patient and a medical man, stop short in the midst of an animated
conversation, look fixedly ahead, appearing momentarily lost, remaining abstracted for a short period,
possibly a minute, and on recovering herself go on, finishing the sentence she had commenced before
the seizure. At this time she constantly had hallucinations of a visual character, when she saw animals,
birds, figures of men and women, who approached her, as well as a variety of other objects. A common
hallucination, which had been repeated quite frequently, consisted in visions in which green leaves and
white rabbits and other objects familiar to her in childhood figured extensively. Upon one occasion, while
sitting in the drawing-room, opposite a door which communicated with the hall, she suddenly called her
companion's attention to the hand of a man which she saw clasping the baluster rail. The hand was
seemingly disconnected from the arm. She was somewhat agitated, and it was nearly half a minute
before the vision was dismissed. Sometimes she would call attention to the hallucinations before the
attack, but more often she became transfixed, apparently lost, and then recovering she described her
visions minutely. She has apparently been able to foresee the attacks and ward them off by a strong
voluntary effort. So far as can be learned, there is no hysterical element in the case, but her seizures are
more frequent at the time of menstruation. In a private note it is stated that “the family history of the
patient is very good, and she has always seemed remarkably healthy and robust, and has shown more
than usual intellectual ability. She has appeared to persons generally to be of a contented, happy
disposition.... At night, when she closed her eyes, she suffered from these hallucinations, especially
after a day of fatigue. Her pupils are usually dilated, but her color undergoes no change during the
seizure.”

The second case is one of a more complex type:

J. B——, a bright boy aged sixteen, was sent to me by F. H. Bosworth in April, 1883. He comes of
nervous stock, his mother being subject to epilepsy, and his father is an eccentric man who manifests
his mental peculiarities chiefly in a morbid restlessness and irascibility. There is a brother who is healthy.
The attention of the parents was first called to the boy's condition by his recital of a sudden attack which
occurred during the summer of 1882. While rowing upon a river he suddenly and completely lost the
visual use of the right eye, so that in looking at a number of ducks swimming near his boat he failed to
perceive those upon one side of the flock. This condition lasted for twenty minutes, and after a brief and
severe pain over the right eye he became unconscious, the unconsciousness being preceded by a
tingling and numbness of the hand, forearm, arm, and left side of the tongue. He has subsequently had
eight or ten of these attacks, of which the following is an example: Usually without any bad feelings,
physical or mental, he, while engaged in any duty or at any time, suffers a sudden unilateral blindness.
This is never gradual, and not like the form of amblyopia in which the visual field is gradually reduced.
There is some hemichromatopsia. It would seem as if the retinal anæsthesia was unequal, for while
usually the loss is complete and universal, it sometimes happens that there is only a limited loss. Upon
one occasion, while reading, he suddenly lost the printed matter of the right lower half of the page below
a diagonal line extending from the right upper corner to the left lower corner. There is never diplopia.
This deprivation lasts anywhere from ten to twenty minutes; meanwhile, a distal anæsthesia, coming
very gradually, involves at first the fingers of the opposite hand, and successively extends to the
forearm, arm, and other parts, as I have already mentioned. There seems to be analgesia as well as
anæsthesia, for a pin may be run into the muscles without producing pain, and upon one occasion the
gum was freely pricked without any discomfort to the patient. It invariably happened that the cutaneous
sensory trouble occurred upon the side opposite to the hemianopsia and neuralgia, and in the greater
number of instances the left side was that affected. The third stage of the attack consists in migrainous
headache of a very severe kind, and which sometimes lasts for an hour or more. There is a subjective
feeling as if the eye was pushed forward. This disappears with nausea and relaxation. More often he
loses consciousness when the anæsthesia reaches its limit, which seems to be the extension of the
anæsthesia to the gums. Occasionally there are slight convulsive movements upon the anæsthetic side.
While the attacks involve the left side of the body as a rule, it happens that when there is primary left
hemianopsia and right-sided anæsthesia the boy becomes very much confused in speech, and
sometimes is paraphasic, the trouble being but transitory. He is sometimes unable to speak at all,
though perfectly conscious and in possession of his faculties. No pupillary disturbance has been noticed
at any time. Upon two occasions there was a swelling of gums and tongue, which was not only
subjective, but perceived by the mother. Occasionally he sees prismatic colors and rays before the
blindness, but this has been only once or twice. During his early life he had attacks of slight numbness
of the hands and feet which were not thought much of, and he had headache as well. He has been a
somnambulist.
MORBID ANATOMY AND PATHOLOGY.—The literature of the experimental physiology of epilepsy is enriched
by the observations of a variety of careful students, among them Sir Astley Cooper, Kussmaul and
Tenner, Brown-Séquard, Nothnagel, Schroeder Van der Kolk, Pitres, Hughlings-Jackson, and the
followers of the localization school, as well as many others more or less distinguished.

The experiments of many of the early writers were directed for the purpose of ascertaining the relations
of circulatory variations to convulsive seizures, and the most notable were those of Burrows and
Kussmaul and Tenner. These latter produced compression of the carotid arteries, and instituted cerebral
anæmia by free and exhausting hemorrhages. As a consequence, the emptying of the cerebral vessels
was followed by a loss of consciousness and by epileptiform convulsions, and it was necessary to
produce the same result to compress all the great afferent vessels of the brain. The experience of
surgeons generally is, that ligation of the common carotid upon one side of the neck is sometimes very
apt to produce an alarming anæmia, with occasional convulsions, and sometimes fatal consequences.

The experiments of Hall, Landois, Hermann, and others, as well as those of the writers just mentioned,
show that carotid compression results in capilliary anæmia and venous hyperæmia, and that with
cessation of this pressure there is a sudden congestion of all vessels. The susceptibility of the brain is
greatest at its posterior part and between the optic thalami and the cord. When the bulb was subjected
to sudden changes in its nutrition—such, for instance, as followed the experiments of Hermann, who
ligated simultaneously the superior and inferior venæ cavæ of a rabbit—there were not only
convulsions, but various cardiac and other disturbances which were undoubtedly due to central
impairment of function. Kussmaul and Tenner conducted their experiments with watch-glasses luted into
the cranium—a procedure which, however, at best, is unreliable.

Brown-Séquard some years ago in part established an important pathological truth, the theory of
epileptic zones, and demonstrated in certain animals that bruising and injury of the great nerve-trunks,
especially the great sciatic, would give rise to epilepsy, and that irritation of certain tracts would
precipitate the paroxysms. He further announced that the progeny of animals in whom epilepsy had
been thus induced very frequently inherited the epilepsy of the parent. By some it was held that such
epilepsies were purely peripheral, and Brown-Séquard even believed in spinal epilepsy. His spinal
epilepsic theory has, for the most part, been explained by the anatomical researches of Hitzig and the
doctrine of interrupted spinal inhibition. In fact, many of the spinal epilepsies are examples of
exaggerated reflexes.

The epileptiginous zone theory, which, while it induced many to believe that the disease might have its
origin outside of the brain, gave rise to the false assumption that attacks with distal auræ were primarily
non-cerebral, has been discarded, and most observers have arrived at the conclusion that even in these
cases the first explosion is due to some cerebral cell-discharge.

Hughlings-Jackson's grand work has revolutionized the views held prior to his first published writings,
about twelve years ago. He believes that any part of the gray matter may, through over-excitability, give
rise to convulsive attacks.

The production of convulsions by cortical irritation is now an old story.

The experiment of Pitres and Frank33 bears upon the sensorial function of the cortex in showing that,
when the cortex is irritated, epileptiform convulsions follow, but if the exposed surface be subjected to
the ether spray the same irritation will only produce definite movements, but no convulsions.
33 Gazette des Hôpitaux, No. 38, 1883.

The investigations of Van der Kolk especially, and his followers, certainly give the medulla an important
place as the locus morbi of the malady; and it must be assumed, bearing in mind the existence of the
vaso-motor centres of Dieters and the presentation of symptoms indicative of disturbance at the floor of
the fourth ventricle, that the most important pathological changes must be looked for in this part of the
brain.
Jackson's cortical explanation is, however, fully in consonance with the medullary theory. If we study the
different stages of the attack, we shall find that there is probably a suspension of cortical inhibition—that
a derangement of the cortical cells or discharge may cause a resulting disturbance in the bulb. On the
other hand, a reflex irritation through the pneumogastric or from some distal part brings about the same
disturbance of equilibrium. There is anæmia due to irritation of the vaso-motor centre, an inhibition of the
great ganglion-cells, and a disturbance of function of the important cranial nerves. The primary anæmia
and unconsciousness are accounted for by this primary irritation of sympathetic filaments and vascular
constriction; the secondary hyperæmia is explained by the experiments of Kussmaul, which
demonstrated the succeeding congestion; or by irritation of the spinal accessory and contraction of the
muscles of the neck and compression of the large veins. The pupillary, ocular, respiratory, and other
symptoms indicate the disturbance of the nerve-nuclei in the bulb. The respiratory difficulty and the
interrupted decarbonization of the blood undoubtedly account for the secondary unconsciousness.

Van der Kolk34 in localizing the lesion in the medulla found capillary dilatations in the neighborhood of
the hypoglossal nuclei in tongue-biters. In epileptic patients who were in the habit of biting their tongues
during the fit the vessels were wider than in those who did not bite the tongue, on an average in the
course of the hypoglossus by 0.096; in the corpus olivare, which certainly here plays an important part,
by 0.098 mm.; and in the raphé by 0.055. In those who did not bite the tongue, on the contrary, the
vessels in the path of the vagus were 0.111 wider than in those in the first, Table A.35
34 “On the Minute Structure and Functions of the Spinal Cord,” by J. L. C. Schroeder Van der Kolk, New Syd. Soc. Trans.

35 TABLE.
Different Epileptics. Hypoglossus. Corpus olivare. Raphé. Vagus.
Table A—tongue biters 0.306 0.315 0.315 0.237
Table B—non biters 0.210 0.217 0.217 0.348
Difference +0.096 A. +0.098 A. +0.055 A. +0.111 B.

Nothnagel36 is of the opinion that the anæmia of the brain is not the cause of the convulsions, but that
the “excitation of the vaso-motor centre and that of the centre for the muscles are co-ordinate—that both
go on side by side, and are independent of each other.”
36 Ziemssen's Encyclopædia, vol. xiv. p. 268.

He by this theory explains the occurrence of those forms of petit mal in which there is loss of
consciousness without convulsions, and, on the other hand, twitchings before the coma.

The best argument in favor of this hypothesis is in Jacksonian epilepsy, when monospasms exist
oftentimes with a succeeding extension.

In those cases which are the outgrowth of migraine the pathological condition is probably an
exaggerated tendency to angio-spasm, the original impaired vascular tonus in the beginning giving rise
simply to pain and lesser troubles, while after repeated changes of calibre not only nutritive alterations
ensue, but hyperexcitability of the bulbar convulsion centres as well.

The labors of those who have endeavored to connect epilepsy with cerebral-tissue alterations have
been attended by nothing very definite or positive, so far as pathological explanation is concerned. The
post-mortem appearances have varied widely, and the only conclusion to be reached is that which
shows that almost any morbid gross alteration of the cerebral mass may be symptomatized by
convulsions, but such a production of paroxysmal trouble is much more likely to be the case, and in a
more definite manner, when the cortical motor-centres are subject to destructive disease or irritative
pressure. This is even not always the case, for numerous cases of injury of the paracentral lobe have
been recorded with no showing of resulting convulsions. The long list of autopsies which I will not here
consider show that an epilepsy may owe its origin to the pressure of a spicula of bone, or to the
pressure exercised by depressed fragments of the same—to tumors or adventitious products,
meningitis, cortical encephalitis, vascular degeneration, ventricular œdema, contusio-cerebri, and many
other morbid processes which result in rapid or tardy degeneration. Of course, in such cases the
genesis of the disease depends not so much upon the nature of the lesion as the location. The fruitful
collections of cases of Ogle and Jackson are full of examples of limited growth or disease involving the
cerebral cortex, while numerous cases collated by other writers show disease of the bulb or various
peripheral parts which have been closely connected with the growth and behavior of the affection.

Several able pathologists have independently and repeatedly found that sclerotic degeneration of the
hippocampal folds often existed. Delasiauve and Lébert first observed this lesion, but many modern
authorities—among them Meynert, Nothnagel, and Charcot—who have also found this appearance,
regard the change as of purely secondary, and consequently unimportant, character.

Tamburini37 reports a case of hemiplegic epilepsy with induration of the left optic thalamus and the left
cornu ammonis, in which aphasia existed. Pfleger38 and Henkes have also found the sole lesion to be
induration of the cornu ammonis. Of Pfleger's39 43 autopsies, atrophy and sclerosis of the cornu
ammonis were found twenty-five times, and it was noted that the extent of the morbid change bore
relation to the violence and frequency of the seizures.
37 Sallanzani, Modena, 1879, viii. 550-557.

38 Allg. Zeitschrift f. Psychiatrie, etc., Berlin, 1879, xxxvi. 359-365.

39 Ibid., lxxvi., and Arch. de Neurologie, No. 2, 1880, p. 299.

In many examples, especially where the disease has been found to be unilateral and associated with
more or less hemiatrophy, the autopsy disclosed a corresponding hemiatrophy of the brain. Many such
cases are reported. I have frequently found epilepsy in association with cerebral hypertrophy, and as a
symptom of cerebral tuberculosis it has long been recognized, and numerous cases are reported in
which for a long time the paroxysms were the only manifestations of the condition. In one of these
cases, reported by Luys,40 the bulb was found involved by tuberculous matter.
40 Archives gén. de Méd., 1869, ii. 641 et seq.

Convulsions have very frequently been noted in association with imperfect cerebral development, and
Echeverria laid great stress upon the hyperplastic increase in volume of certain parts of the brain.

Marie Bra41 has thus summed up her conclusions relating to the morbid anatomy of epilepsy:

“1. The mean weight of the brains of epileptics is less than the physiological mean.

“2. The cerebellum is greater than the physiological mean.

“3. There frequently exists an asymmetry between the lobes (not peculiar to epilepsy). The increase
of weight is sometimes found on the right and sometimes on the left side. Equality is the exception.

“4. In no form of mental disease (excepting perhaps general paresis, which is accompanied also by
epileptiform crises) have we met with so marked and constant a variation between the weights of
the hemispheres as exists in epilepsy.”
41 Referred to by Axenfeld.

Drasche, Green, Greenhow, Löbel, and others have detailed cases in which tuberculous deposits were
undoubtedly the causes of the disease.

Kussmaul and Tenner, Hoffman, and others have held that a stenosis of the superior part of the
vertebral canal may explain, through pressure upon the cord, the genesis of the attack, and Kroon found
asymmetry of the medulla oblongata.
The microscopical changes that have been found in brains where no gross lesion was apparent are by
no means distinctive. I have myself examined the brains of many epileptics with discouraging results.
The varying granular cell-degeneration, capillary dilatation, and exudative changes are common
enough. In several cases of cortical epilepsy I found more or less advanced degeneration of the great
cells in limited regions.

By far the most important and exact changes are those observed in the cases of sensory epilepsy. I
have elsewhere collected some continental cases. In brief, areas of occipital softening or degeneration
have been discovered in those cases with hallucination, sensory expressions, and hemiopia. In one
case attended by hallucination of smell the autopsy disclosed the following:

M. M——, was a stout Irish woman about forty years of age. She had suffered from a light form of
epilepsy dating from the tenth year, and resulting, as she stated, from a fall, when she struck her head
and was unconscious thereafter for some hours. No scar was visible, however. No satisfactory history
could be obtained regarding her early life and the first paroxysms. In the beginning these were rather
frequent, and she had as many as four or five a month. They afterward diminished in number and
severity, and for many years she had but three or four in the course of the year. They were not very
severe, and she was enabled to pursue her work as a housemaid, but did not keep her places for any
great length of time. She rarely bit her tongue, but usually frothed at the mouth and became livid and
convulsed for a short time. There was no history of one-sided spasms. As I have stated, I could gain no
accurate account of the previous attacks, except that she nearly always had an aura of a peculiar
character, which was a prominent feature of the seizure and very pronounced. She suddenly perceived
a disagreeable odor, sometimes of smoke, sometimes of a fetid character, and quite uncomplicated by
other sensory warnings; and afterward became unconscious, and remained so for two or three minutes.
She was invariably able to describe her sensations when she recovered, which she always did when I
asked her, comparing her warning to the smell of burning rags, to the smell from a match, and, as she
expressed it, it sometimes rose up in her head and choked her. She was under my observation for one
or two years, but eventually developed phthisis, and died, her attacks occurring from time to time until
her death.

Besides well-marked tuberculous lesions in the lungs, there was little of interest so far as the visceral
examination was concerned. The brain was removed and its peculiarities were carefully observed. A
great quantity of fluid was found, especially at the dependent portions of the membranes and in the
ventricles, while the dura was thickened and pearly in spots. There was a condition that might be
likened to a low grade of hemorrhagic pachymeningitis, and at the base of the brain old plastic changes
were found, there being adhesions, especially in the region of the middle lobes, but more particularly on
the right side and near the median line. The brain as a whole was small, and weighed forty-one ounces
and a fraction. The sulci were deep and gaping, and the convolutions were distinct. There was no
atrophy of the fore-brain convolutions, and no other pathological appearance was presented except that
found in the meninges, but at the lower part of the temporo-sphenoidal lobe of the right side an
appearance was found of an exceedingly interesting nature. At this point a decided shrinkage of tissue
was discovered, with depression and adhesion of the pia, the induration involving the uncinate gyrus
and parts of the adjacent convolutions, as represented in the drawing. No induration or softening of the
great motor tracts was observed, and the optic thalamus and parts adjacent were uninvolved, as was
the cord. An attempted microscopic examination, undertaken some months subsequently, was
unsatisfactory, because of the bad condition of the brain, the preserving fluid having been improperly
made. The olfactory nerves were not involved. The third frontal convolution was examined, but no
disease was found there. Consequently, it is to be inferred that no lesion of the external root of the
olfactory nerve existed.
FIG. 27.

Lower Face of Right Hemisphere.

DIAGNOSIS.—Having spoken of epilepsy as in most instances a


symptomatic disorder, it would be proper to confine this section to
the differentiation of the simpler and more classical form of the
idiopathic disorder from certain purely eclamptic attacks or those due
to cerebral tumor or coarse degeneration. The epileptic attack itself
is to be considered from its time of happening, its duration, the
element of unconsciousness, its associations, and the antecedent
history of the individual. It may be confounded with the similar
phenomenon dependent upon cardiac weakness, uræmic poisoning,
toxic or alcoholic saturation, etc.

Of course, when we find recurring seizures with a certain amount of


what Carter-Gray calls quasi-periodicity, preferring perhaps the night,
the early morning, or only the daytime, we are almost sure of
epilepsy. This supposition is strengthened by the association with
attacks of petit mal. The duration of an attack, which may be from a
few seconds to several minutes, is also a guide, for in certain toxic
and other paroxysms the rule is for a succession of attacks to occur.

The question of consciousness is one that has drawn forth a great


deal of discussion, especially with reference to medico-legal cases. I
think the majority of clinicians are agreed that loss of consciousness
is an absolute belonging of epilepsy, yet there are cases in which the
lapse is scarcely perceptible. It is a dangerous precedent to
establish, for the convulsive symptoms in such cases are taken from
the epileptoid category. It is quite true that there are many hemi-
epilepsies in which the intellectual condition is one that may easily
be mistaken. I have seen numerous cases in which an apparent
conservation of consciousness remained throughout a slight
monospasm, but I do not feel at all sure of this; and in cases of
aborted or masked epilepsy there is a dual mental state which would
readily deceive the lay observer. The case of Mrs. S—— is an
example of this kind. After the obvious subsidence of the dramatic
and conspicuous feature of the fit she remained for hours and days
in a state of undoubted transposition, performing acts which required
something more than a high degree of automatism—going to the
table, talking about certain subjects which were suggested, with
apparent ease, but not connecting them intelligently with her
surroundings, as she would before and after the epileptoid state.
After a time she apparently resumed her normal state, but was
entirely unconscious of the happenings of her previous hours or
days, not even recollecting her simplest actions. Julian Hawthorne's
hero in Archibald Malmaison, though not drawn by a physician's pen,
suggests the state of which I speak, and it has the merit of being
based upon one of the elder Forbes Winslow's interesting cases.

When we find paroxysmal attacks occurring in individuals with


atypical heads, thick swollen lips, scarred tongues, and irregular
teeth, we may strongly suspect the patient to be epileptic. To these
we may add the appearance of the eyes, the fishy, lack-lustre
expression which betokens old epilepsy. The hands are clammy and
the skin mud-colored; the hair is dry and coarse; and the body often
has a death-like odor.

In children, certain mental peculiarities are to be inquired into.


Unnatural brightness or dulness—what may be called the clumsy
organization—is often present, and the muscular use is often
imperfect. We find that there is often but little nicety in walking, in
using the hands, in speaking, or after learning to write there is an
incapacity, with ever so much teaching, to develop a character or
style. Such children can never become ambidextrous. These little
points may seem trifling, but to the physician who carefully studies
his cases they may prove of great help. The history of the nights may
often lead to the discovery perhaps of a long-existing nocturnal
epilepsy. Incontinence of urine, blood upon the pillow, nightmares,
morning headache, and petechiæ betoken unsuspected night
attacks; and Le Grand du Saulk mentions the case of a young
Englishman who committed a purposeless crime and was
discovered to be epileptic, the diagnosis being confirmed by an
antecedent history of nocturnal seizures, and subsequent watching
resulted in the discovery of many night attacks.

As to special conditions with which the epilepsy may be confounded,


I may refer to cardiac weakness. It not rarely happens that simple
fainting attacks are confounded with those of an epileptic nature.
Such is the case more often in heat-prostration, when some rigidity
attends the loss of consciousness. The duration of such a state, the
condition of the pulse and color, however, will easily clear up any
doubts upon the part of the observer. The existence of a cause
should also be considered, and the fact that usually the epileptic
paroxysm is sudden, while a feeling of depression and feebleness
precedes the fainting attack, should be remembered. I may present
in tabular form the points of difference:

EPILEPSY. SYNCOPE.
Loss of consciousness Loss of consciousness follows
sudden. feeling of faintness.
Period of complete Unconscious throughout, no
unconsciousness usually convulsions.
short.
The existence of auræ of a The existence of preliminary vague
well-defined type. prostration, nausea, and irregular
heart action.
Often involuntary discharge Quite rare or never.
from bowels and bladder.
Patient usually falls into heavy After slight weakness patient is
sleep or is indifferent after anxious and worried, and quickly
convulsion. seeks relief.

The difficulty of diagnosis, however, is only in cases of petit mal.


There are light forms of auditory vertigo that may resemble
vertiginous epilepsy. In the former there is never loss of
consciousness, and the patient refers to the rotary character of the
vertigo. A history of antecedent attacks, tinnitus, aural disease, and a
certain constancy which is not a feature of petit mal, may be
mentioned.

There are cases, however, which are puzzling, and come under the
head of auditory epilepsy rather than auditory vertigo; and in these
there is a multiplicity of expressions, the auditory symptoms
predominating.

Of uræmic convulsions it is hardly necessary to speak. There is a


previous history of renal disease which the microscope and less
delicate tests will reveal, and clinically there is antecedent headache,
some stupidity, and not unrarely thickness of speech and
somnolence. There are some cases, however, which are obscure. I
have known patients with chronic renal disease—such as waxy
kidney, for instance—to develop a species of epilepsy, the
paroxysms recurring from time to time and behaving very much as
the idiopathic disease would; and their occurrence would mark some
imprudence in diet or exposure, and their disappearance an
improvement in the patient's general condition. The attacks were not
classical, inasmuch as there seemed to be but one stage of violent
clonic convulsion, preceded by intellectual dulness, and followed by
a semi-comatose condition which was far mere profound than the
somnolent stage of epilepsy. The movements were not accompanied
by a great degree of opisthotonos or pleurosthotonos.

Alcoholic and absinthic epilepsies are usually preceded and followed


by symptoms indicative of profound saturation.

The consideration of hysterical epilepsy may be found elsewhere,


but it may do to briefly refer to some cases which do not present the
phenomenon first described by Charcot and Bourneville. The
ordinary hysterical attack is never attended by loss of
consciousness, by any of the pupillary changes so constant in
epilepsy, by the mobility of the pupil between the attacks which is
present in a large number of true epileptic individuals. There are
never the succeeding changes of color, and the seizures are
commonly produced or attended by some emotional disturbance, or
are associated with ovarian disturbance.

Epilepsy is occasionally simulated by malingerers, and sometimes


the skill of the subject is so great as to even deceive the practised
eye. Prisoners, soldiers, and litigants may counterfeit an epilepsy,
and go through with great personal suffering to accomplish their
purpose. “Clegg, the dummy-chucker,” whose remarkable case has
figured in the medical journals, upon one occasion threw himself
from an iron platform to the stone floor of the jail, nearly twenty feet
below, to convince a suspicious physician of his honesty. The
simulator rarely bears close watching. The dilatation and contraction
of the pupil cannot be simulated, nor can the corneal or pupillary
insensibility. The fraud cannot voluntarily change his color, as is the
case in true epilepsy, and as a rule the thumbs of the impostor are
never flexed, as they should be. Suggestions for a purpose are
readily heard, and sometimes adopted, by the apparently
unconscious man. Gottardi42 lays great stress upon the use of the
ophthalmoscope as a means of detecting simulated epilepsy. He
calls attention to the frequency of retinal changes with facial
asymmetry and other evidences that suggest cerebral disease or
non-development. Gottardi has found that the pulse in true epilepsy
is always lower after an attack, but it soon reaches its normal
standard.
42 Abstract in Journal of N. and M. Dis., Oct., 1881, p. 843.

The differentiation of idiopathic epilepsy from that due to syphilis is


possible when we consider the element of pain. Besides the tibial
pains of syphilis, the epilepsy thus produced is often preceded by
intense frontal headache, while that of ordinary epilepsy follows the
attack. The syphilitic epilepsy is not attended by so great or
continued a loss of consciousness as the non-specific form, and the
movements are apt to be most violent on one side or the other. The
association of the attacks with various bodily signs, such as nodes,
old scars, alopecia, erosions, etc., and in connection with possible
cranial nerve-paralyses, will throw light upon its true character. The
paralyses referred to seem most frequently to involve the motor
ocularis, abducens, and patheticus. Syphilitic epilepsy, too, is quite
irregular in its time of manifestation, and is not unrarely followed by
aphasia; but the interparoxysmal mental state is one of extreme
dulness, memory being blunted and there being a peculiar hebetude.

PROGNOSIS.—Within the past quarter of a century the ideas of the


medical profession regarding the curability of epilepsy have certainly
undergone a change. The statistics of Bennett and others show that
since the introduction of the bromic salts the proportion of cures has
been decidedly increased. Nevertheless, the disease is a most
discouraging and troublesome one to manage, and especially is this
the case when it assumes the form of petit mal. The rapid recurrence
of light attacks is, as has already been said, very apt to lead not only
to mental enfeeblement, but is very often followed by very severe
paroxysms.

Epilepsy of a more or less constant form, in which the seizures


resemble each other, is far more incurable than that of variable type;
for example, we find that unilateral seizures are much more apt to be
associated with established cortical disease than when they are
general and simply explosive manifestations. It has been held that a
tendency to permanency is marked by a diminution in the extent of
the interval. This is by no means true. I have had cases under
observation for ten or twelve years in which attacks separated by
intervals of six months or one year marked the course of the
disease, in which frequent initial attacks were present. These cases I
regard as very bad so far as prognosis is concerned. I much prefer a
history of irregular and comparatively disorderly attacks. In female
subjects the menstrual influence is not always a bad factor. When we
are enabled to remove some production of an exciting cause in
connection with the catamenia the prognosis is more hopeful; but an
opinion must be expressed with great caution, especially in those
cases beginning at an early age and not after the establishment of
the menses. Traumatic cases are not always bad, but those in which
the element of heredity plays a part most certainly are, Herpin and
Gowers to the contrary; and though these cases for a time do well
under treatment, its good effects are not constant. Individuals with
misshapen heads, whose deformity suggests premature sutural
ossification, are not susceptible to the influence of treatment, and all
other osseous changes, such as exostosis, plaques in the dura, and
bony growths, whose existence can only be guessed at or inferred
from suggestive appearances elsewhere, give rise to a variety of
epilepsy which is beyond the reach of drugs. With symptomatic
epilepsies the case is sometimes different, for while the seizures
which arise from the irritation of a cerebral tumor are almost as
hopeless as the form I have just mentioned, we know from
experience that the epilepsy of syphilis and other allied diseases,
and those of toxic origin, with the exception sometimes of those
occasionally due to alcohol or lead, are curable. The meningeal
thickening of alcoholic origin or the encephalopathy of lead may be
the pathological bases of very intractable paroxysms.

So far as age is concerned, it may be stated that many eclamptic


seizures of young children which are due to well-recognized irritable
causes are promptly cured if there be no hydrops ventriculi or
preossification of the coronal sutures, and if the epileptic habit is not
established. The epilepsies of six or eight years' standing are not
encouraging from a therapeutic point of view, and those of advanced
life developing in aged persons are equally unfavorable.

The treatment of epilepsy due to heat-stroke is by no means


satisfactory, and, though the attacks are often separated by long
periods, they are apt to recur in spite of drugs.

Gowers has prepared several valuable tables which show the


influence of age upon recovery. He says: “The following table shows
that age has a distinct influence on prognosis. The percentage of the
unimproved cases to the whole is 30 (43:143::30:100). The
percentage of the cases commencing at each age arrested and
unimproved is stated, and between brackets is indicated the excess
of the arrested or unimproved cases at each period of life over the
proportion for the whole 30 and 70 per cent. respectively:

———Cases.——— ———Percentage.———
Unimproved. Arrested. Unimproved. Arrested.
Under 10 14 29 32.5(+2.5) 67.5
From 10-19 23 45 34 (+4) 66
20 and over 6 26 19 81 (+11)
43 100 30 70

Thus, the proportion of the cases commencing under twenty in which


arrest was obtained is considerably less than the proportion of cases
commencing over twenty, the difference amounting to about 13 per
cent. The period of the first twenty years of life at which the disease
commences has little influence, but the prognosis is little better in the
cases which commence under ten than in those which commence
between ten and twenty: arrest is more frequently obtained. The
cases which commence in women at the second climacteric period
are also obstinate, although not sufficiently numerous to be
separately given.”

He also finds, from an analysis of the same cases, the fact noted by
others, that the prognosis is favorable in inverse proportion to the
duration of the disease.

Attacks which chiefly occur in the daytime are much more amenable
to treatment than the nocturnal seizures, and especially is this the
case in the tongue-biting form. Sudden blows upon the head or falls
have been known in isolated cases to effect an amelioration in the
patient's disease, but these examples are rare.

The existence of an aura is much better than if none existed.

Death from the attack itself is rare, yet in the large pauper institution
with which I was connected for many years I have known of several
cases. More often the death results from asphyxia resulting from a
bolus of food which chokes the patient or from a fall in some
dangerous place—into the fire or elsewhere. Accidental death from
drowning is more common than any other form.

The status epileptica into which patients sometimes pass who have
had many convulsions is occasionally a fatal termination of the
malady, and is always a serious feature.

The influence of different epochs in life is worthy of consideration: of


menstruation, of marriage, of pregnancy, and of the menopause
there is much to be said. I have sufficiently spoken of the
establishment of the menstrual flow, and I would only add another
word of caution against giving a too favorable prognosis except in
those cases of very recent origin. Marriage appears to have very
little to do with changing the attacks, unless they be of an hysteroid
character. I have never known epilepsy to influence the course of a
pregnancy in any unfavorable way, and I think this has been the
observation of others. Gowers refers to cases in which the attacks
ceased during the time the mother was carrying the child.

The occasional bad influence of the pregnant state has been


illustrated by a case reported by Terrillon.43 This example was a
woman who had been the victim of epilepsy of hereditary origin since
her seventh year. At the commencement of menstruation her attacks
became periodic, and recurred every two months, and she had
several two or three days before the flow. Two pregnancies followed
several years afterward. During the periods they were increased in
number and severity, and occurred several times daily. She had
more attacks at this period than in all the time after delivery.
43 Annales de Gynécologie, June, 1881, p. 401.

I have found that the relief of uterine flexion or the establishment of


menstruation has exercised a decidedly modifying influence for the
better in several cases.

Sometimes the disease is interrupted by the menopause, but very


often in my experience it has changed in type and been followed by
mental degeneration.
The prognosis of the epileptoid mental state is serious in the
extreme, and even when in early life the attacks are aborted or
changed to perversion of the intellect or emotions existing as a
complication, the hope of cure dwindles almost to nothing.

The spontaneous cure of epilepsy is rare. Its course, however, is


more often interrupted by some intercurrent disease. Of 33 cases
observed by Delasiauve in which there was some complicating
disease, such as erysipelas, pneumonia, pleurisy, acute articular
rheumatism, burns and contusions, scarlatina, erythema, or the
condition of pregnancy, it was found that in 25 cases there was a
decided improvement (une heureuse influence), and in 8 only was
there no modification of the attacks. Axenfeld is disposed to believe
that acute and febrile disorders more decidedly influence the course
of epilepsy than those of a chronic nature. The influence of either
may be small or may diminish the number of attacks without curing
the disease.

TREATMENT.—The treatment of epilepsy depends so much upon the


form of the disease that no arbitrary rule can be laid down upon
general principles, and we must bear in mind the necessity for
removing the exciting causes if possible, the preservation of the
balance of cerebral blood-pressure and cell-equilibrium, and the
nutrition of the cerebral mass. It may be our purpose to remove
various toxæmic or cachectic states as well. As a minor division of
treatment we must consider the abortion of the attack when auræ
are detected. It has been the custom, I think among too many, to
manage the disease in an empirical manner, depending upon some
routine course of treatment, such as the indiscriminate use of the
bromides, for example. I am convinced that the intractable character
of the disease has come to be greatly exaggerated through failures
attendant upon the wholesale use of the bromic salts, without regard
to the indication in each particular case. It behooves us first to select
a reliable bromide, and then to give it with relation to the time of the
fit, its severity, and the condition of the individual. The importance of
this has impressed me very often. An equally divided daily dose will
not do a patient who has matutinal attacks the same good as will a
large dose at night, and in certain anæmic individuals the bromides
very often increase the attack. Then, too, the cases in which
seizures of petit mal predominate are not benefited to the extent that
those are in which the repetition of severe attacks is the feature. The
bromide should always be well diluted and given when the stomach
is empty or nearly so. The bromide of sodium is, to my mind, the
most serviceable salt, and when given alone or combined with the
bromide of ammonium is better than the potassic salt or the various
others. It should be carefully kept in solution or in waxed-paper
powders in a tight preserve-jar. As to its method of administration, I
much prefer the use of a solution which shall combine other
adjuvants which I will presently mention, and separate powders as
well, which may be used to reinforce the dose. The latter are to be
employed by the patient in the event of an unlooked-for series of
attacks, and are to be used to the point of producing mild bromism at
the time. In certain cases it is all-important to take into consideration
the condition of the heart. In some cases where there is manifest
and continued cerebral congestion, with full vessels and hard pulse, I
have found that the combination with chloral or aconite was
desirable. In other cases where the heart's action was irregular and
weak my experience with digitalis and nitro-glycerin or with
strychnine was most happy. In those cases that passed large
quantities of clear urine of low specific gravity the action of nitro-
glycerin and digitalis has been most prompt, and the same has been
true of epilepsies of migrainous origin.

There have been various methods of using the bromide suggested


which are more or less practical. The writers of a few years ago
suggested the prompt production of bromism—a state in which the
patient should be kept for a long time. This I strongly disapprove of,
not only because the mental and physical depression is a very
disagreeable and sometimes permanent condition, but because I
have found that the attacks are often increased after a time, though
at first they may have been suppressed. Others believe in giving the
bromides at intervals, with periods when no medicine at all is
administered.
For my own part, I am in favor of the establishment of a mild
bromism which does not extend beyond a slight anæsthesia of the
fauces or the appearance of slight acne. If I find it necessary to
increase the dose, I give cod-liver oil, iron, and bark or some of the
many preparations of the hypophosphites for a time; and they do not
diminish the specific effects of the drug to any great extent. In the
event of a series of attacks I direct the patient to take an extra dose
at such time as will anticipate the seizure.

This treatment should be kept up for at least two or three years after
the attacks have disappeared, and it may be even necessary to
continue a bromide course in a small way for an unlimited period.

If there be an hysterical element, or if ovarian excitement is


supposed to have anything to do with the attacks, the combination of
cannabis indica is strongly recommended. This suggestion holds
good in the cases where migraine is associated with the epilepsy, or
the latter is an outgrowth of the former.

Next to the bromides of potassium and sodium I have been very


successful with the nickel bromide. I find that it is retained with little
trouble, producing no gastric derangement if taken after eating. A
syrup prepared by most of the good pharmacists is preferable to any
other method of administering the salt. Quite recently Leaman44 has
reported two cases of severe epilepsy which were greatly benefited.
His conclusion is that it does most good in the form of the disease
when the attacks are separated by long intervals.
44 Med. News, Apr. 18, 1885.

The bromate of potassium, which has been used by Weir Mitchell45


and Hinsdale, may be worthy of a trial. It should never be given,
however, in larger doses than five or ten grains thrice daily. These
investigators found that thirty grains slowed the heart very
considerably, and forty grains produced watery discharges from the
bowels and drowsiness. In their hands, notwithstanding these
disagreeable effects, it controlled the seizures. The hydrobromate of
conia is a comparatively new remedy which has been

You might also like