100% found this document useful (2 votes)
70 views

Building Java Programs: A Back to Basics Approach Stuart Reges 2024 Scribd Download

Reges

Uploaded by

bredabatayo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
70 views

Building Java Programs: A Back to Basics Approach Stuart Reges 2024 Scribd Download

Reges

Uploaded by

bredabatayo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Building Java Programs: A Back to Basics Approach


Stuart Reges

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

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

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/

textboxfull.com

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/

textboxfull.com

Building Python Programs 1st Edition Stuart Reges

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

textboxfull.com

Simpler Living Back to Basics Guides 2nd Edition Jeff


Davidson

https://textbookfull.com/product/simpler-living-back-to-basics-
guides-2nd-edition-jeff-davidson/

textboxfull.com
College physics : a strategic approach 4th Edition Stuart
Field

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

textboxfull.com

Artificial Intelligence: A Modern Approach 4th Edition


Stuart Russell

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

textboxfull.com

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/
textboxfull.com

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/
textboxfull.com

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/
textboxfull.com
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


Exploring the Variety of Random
Documents with Different Content
town. Ten lamps lighted up the vast room that evening, but were not
sufficient to show off the fine old high-timbered ceiling.
Madame Dulaurens anxiously left her daughter, and drawing back
the window-curtain looked out into the square, which she saw by the
gas-jets flickering in the keen frosty air, was quite empty. She drew
down the blind and looked at the party. They seem so interested in
their talk that she decided to wait a few minutes longer.
“Madame Orlandi, who is always late, came too soon to-day,” she
thought rather spitefully.
Round the fireplace the women were listening to Mademoiselle
de Songeon, who was describing the catacombs at Rome with the
devotion of a catechumen. Madame Orlandi, artlessly devoid of
morality and unskilled at suitable comparisons, said she preferred
the ruins at Pompeii, because the pictures there were so diverting.
Mesdames de Lavernay and d’Amberlard, mature and solemn
women, had no opinion at all. Their aristocracy was very pleasing to
Madame Dulaurens, who gladly advertised their origin. They were
well-bred, and valued existence according to the number and the
importance of the invitations that they managed to procure for
themselves. Their husbands, a pair of practised parasites, had
retained a distinguished air from the old royalist days. They had the
right prejudices, were sincerely ignorant of modern life, and sought
pleasure unceasingly. Baron d’Amberlard had high color and liked
good living; the Marquis de Lavernay, still young in spite of his white
hair, reserved his polite speeches concerning feminine beauty.
The latter had just come from the Court of Sessions and was
giving a group of men his impressions of the jury.
“You condemn a thief and let a child-murderer go scot-free,” said
M. Dulaurens. But the nervous little man hastened to add: “Please
note that I am not criticising you.”
M. de Lavernay laughed unreservedly.
“Ah, my dear fellow, if we sentenced child-murderers we should
never have any servants.”
“What a mania there is for having children!” cried M.
d’Amberlard. “One’s family should be governed by the state of one’s
finances. What do you think about it, M. Landeau?”
M. Landeau admitted that he had thought nothing about it. As a
millionaire, he was always fighting terrible battles with labor so as to
be able to pour a golden rain upon his wife and at last with a
triumphant cheque to touch her proud heart. She played with him
much in the same way a tamer does with the beast that roars,
threatens, and arches its back. Under the pretext of filial duty
towards Madame Orlandi (who did not care at all what she did) she
had refused to follow him to Lyons; so twice a week he came to see
her in the splendid villa he had built for her on the Cognin road. It
was an overworked man with bent shoulders and pale face that she
dragged with her into society. There, tamely growling, he admired
Isabelle’s beauty and listened joylessly to her bell-like laughter, as
she showed her white and shining teeth.
M. d’Amberlard, stifling a yawn, began to fidget.
“I’m afraid the dinner will be spoilt. It has been kept waiting too
long,” he whispered to the Marquis de Lavernay, who made no
answer but hastened to an empty seat beside Madame Landeau,
where he was seen shaking his long horse-like head in his efforts to
please.
Armand de Marthenay, motionless and silent up to now,
overheard this and woke from the torpor into which he had sunk.
“It is all Clément’s fault. He must have had a smash up.”
He spoke so loudly that everybody heard and turned towards
him. The long wait had become unbearable to all. The hands of the
clock pointed to eight.
Again Madame Dulaurens tried to hide her anxiety. “Clément,”
she said, “is very careful. But these cars are dangerous at night. One
can so easily run into something in the dark.”
“Where did he go?” asked the women.
“That is just what is worrying me. He left for La Chênaie at five
o’clock. It would hardly take him ten minutes, it is only two miles.
And he hasn’t come back.”
Anxious as ever for peace, M. Dulaurens assured them that
nothing had ever happened to Clément.
“Not to Clément,” Marthenay sarcastically put in. “He is a young
devil! He is always running over something,—hens and dogs, and
the other day it was an old woman.”
“We paid her,” said Madame Dulaurens indignantly. “And paid her
very well indeed.”
“She is limping about on your money.”
M. de Lavernay gallantly, and without any suspicion of irony,
explained to his hostess that there were unfortunate creatures who
were in the habit of throwing themselves in front of motor cars, so
as to make money out of the owners. All except Mademoiselle de
Songeon, who hated progress, were in favor of this fashionable sport
and were busy defending it when Clément entered, looking very jolly
and with a red face, his fur coat covered with frost which shone in
the light.
Madame Dulaurens rushed up to him and scolded him well
instead of satisfying her desire to kiss him. Since her daughter’s
marriage she had insisted on playing a much larger part in her son’s
life. He made no attempt to excuse himself, but laughed, melting like
an icicle all the time.
“Oh, well, we got stuck at Cognin. Such a bad business!”
M. d’Amberlard tossed his head furiously.
“A nice business indeed,” he said. “Dinner kept waiting! He is
talking very coolly about it, the young scoundrel.” He was still raging
inwardly when Madame Dulaurens took his arm to go in to dinner.
Clément made as though to offer his to Mademoiselle de Songeon,
who stared at him scornfully and ordered him to go and dry himself.
“You are quite right, Mademoiselle de Songeon,” he replied
philosophically. “But you aren’t very kind! I shall go and dry myself
and change too.”
He disappeared, returning in his dinner-jacket as they were
serving the filet of beef with mushrooms. With all the coolness of the
rising generation, he asked loudly for soup and fish and made no
attempt to make up for his delay.
As the courses succeeded one another harmoniously, the guests’
pleasure grew and the conversation became general. Clément,
having satisfied his appetite, was burning to take part in it and
attract the attention of the table. He watched his opportunity and
called across the room: “I have some great news for you.”
“What is it?” they cried on all sides.
“I heard it at Cognin. I had it from my chauffeur, who heard it
from the schoolmaster.”
“Cognin news,” said Isabelle ironically. “It will interest the whole
of France!”

“At the news I bring you


Your lovely eyes will weep,”

Clément hummed to the air of “Malbrough.”


“Ha, ha!” laughed everybody.
“You may laugh, Madame, but my news will interest the whole of
France.”
“Then tell us what it is,” cried several voices at once.
Every eye was on the young man. He enjoyed the momentary
superiority which his possession of news gave him. Holding the
whole table at his mercy he had succeeded in gaining his ends. They
were now serving truffled galantine “des gourmets” as it was called,
the glory of a Toulouse specialist. In front of each guest costly
orchids of various hues blossomed in a tall Murano vase. It was
Alice’s idea to have this decoration, which she had read of in a
society paper.
“Well?” said Madame Dulaurens, speaking in the name of all.
Clément could contain himself no longer. He had had time
enough to appreciate his own tactlessness, but with the utmost
coolness he said: “Well, Commander Guibert is dead!”
This news, dropped like a bombshell in the middle of a gay
dinner-party, all but perfect in its arrangements, amid the warmth,
the lights, the charming flowers, the dazzling jewels, the lovely
dresses, and the general cheerfulness, seemed almost an
impropriety. It would be only the unmannerly Clément, coarsened by
sport, who could be guilty of such a blunder. Why, the very
introduction of the subject of death seemed to imply that the
pleasures of the evening were not everlasting; and does not the
whole art of enjoying the present consist in supposing it will last
forever? And then if it had only been the death of some unknown
person, they could have passed it over! But Commander Guibert
could not be so quickly disposed of; the common knowledge of his
origin, his personality, and his brilliant career prevented his name
from dropping out of the conversation. Stupefaction reigned at the
table.
Isabelle was the first to speak, and it was to cast doubts on the
truth of the story.
“But it is not possible! Last year we might have believed you. He
was taking part in the Moureau Expedition to Africa. He was
travelling in unknown and dangerous countries. But he came back
safe and sound, and famous as well. Now he is commander and an
officer of the Legion of Honour at thirty-two. He is our great man.
You are all jealous of him, so you think you will just get rid of him.”
She spoke with animation, turning from right to left in her chair,
as if inviting all the guests to witness her anger. On Clément’s
unhappy remark she had looked at Alice and saw the blood leave her
cheeks as though she were dying. This mortal pallor extended even
to her hands, which shook nervously, hardly distinguishable from the
white cloth. Isabelle had immediately turned the attention on herself
with her hasty words.
Clément made a slight gesture.
“No, he is dead. I admire him as much as you do, but he is
dead.” And he repeated this word, which should never be spoken in
a dining-room.
“Oh, for Heaven’s sake do be quiet,” murmured Madame Orlandi,
who had just noticed that they were thirteen at table, counting twice
over in the hope that she was mistaken. Solemnly Mademoiselle de
Songeon exclaimed: “May God rest his soul in peace.”
“Did he die in France?” asked M. Dulaurens. “The Expedition
came back a month or two ago.”
M. d’Amberlard, quite unmoved, was enjoying a truffle that he
kept on his plate so as to reserve its taste to the last, and M. de
Lavernay kept his eyes fixed on Isabelle’s corsage as she bent
forward.
M. de Marthenay put down his glass, which he kept emptying
constantly.
“I met the Commander,” he said, “scarcely three weeks ago. He
was getting out at the station. I went up to him but he seemed not
to know me.”
“Probably because he didn’t want to,” Isabelle could not refrain
from remarking. She hated Alice’s husband, who made persistent
love to her when he had lost at cards and had nothing else to do.
And to prevent any more allusions she added: “No doubt he has a
contempt for officers who have resigned.”
M. de Marthenay had left the army the year before.
“He had a contempt, you mean,” said Clément cruelly. He would
not allow them to rob him of his dead, and when he had
reconquered the general attention he gave a few details.
“My brother-in-law is quite right,” he said. “Commander Guibert
did come back to Savoy last month. He stayed two days with his
mother and sister at Le Maupas and then returned to his barracks at
Timmimun, in Southern Algiers.”
“At the entrance to Touât,” explained the ex-dragoon, who since
he left the army was exceeding keen about all military questions.
“But General Lervières passed Timmimun to-day, so the Berbers and
the Doui-Menia must have attacked him from the rear.”
Young Dulaurens stuck his monocle in his eye and stared
impertinently at Marthenay.
“Armand,” said he, “I don’t recognise you. Have you gone in for
strategy?”
With another look at her friend’s bloodless face, Isabelle made a
fresh interruption.
“I do not understand. He had scarcely returned from crossing the
Sahara, a trip which lasted eighteen months or two years, I don’t
quite remember which. After these expeditions one generally has a
long leave. Then he evidently took no rest? He went back at once to
this expedition? Because, if he is dead, he must have been killed in
battle.”
Raising his eyebrows, Clément let his eyeglass fall.
“When a man is a hero he is not one by halves. He asked for this
post on account of the danger.”
M. de Lavernay, bending towards his neighbor, whispered in her
ear:
“I like to see you get excited. Your cheeks color and your eyes
flash.”
But it was not at either her cheeks or her eyes that he was
looking. The impatient Isabelle cut him short with that sharpness
which marriage had not cured.
“Do be quiet, you old sinner!” she cried.
Alice had taken up her bouquet of orchids and was smelling it,
half hiding her paleness. At last Isabelle, giving full vent to the
uneasiness which had tortured her for the last few minutes, said,
“And Captain Berlier? He was coming back from the Sahara too.
He belonged to the same regiment as Commander Guibert. Had he
gone with him to Timmimun?”
Did Clément Dulaurens guess her anxiety from the tone of her
voice? Too often had he suffered from her sarcastic remarks not to
take a cruel pleasure in tormenting her a little now.
“Yes, that is true,” he said. “Jean Berlier must have been there as
well.”
“Now what do you know exactly?” demanded Isabelle
imperiously.
“Tell us what you heard,” put in Madame Dulaurens. Annoyed at
the course of the conversation, she had given up all hope of
diverting it and was resigned to hearing the whole story.
“Well, here you are! While they were mending my car at Cognin I
went into the Café National. There were only the mayor, the
schoolmaster, and three or four municipal councillors there. When
they saw me they looked at me mysteriously. ‘Hallo,’ I said to them,
‘are you holding a meeting?’ ‘No, we are just chatting,’ the mayor
said. And that was as far as we got.”
“And then?”
“That was all that concerned me. I went out, and sent my
chauffeur to have a drink in his turn. He is very thick with the
schoolmaster. They are both anarchists.”
“Anarchists!” repeated Mademoiselle de Songeon wrathfully.
“Certainly. Everybody is nowadays. It is the fashion. My chauffeur
came back. ‘I know what it is,’ he said. ‘They have had a wire from
the Minister about Commander Guibert’s death in Africa.’ ‘Are you
sure? I said. ‘Quite,’ he said. ‘He was killed by savages defending a
town called Timou—Timmimun?—that’s it. Then of course they had
to tell his people the news. They were very puzzled how to do it. At
last they sent a policeman.’”
“A policeman?” said M. Dulaurens, a stickler for legalities. “But
the mayor should have taken the fatal telegram in person.”
“The Guiberts are conservatives,” said M. de Lavernay. “These
republicans will not trouble themselves in such cases.”
“But the Guiberts are not interested in politics.”
“The grandfather was a councillor, of conservative views, and the
father was mayor of Cognin. That is quite enough.”
Madame Dulaurens was trying to catch a glimpse of her
daughter, who was separated from her by a candelabrum. Alice’s
orchids were drooping under the warm rain of her tears. In the
general confusion no one had seen her cry.
“How did he die?” questioned one of the ladies.
“At the head of his men—after the victory—with a bullet in his
forehead. I quote the telegram that my man read.”
“Did he receive the last sacrament?” asked Mademoiselle de
Songeon shaking her grey head.
The ever-correct M. Dulaurens summed up the affair. “He is a
great loss to his country.”
“Yes,” added his wife, in a noble impulse of eloquence. “We will
honor his glorious memory. We will get up a memorial service whose
magnificence shall astonish all Chambéry. It is the duty of our class
to show France how genuine merit must be recognised and
rewarded, at a time when mediocrity has taken possession of the
country, when envious equality drags it down to the lowest level.”
She had read this last sentence that very morning in a leading article
of the Gaulois.
Alice, surprised to hear all this, thought in her sorrow, “Why
then, did she refuse to let me give myself to him?” And Isabelle was
silent, thinking of Jean Berlier, whose fate was still unknown.
Madame Orlandi, forgetting Pistache for a minute, noticed how
abstracted her daughter was. She looked at her with loving
admiration and praised herself for the depth of her maternal
affection. In an outburst in which the thought of self did not swallow
up all pity she expressed her concern for Madame Guibert.
“Does his mother know?” she asked. And she stopped confusedly,
as though she felt herself guilty of a scandal. All eyes turned to
Clément Dulaurens. The young man answered in a free and easy
way, the bad taste of which was due rather to his youth than to any
lack of feeling.
“She must know all by now. As I was coming home I met her
driving back to Le Maupas in her old cart. She was passing under a
gas lamp; I recognised her quite well, I had to go slowly on account
of my damaged car.”
These words brought a dreadful feeling of actuality into the
company. It seemed as if the cold outside air had suddenly frozen
this comfortable dining-room.
Instinctively M. d’Amberlard, who was completely bored,
examined the windows to see if they were open. A shudder passed
through the assembly, all of whom were haunted by the same
vision: the picture of an old woman, already heavily tried by life’s
sorrows, going home through the snow, contented and
unsuspecting, to that home where news of death awaited her.
This inevitable catastrophe which was about to take place—which
was perhaps taking place at this very moment—came home to them
all even more than the glorious faraway death of Commander
Guibert on African soil.
A sob from Alice broke the oppressive silence. In a frightened
voice Isabelle murmured: “She knows by now.”
The mothers all broke down unreservedly, and Madame
Dulaurens promptly resolved to comfort and console the poor
woman in an early visit.
With all these solemn faces round him, Clément, who loved
gaiety at table, at last recognised his thoughtlessness and admitted
to himself, “Now I’ve done it!” His father, a slave to punctilio, without
paying any attention to the rest of the conversation, returned to the
discussion of an accessory point which he had not sufficiently
developed.
“The mayor of Cognin should have gone to them and broken the
news delicately, instead of just rudely sending a policeman,” he
stated.
Profiting by the interposition of this enlightening remark, M.
d’Amberlard thought it time to unburden himself of a protest which
he had been keeping back with difficulty for some time.
“All our regrets can make no change,” he said, “and we might as
well talk about something more cheerful. When I was in Paris I
always used to ask if a play ended happily before I took seats for it.
A party, like a comedy, should avoid all gloomy subjects.”
The Marquis de Lavernay quite agreed with this, and so death
was forgotten. Champagne filled the gilded glasses. Flowers spread
their perfume over the table which was laden with baskets of
preserved fruits. The jewels of the women sparkled in the lights. It
was a pleasure to recover the former luxurious and comfortable
atmosphere which the unhappy news had disturbed. Alice and
Isabelle were left alone in their distress.
The guests all drank the health of the young de Marthenay
couple, whose wedding anniversary was being celebrated, and a
move was made to the drawing-room. Alice, unable to bear it any
longer, rushed to her mother’s room. In the darkness she gave way
to her grief. She had been able to smile bravely during the toast they
had drunk in her honor, with its allusion to her “enviable happiness.”
Her happiness! She had looked in vain for it both in the present and
in the past, and how could she expect it in the future? With the clear
sight which the great shocks of destiny give us when we expect the
bitterness of life to crush us, she lived again despairingly through
the last years of her life. In a rapid succession of vivid pictures she
saw her sad days pass before her eyes.
She had not wished to marry Armand de Marthenay: it was so
constantly forced upon her that at last she had yielded. She came
down the aisle of the church in her wedding dress on the arm of the
husband she had not chosen. And since then? Could she look back
upon one hour of joy, that deep, pure joy that her childish soul had
imagined? The first days of her married life had been deadened by a
kind of merciful stupor, like a fog which hides the desolation of a
blasted plain. She forgot to feel she had a heart. Her husband still
retained the good humor of a man with something to do. He rode,
he fulfilled his military duties, he received his friends, he got up
parties. She allowed herself to be occupied by her new household
duties and by the many society calls. Instead of the husband of her
dreams, she had a companion proud of her fortune and her pretty
face, a man without much delicacy of feeling and with no great
intelligence, not even clever, but possessed of a good digestion and
an idiotic fatuity which enabled him to admire himself unceasingly all
his life. When her little girl was born she thought she had at last
found the oblivion for which at times she still sought.
From this tolerable time in her existence her thoughts travelled
on to the present, which was always with her. After a series of
unforeseen incidents, the regiment stationed at Chambéry had been
designated for a distant Eastern garrison. M. de Marthenay tried to
exchange, but it was impossible. He had either to go away and leave
Savoy, or to spoil his career. At the prospect of this departure
Madame Dulaurens had shown such violent grief that the young wife
was foolish enough to remind her husband of the solemn promise he
had made her when they became engaged. As a man of honor the
dragoon sacrificed himself. In twenty-four hours he had resigned. He
then gave way to his idle instincts, which a soldier’s life had kept in
check. And from that time he went steadily from bad to worse.
He began by becoming a constant habitué of the cafés. In
summer he was a member of the Club at Aix-le-Bains and of the Villa
des Fleurs. He began to play baccarat and won. While his wife was
slowly recovering after their child’s birth he was engaged in low
adventures, and reports were spread about concerning him by the
visitors to these watering-places. One day Alice learned of his base
unfaithfulness. She had kept her innocence after her marriage and
learnt the cruel fact of unfaithfulness before she well knew what
unfaithfulness meant. She rebelled against it, but instead of finding
the repentance which she expected and could have pardoned, she
received only this humiliating answer:
“You wanted me to resign the service and I resigned. You have
only yourself to blame if I try to make up for the loss of my career in
my own way. A man must have something to do. I sacrificed the
object of my life for your sake. What have you given up in return?”
Overwhelmed at his reproaches she retired into herself from that
time and wrapped herself in a mournful silence. She was not
resigned, but she followed the bent of her passive nature.
Losses at cards soured M. de Marthenay’s character. After the
season, idle and unsettled, he began to drink. His wife saw him try
to captivate her friend Isabelle before her very eyes, and was so
discouraged that she noted his failure with indifference. Thus she
was obliged to follow the only too rapid phases of his fall, of which
she was perhaps indirectly the cause. She could not shut her eyes to
it, yet felt the impossibility of saving him.
Thinking over all the details of her miserable past, Alice felt
astonished that she suffered so much. She had grown accustomed
to living amid such thoughts. Their dull monotony was now familiar
to her. But to-day a new sorrow had come to reinforce their
bitterness. Fresh melancholy pictures rose up in her memory as if to
remind her of the part she had played in her own destiny. She
remembered the day when Paule Guibert in the oakwood had stirred
her heart with an unknown desire. She saw once more the vivid light
of the setting sun through the trees and heaven descending upon
her transfigured soul, saw Marcel’s tall figure bending down to her
with his words of love. And then ... then she saw him lying dead in a
distant, sun-scorched land, a bullet through his head, pale and
terrible, his reproachful eyes fixed upon her. Oh, those eyes of
agony! How well she knew their look! They had gazed on her like
that when she had kept that obstinate silence—that wicked silence
which had ruined their happiness. Now in this dark room she vainly
hid her face so as not to see them. “Marcel, forgive me!” Distracted
and trembling, her love made supplication to him. “Don’t look at me
like that! I did not know. I was a child. That is my excuse. Yes, I was
a coward, I was afraid to strive for you, to fight for my love. I was
afraid to wait, to love, to suffer, to live. But God has punished me—
oh, how cruelly! Close your eyes and forgive me....”
Frightened at the sound of her own voice, she laid her hand on
her bosom. She was choking as on the day her child was born. At
last in her broken heart rose up the knowledge of life in all its
strength and dignity. Her soul had won its freedom, and she loved
Marcel as he had loved her, nobly and proudly. For her sake, to seek
forgetfulness, he had travelled over Africa and met glory and death.
Perhaps, as he fell, he had recalled her face. That she might have
been his last thought, though that thought might be but disdainful,
was now her most ardent prayer. Comparing her existence with the
one she had thrust from her she regretted not being a hero’s widow
instead of sharing the dull life of a man incapable of inspiring or
feeling love.
The door opened and Madame Dulaurens, anxious at her
daughter’s long absence, called in the darkness.
“Alice, are you there? Answer me.”
“Yes, what do you want?”
Madame Dulaurens was surprised at the unexpected hardness of
tone. She went back to the lighted corridor and returned with a
lamp. She found her daughter lying motionless and white, and
recognised traces of tears on her hastily dried cheeks. She sat down
beside her at once and tried to take her in her arms. But Alice
shrank from her embrace. All the mother in Madame Dulaurens was
aroused, and she winced with pain.
“Dearest,” she said, “you are suffering. Tell me your trouble. I am
your mother. What the matter to-night?”
Although her masterful nature was irritated by this rebellion, she
understood that now she must not put pressure on her child. She
covered her with kisses and overwhelmed her with kind words, but it
was all in vain.
“What is the matter with you to-night?” she repeated.
“Nothing,” said Alice in a firm voice, which her mother did not
recognise.
In the face of such profundity of sorrow Madame Dulaurens
hesitated, not knowing which to ask of the two questions that
burned her lips.
“Is it about your husband?” she asked at last.
She had guessed that Commander Guibert’s death had
something to do with these tears. But she did not dare to allude to
the secret which she had once treated so lightly.
“Yes,” whispered Alice, weakening again. And they both accepted
this lie, by which they were spared the reproach which no passing of
time could wipe away. Both were thinking of Marcel Guibert and they
talked about Armand de Marthenay.
Alice began to complain of her joyless life.
“We were wrong to ask him to resign.”
“Oh, my dearest,” said her mother, “how you hurt me! So you
would have agreed to desert me?”
“Was it better that my husband should desert me?”
“I should have died,” exclaimed Madame Dulaurens energetically,
“if you had had to go. You will never know how I love you and how I
want to make you happy!”
She spoke in entirely good faith. Deceived by her daughter’s
words, she had regained the serenity which the memory of death
had almost destroyed. Taught by her own experience, she was not in
the least surprised at the disillusionment of Armand’s neglected wife.
Was it not the lot of most women? And had she not, what so many
women lacked, the consolation of a warm motherly heart to fly to?
But Alice saw another mother, who at this hour was draining her
cup of sorrow, a poor old woman by whose side she longed to be,
where she would have been if she had listened to the dictates of her
heart. Like all weaklings who revolt, she went beyond the bounds
and did not stop short of injustice to her own mother.
They looked at each other. Madame Dulaurens understood at last
and felt a deep anguish. A gulf yawned between her and her
daughter. There had suddenly and relentlessly been revealed to both
of them the difference of their two natures, the one imperious and
under the sway of worldly prejudices, the other shrinking, docile,
and under no sway but that of the heart.
When they went back to the drawing-room a few minutes later,
calm, and leaning on each other’s arms, nobody could have
suspected the domestic drama which had just parted them asunder.
Isabelle was leading the conversation, talking loudly, making
jokes, and showing her white teeth. And from time to time she
looked at her surroundings, at her husband, at her admirers, M. de
Marthenay, M. de Lavernay, and particularly at Clément Dulaurens,
with eyes full of hatred and scorn. She detested them all, because
they could not tell her that Jean Berlier was still alive.
She saw that Alice had been crying and envied her the reality of
her sorrow. When the time for departure came, as her friend went to
the hall to help her on with her furs, she took advantage of their
being alone to throw her arms round her neck, and at last giving
way to the grief which she had choked back all the evening she
whispered a few wild words, which were understood at once.
“My poor Alice! What cowards we have been! Oh, why can we
not be allowed to mourn for our dead this evening? Our lives
belonged to them, and we denied it. Let us weep for them and for
our dull existence which might have been so bright!”
“Yes,” said Alice, “sorrow itself is more to be desired than the fate
that is ours.”
CHAPTER II
THE POLICEMAN’S MESSAGE
The discussion at the Café National at Cognin had been long and
animated. When the telegram from the Minister of War had been
brought to the town-hall, the municipal schoolmaster was on the
doorstep dismissing his pupils. He took the envelope from the hands of
the messenger, who was puffing out his cheeks to make his importance
felt.
“Official and post free! For the Mayor.”
“Give it to me,” said the schoolmaster cautiously. And he
immediately tore open the envelope, to show the messenger who was
the real head of the community. He read the words twice aloud, with
the Minister’s name at the bottom:
“The Mayor, Cognin, near Chambéry. Inform Guibert family
immediately decease of Commander Guibert while defending
Timmimun, Algiers. Shot through forehead after repulsing assault.”
He did not grasp it the first time he read it because, taking
everything to himself as most people do, he expected to discover
something of a personal nature in this government communication,
perhaps the exemption of his son, who had just drawn his lot and was
trying to escape military service. His disappointment prevailed over his
pity.
After having told his wife and his deputy about the news, he put on
his hat and ran over to the Café National, kept by Mayor Simon himself.
The latter was the successor to the post to Dr. Guibert, who had been
excluded from the Corporation a short time before his death, the very
year that he had gratuitously attended almost all the population when
attacked by typhoid fever. He was a country lawyer, an intemperate
boaster, who drank with all his customers and treated his bar as a
political committee-room. Ignorant and incapable, but genial-hearted,
he left all his duties to the schoolmaster, who was filled with false
teachings and who dazzled him by his socialistic and anti-militarist
theories which he culled from pernicious propagandist pamphlets. In
public he treated him condescendingly, but he obeyed him humbly at
the town-hall.
“Well, Master,” he cried as he saw him come in, “you have forgotten
your ferule!”
Proud of knowing this rare word, he used it on every occasion to
poke fun at his assistant.
“There is some news,” said Maillard mysteriously gliding up to the
counter. And the Mayor and his assistant gravely shook their heads in
concert. It was important that they should impress two honest
customers who sat at the end of the room, with their whips slung over
their shoulders, sipping absinthe before going out again into the bitter
cold of the clear winter evening.
After informing himself of the contents of the telegram, the Mayor
shook his red head.
“It must be done. These Guiberts are people of importance. I’ll put
on my frock-coat and go up to Le Maupas.”
He had been in the militia during the campaign of 1870 but his
regiment never reached the front. From that terrible year he had
learned the fear of war and a respect for courage. Flattered at having
received an official telegram, he also felt pride in the heroism of his
fellow-townsman abroad. He called his daughters to tell them the
secret that the schoolmaster’s wife had already told everybody.
While he was strutting about, the ferret-faced Maillard looked at
him and cackled.
“Let’s drink a glass of something,” said the Mayor. “Nothing can be
done well without a drink. I shall have time. One always arrives early
enough when carrying a message of death. But what do you find to
laugh at, you imp of ill omen?”
“I was wondering, Mr. Mayor, if we were republicans or not. The
Minister treats you like a dog, you the head of the community. ‘Inform
the Guibert family!’ Hurry up and do it. For whom is all this fuss? For a
lot of reactionaries, who defied you at the town-hall. They are not so
particular when there’s only a man of the people concerned.”
“He was a commander,” observed the hotelkeeper, who could not
forget his respect for rank.
“Isn’t a soldier’s blood worth as much as an officer’s?” retorted the
schoolmaster in a professorial tone. “I suppose that the equality which
is proclaimed on all our public buildings is a lie then? Everything is for
the gold lace? The others are just food for powder! It was well worth
while having the revolution only to re-establish caste a hundred years
later!”
It is imperfect education that is responsible for these bitter, envious,
aspiring beings, who find it hard to tolerate superiority of any kind.
Before his weak boasting Mayor, the little ill-natured man gave free
scope to his hatred of the authorities, a hatred which was increased by
the coming entry of his son into military service.
Simon’s face grew red. It was a sign that his brain was working.
“No,” he said, “I can’t get out of it. It is an order.”
“Only the Minister of the Interior can give you orders. You aren’t
amenable to military law.”
“But, good God! Madame Guibert will have to be told.”
“I don’t deny it. Only it isn’t necessary that you should put yourself
out about it. A Mayor is not at everybody’s beck and call. When a
Mayor bestirs himself it is the State which acts. You send a deputy, or
even a councillor, where enemies of the Republic are concerned. Devil
take it! One is either a republican or one isn’t, Mr. Mayor!”
“Mélanie, fetch us a pint!” cried the Mayor, torn between his natural
duty and his duty as a republican which was being instilled into him.
“And send the boy to look for Randon, Pitet, and Détraz.”
These three were the most influential councillors in the place. Pitet,
with his red, freckled face, which gained him the nickname of Pitet le
Rouge, was the first to arrive.
“I heard the news at the Fountain,” he declared as he came in. “I
can’t do anything. What do you want of me?”
He always spoke in a coarse, aggressive tone. He had been a
tenant at Le Maupas, and suddenly had to leave his farm. Nobody ever
understood why he was sent away from an estate where the tenants
and servants “took root,” as was currently said. In reality it was on
account of a theft, about which Dr. Guibert had never told anyone. Till
the doctor’s death Pitet had kept quiet. When he was quite certain he
could do so with impunity, he raised his head and played a vigorous
part in all the elections. He began by making money out of politics and
ended by getting dignity—which people were the less ready to refuse
him because he needed it so much. The whole community was afraid
of him, and everyone knows the power of fear over the peasants. He
turned the scale at once in favor of the schoolmaster Maillard. The
Mayor could not put himself out for the “aristocrats.”
“The Mayor must put himself at the service of everybody,” said
Simon, whose face shone like a burning log. “And, besides, a man’s
death isn’t a matter of politics.”
Pitet the Red would not hear of it.
“There you are! You must bow and scrape to the nobility and the
church! Then you will say it isn’t a matter of politics. Your daughters go
to Mass, Mr. Mayor. Take care, it won’t be forgotten.”
“But I don’t go to their church! Our deputy knows that,” cried
Simon.
“You don’t go to Cognin, but you go to Bissy.”
Bissy was the neighboring parish. While the Mayor was defending
himself, Randon and Détraz entered the room.
“Now, Mélanie, two pints of wine, one red and one white. And see
that it’s good stuff!”
The newcomers asked together: “He’s dead then?”
“The whole place knows about it!” cried Simon, raising his arms to
heaven. “We must hurry up or Madame Guibert will hear of it.”
Randon, old and broken down, had to thank the size of his estate
for the electors’ regard. He was an honest man, but as shy and
nervous as a hare. He gave a timid vote for the Mayor’s visit in person.
As to Détraz, the boorish and vulgar, he admitted at once that he took
no interest whatever in the question.
“Two against two; it’s a tie,” shouted Pitet the Red, exultantly,
throwing all his long-cherished rancor into the argument.
In a weak voice Randon muttered that the schoolmaster had no say
in the matter and that the Mayor’s voice was the important one. But
nobody listened to his prudent words. The Mayor was derided for the
lukewarmness of his democratic opinions and was at last reduced to
silence.
“Now then, you’re the oldest, you must go,” said Pitet to Randon.
“Oh, no, not I!” cried the latter, terrified. And he kept on repeating
“Not I!” as if the message of death threatened his own life. He was
thinking of his own peace of mind above all things.
“Well then, you, Détraz.”
“It isn’t my business.”
“Then I shall go,” said the Mayor, taking on an offensive manner.
Randon expressed a mild approval.
They both remembered how Dr. Guibert had attended and saved
their children. They strove hard to reconcile their opinions and their
prospects of re-election.
Furious at this reverse which followed his victory, and also excited
by the wine he had drunk, Pitet shouted: “Haven’t you been told that it
is too much honor? Can’t you hear? I tell you, don’t argue!”
“What?” exclaimed the Mayor, purple in the face.
The schoolmaster interrupted in honeyed tones:
“The logical thing is to give the message to the police. They carry
the Mayor’s orders in the town. A policeman can take the telegram and
explain that the Mayor has sent him in person.”
“That, of course, is the only right way,” said Pitet approvingly.
No sooner said than done. Faroux, the policeman, was sent for, and
the schoolmaster gave him the Mayor’s instructions with the telegram.
A few more glasses were drunk and the party broke up.
Old Randon, who was waiting for his cart, was left alone in Simon’s
bar. For a few minutes the two men found nothing more to say. They
were thinking of the effect of the message, which they had forgotten in
their discussion.
“We are cowards,” the Mayor admitted at last, and the councillor
heartily agreed.
As a matter of fact, they were no more cowardly than the average
man. They simply represented the attitude of honest men confronted
by bullies.
After a long silence—for a countryman moves in the world of ideas
at the pace of a plough-ox among the furrows—old Randon suggested:
“Do you think we ought to go up to Le Maupas together?”
“I was thinking about it,” rejoined the Mayor. And they encouraged
each other with all kinds of good reasons.
“Nobody will see us.”
“It is dark.”
“We will go up privately, as fellow citizens.”
“Just in ordinary clothes, unofficially.”
“The doctor saved my little one.”
“And my two daughters. Mélanie, my hat!”
They got up very firmly. They felt proud of their resolution. They
wrapped themselves up in their capes and went out, the old man going
in front like a youngster. They got as far as the end of the village, when
in the road they met the schoolmaster, who was walking along smoking
a cigar. Maillard grinned as he recognised them.
“What, going for a walk?” he asked.
“No,” said the stammering Mayor, “I am seeing Randon home.”
“But he lives on the Chaloux road!”
The councillor explained matters.
“I am going as far as the Favres grocery near here with an order. It
is for my wife.”
“I will go with you. I am just taking the air before supper.”
Neither the Mayor nor Randon dared to confess their plan. They
returned to Cognin very humbly on either side of the schoolmaster,
who held forth at length and announced the coming golden age of
brotherhood.

* * * * *
“I shall be back in the evening,” Madame Guibert had said to her
daughter, as she got into Trélaz’s carriage. She was going to Chambéry
on family business. With the help of Étienne and François, who had
been lucky in their enterprises at Tonkin, and with Marcel’s aid during
the Sahara Expedition they had been able to keep Le Maupas.
At sunset Paule came out for the first time to lean on the
balustrade. She listened for the sound of the approaching carriage
coming up the slope, but she listened in the quiet evening air in vain.
As the frost was very sharp she ran to get a shawl, wrapped herself in
it, and waited.
The snow-covered land grew rosy in the evening light. A kind of
virginal purity was over it. The vine-branches and the hedges were
covered with a fine lacework of hoarfrost, which shone in the dying
fires of day. The bare woods had no more secrets, and the branches
with their thousand twigs stood out in the clear air like blades of grass.
Paule, who clung to this little place with every fibre of her being,
loved the fairy-like winter effects. The cold made her shiver. As she
crossed the threshold, a raven flew croaking across the horizon. Its
wings made a black spot against the pale sky.
“Bird of misfortune!” murmured the girl carelessly, without reading
any ill omen in it. Was it not the time for ravens? They hover over the
bare fields, near the houses, trying to find a scanty sustenance.
She put two logs in the drawing-room grate, built up the fire
carefully, and placed a kettle on the logs. Then she went to find a
glass, a spoon, the sugar and the bottle of rum, which she arrayed on
a little table near the fireplace. “Mother will be cold when she gets
back,” she thought during these preparations. “It is freezing to-night
and she will be dreadfully cold in that open cart of Trélaz’s. A good fire
and a hot drink will do her good. Poor Mother!”
She sat down beside the lamp and tried to read a book she had
begun. But this occupation could not hold her attention. She looked at
the clock. It was past six.
Uneasily she took up the shawl which she had left on a chair, and
went back to the veranda. Night had fallen. The stars were trembling in
the sky, as if they were cold. Although the moon was still invisible, the
horizon was not dark. It seemed as if a faint light was rising from
below, as if the white earth illumined the sky. Down in the depths of
the valley Paule saw the lamps of Chambéry shining. She looked
searchingly at the wood with its bare oak-trees, through which the
carriage must come, she watched for the light of the moving lamps,
and listened for the slightest sounds that the breeze carried to her. For
a moment the clatter of a mill deceived her. A shrill scream which broke
the silence made her shudder,—it was so like a cry of despair. When
she had recovered from her fright, she recognised the siren of a
neighboring factory. For a long time she remained leaning on the
balustrade, listening and receptive of every impression.
Marie, the old servant who had lived with the family through good
and bad fortune, came to look for her and scolded her.
“Now isn’t it madness to stay outside in this cold? Will you come in,
Miss Paule? You won’t bring Madame home any quicker by taking cold
yourself!”
Paule obeyed, making no reply. But she went no further than the
kitchen, so that she might be ready to run out at once. Hearing the
gate open, she rushed out and found herself face to face with a
peasant from Vimines, who on account of his poverty was ironically
nicknamed Baron.
“Oh!” she exclaimed in her disappointment, as the poor creature
walked unceremoniously into the kitchen.
“Good evening, everybody! I’ve just looked in as I passed, to get
warm.”
From time to time he did a day’s work at Le Maupas. He was an idle
good-for-nothing, whom Dr. Guibert had helped. He often came to the
door and asked for work, though really only to get a drink.
“Good evening, Baron. You did not meet my mother on the road?”
“No, Miss, I saw nobody.”
Seated near the stove with his felt hat crushed in his hand, he
looked at the girl and the servant with a cunning eye. Paule left them
and began gazing out once more into the night. The moon was
illuminating the scene with her silvery beams, but her light revealed
only the emptiness of the road.
In the kitchen the rustic was saying to Marie: “So you haven’t heard
anything?”
“About what?” asked the servant, putting her pan on the fire.
“About the news, bless you!”
“What news, you old chatterbox? What are you keeping to
yourself?”
Distrustful, he had thought that they were hiding it from him. At
last he understood that at Le Maupas they were still ignorant of what
all Cognin already knew. As he passed in front of the hospitable house,
he had yielded to his curiosity to see the effect of the bad news. But he
would not tell anything, not he! Everybody has his own job to do. He
quickly drained his glass of red wine, refused a second, and got up to
leave.
“Well, Baron, what about your news? Are you going to take it on to
Vimines?”
“That’s just it,” said he, winking his wicked eye.
“So you won’t tell us about it?”
“Oh, you will know it soon enough.”
“It’s all cry and no wool with you, you old humbug!”
On the threshold the rustic turned round and delivered himself of a
platitude with a sarcastic smile: “Live and learn! Well, well, what will
the old woman do?”
His feet falling lightly in the snow he passed behind Paule, who was
still leaning on the veranda rail.
“Good evening, miss. Bear up! You never know who’s alive or who’s
dead.”
The girl started again, more at this voice heard unexpectedly behind
her back than at the words, whose meaning she did not understand.
She came back to the kitchen with a vague fear mingled with her
uneasiness.
“Make us some nice soup, Marie, and very hot. It is freezing hard.”
And cheered by the cosy hearth she added, “That Baron almost
frightened me.”
The servant snorted. “A good-for-nothing like that, with a long
tongue! I don’t want to see him round here any more. Your father was
a good Samaritan when he picked up that fish. And he has the evil eye.
We must take care. If the soup is burned, it will be all his fault. I don’t
know what story he had heard in the town, but he had a long face and
was watching us as a cat watches a rat.”
The girl went back to the drawing-room to stir the fire. Now she
was alone, she no longer felt her accustomed courage. Her heart was
beating loudly in her breast. She tried to comfort herself and did not
succeed.
“Trélaz’s horse goes so slowly. That business at the lawyer’s always
lasts so much longer than one thinks it will....”
She could no longer keep down her anxiety, which increased every
minute. Even prayer could not calm her. As she was on her knees, she
heard the drawing-room door open.
“Is Mamma there?” she cried as she rose from her knees. It was old
Marie who appeared at the door.
“No, Miss Paule. It is a man who wants to speak to the mistress.”
“Who is he?”
“He says he is a policeman and has been sent by the Mayor.”
“A policeman! What does he want with us?”
As her mind recalled all the bad omens of that evening, the girl
trembled while she gave the order for the man to be shown in. But she
controlled herself and received the Mayor’s messenger with the
greatest outward calm.
Faroux, the policeman, was one of those silent, stolid countrymen
who give themselves up entirely to their work without ever thinking
about it. But in the presence of Paule Guibert it was impossible for him
not to understand at last the importance of his mission. As he came
along the road he had not given a thought to it. So many people
approach thus absent-mindedly the most sacred and most serious
tasks.
Standing before him the girl said:
“My mother is not at home. But could I not take her place?”
He stood there silent and stupid, and the pause increased Paule’s
secret fear. He stammered at last:
“Mademoiselle Guibert, I have come to ... to ... tell you ...”
In his face, as the lamp shone on it, she read so much confusion
and trouble that she gave way to her darkest presentiments. With a
few quick words she aroused the poor, frightened man from his stupor.
“Speak, oh, do speak! Has there been an accident? My mother ...
on the road....” She could not finish the sentence.
“No,” said the man, “I did not meet the lady.” And he relapsed into
silence.
“Well, why did you come? If you have anything to say, say it. Do be
quick!”
Straight and proud, she spoke in the commanding voice which she
knew how to take upon occasion, like Marcel. The stiffness of her
bearing quite confused the policeman, who drew the telegram from his
pocket and with his big trembling hand held it out to the girl. He tried
to take it back again, but the blue paper was already in Paule’s hand.
Before she had even opened it, she thought of her brother. She
glanced over it, said “Ah,” crushed up the telegram, and turned deadly
pale. But with a supreme effort she remained standing and did not cry.
She could not show her weakness to this man, whom she thought
unfeeling, but she had to lean on the table. This movement and her
pallor were her only admissions of weakness.
A fearful silence enveloped them. At last she was able to say
without trembling: “It is all right. You may go. I thank you.”
As he was stepping out she remembered the laws of rural
hospitality and added:
“Tell Marie to give you something to drink, please.”
But the policeman rushed through the kitchen and fled as if he had
murdered someone.
“Oh, my God!” cried Paule when no one could hear her. She
dragged herself towards the fireplace, held on to it for a minute with
her two hands, tried to stand, but had to drop into an armchair. Her
body shook from head to foot. She held her hand before her dry,
staring eyes to keep away the horrible vision before them. She saw
there before her on the carpet her brother lying dead, his shattered
forehead with the lifeblood flowing from it. That grave face of his, so
melancholy and so proud, which had been the more so ever since
Alice’s refusal,—she saw it now, sightless, motionless and icy-cold, still
in death and beautiful! “Marcel, Marcel,” she called softly, and hid her
face in her hands. The tears refused to come to her relief. Her adored
brother, the pride of her life, was dead. Dead, she repeated ten, twenty
times before she could understand the horror of it. Dead, the hero of
Andriba, the conqueror of Rabah and the desert! At thirty-two, this life
of courage, of gallantry and self-sacrifice, had been cut off. Oh, how
little he had cared for life. For a long time he had despised it. Had not
the meeting with a shy little girl taken away his joy in it? And Paule
distractedly racked her memory for the pictures in which she had read
the signs of coming fate. There was that hesitating smile which she
had surprised on his lips the first night that he confessed his secret to
her. There was that movement of indifference as he listened to the
mournful warnings of the owls after his last interview with Alice. And
there was again that strange, quiet, almost disinterested discussion of
his future, as they sat there on the tree-trunk at the edge of the
Montcharvin wood, on the day of his departure from France. For years,
since that evening at La Chênaie, he had carried death in his eyes. He
had never again mentioned Alice’s name, never spoken of his love. But
he had lived on without any faith in life.... And in that dear face that
her ardent love called up in her memory, Paule saw a deep serenity,
unchangeable, eternal. Then she gave a great cry and knelt down,
weeping.
“Yes,” she thought, “you are at peace at last. Our love was not
sufficient for you. We loved you too much, Marcel. You do not know
how I loved you. I cannot speak: but my heart was full of you. Why
was I not chosen in your place? Of what use am I?”
A new fear, which she would not admit to herself in this terrible
hour, completed the distraction of her mind. Marcel was not alone at
Timmimun....
All at once she started up.
“And Mother! Mother is coming home!” She had forgotten her. And,
thanking God who had allowed her to break to her mother this
supreme sorrow, she mourned no longer for him who was sleeping his
last sleep, dead on the day of victory, in a conquered land; but instead
for her who was quietly coming home along the dark roads, travelling
all unsuspicious towards the precipice. Might not this last blow crush
the frail old life, overwhelmed already with its many trials?
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like