SlideShare ist ein Scribd-Unternehmen logo
Visit https://ebookultra.com to download the full version and
explore more ebooks
Programming Logic and Design Comprehensive 6th
Edition Joyce Farrell
_____ Click the link below to download _____
https://ebookultra.com/download/programming-logic-and-
design-comprehensive-6th-edition-joyce-farrell/
Explore and download more ebooks at ebookultra.com
Here are some suggested products you might be interested in.
Click the link to download
Java Programming 7th Edition Joyce Farrell
https://ebookultra.com/download/java-programming-7th-edition-joyce-
farrell/
Java Programming 8th Edition Joyce Farrell
https://ebookultra.com/download/java-programming-8th-edition-joyce-
farrell/
Java Programs to Accompany Programming Logic and Design
7th Edition Jo Ann Smith
https://ebookultra.com/download/java-programs-to-accompany-
programming-logic-and-design-7th-edition-jo-ann-smith/
Microsoft Visual Basic Programs to Accompany Programming
Logic and Design 3rd Edition Jo Ann Smith
https://ebookultra.com/download/microsoft-visual-basic-programs-to-
accompany-programming-logic-and-design-3rd-edition-jo-ann-smith/
Computer programming for teens 1st Edition Mary E. Farrell
https://ebookultra.com/download/computer-programming-for-teens-1st-
edition-mary-e-farrell/
Programming and Problem Solving with C Comprehensive
Comprehensive Edition Nell B. Dale
https://ebookultra.com/download/programming-and-problem-solving-with-
c-comprehensive-comprehensive-edition-nell-b-dale/
Comprehensive Gynecology 6th Edition Gretchen M Lentz
https://ebookultra.com/download/comprehensive-gynecology-6th-edition-
gretchen-m-lentz/
The Haskell Road to Logic Maths and Programming 1st
Edition Kees Doets
https://ebookultra.com/download/the-haskell-road-to-logic-maths-and-
programming-1st-edition-kees-doets/
Logic and Computer Design Fundamentals Third Edition M.
Morris Mano
https://ebookultra.com/download/logic-and-computer-design-
fundamentals-third-edition-m-morris-mano/
Programming Logic and Design Comprehensive 6th Edition Joyce Farrell
Programming Logic and Design Comprehensive 6th
Edition Joyce Farrell Digital Instant Download
Author(s): Joyce Farrell
ISBN(s): 0538744766
Edition: 6
File Details: PDF, 18.81 MB
Year: 2010
Language: english
Programming Logic and Design Comprehensive 6th Edition Joyce Farrell
PROGRAMMING LOGIC
AND DESIGN
COMPREHENSIVE
This page intentionally left blank
S I X T H E D I T I O N
PR OGRAMMING LOGIC
AND DESIGN
COMPREHENSIVE
JO YCE FARRELL
Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may
be suppressed. Editorial review has deemed that any suppressed content does not materially affect the overall
learning experience. The publisher reserves the right to remove content from this title at any time if subsequent rights
restrictions require it. For valuable information on pricing, previous editions, changes to current editions, and
alternate formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.
© 2011 Course Technology, Cengage Learning
ALL RIGHTS RESERVED. No part of this work covered by the copyright
herein may be reproduced, transmitted, stored or used in any form or by
any means—graphic, electronic, or mechanical, including but not limited
to photocopying, recording, scanning, digitizing, taping, Web distribution,
information networks, or information storage and retrieval systems, except
as permitted under Section 107 or 108 of the 1976 United States Copyright
Act—without the prior written permission of the publisher.
Library of Congress Control Number: 2009938501
ISBN-13: 978-0-5387-4476-8
ISBN-10: 0-538-74476-6
Course Technology
20 Channel Center Street
Boston, MA 02210
USA
Some of the product names and company names used in this book have
been used for identification purposes only and may be trademarks or
registered trademarks of their respective manufacturers and sellers.
Course Technology, a part of Cengage Learning, reserves the right to revise
this publication and make changes from time to time in its content without
notice.
Cengage Learning is a leading provider of customized learning solutions with
office locations around the globe, including Singapore, the United Kingdom,
Australia, Mexico, Brazil, and Japan. Locate your local office at:
www.cengage.com/global
Cengage Learning products are represented in Canada by
Nelson Education, Ltd.
To learn more about Course Technology, visit
www.cengage.com/coursetechnology
Purchase any of our products at your local college store or at our preferred
online store www.ichapters.com
Programming Logic and Design,
Comprehensive, Sixth Edition
Joyce Farrell
Executive Editor: Marie Lee
Acquisitions Editor: Amy Jollymore
Managing Editor: Tricia Coia
Developmental Editor: Dan Seiter
Content Project Manager: Jennifer Feltri
Editorial Assistant: Zina Kresin
Marketing Manager: Bryant Chrzan
Art Director: Marissa Falco
Text Designer: Shawn Girsberger
Cover Designer: Cabbage Design Company
Cover Image: iStockphoto
Print Buyer: Julio Esperas
Copy Editor: Michael Beckett
Proofreader: Vicki Zimmer
Indexer: Alexandra Nickerson
Compositor: Integra
Printed in Canada
1 2 3 4 5 6 7 14 13 12 11 10
For product information and technology assistance, contact us at
Cengage Learning Customer & Sales Support, 1-800-354-9706
For permission to use material from this text or product,
submit all requests online at cengage.com/permissions
Further permissions questions can be emailed to
permissionrequest@cengage.com
Brief Contents
Preface . . . . . . . . . . . . . . . . . xvi
CHAPTER 1 An Overview of Computers and Programming . . 1
CHAPTER 2 Working with Data, Creating Modules,
and Designing High-Quality Programs . . . . 41
CHAPTER 3 Understanding Structure . . . . . . . . . . 92
CHAPTER 4 Making Decisions . . . . . . . . . . . . 133
CHAPTER 5 Looping . . . . . . . . . . . . . . . . 184
CHAPTER 6 Arrays . . . . . . . . . . . . . . . . . 228
CHAPTER 7 File Handling and Applications . . . . . . 276
CHAPTER 8 Advanced Array Concepts, Indexed Files,
and Linked Lists. . . . . . . . . . . . . 325
CHAPTER 9 Advanced Modularization Techniques . . . . 370
CHAPTER 10 Object-Oriented Programming . . . . . . . 426
CHAPTER 11 More Object-Oriented Programming
Concepts . . . . . . . . . . . . . . . . 469
CHAPTER 12 Event-Driven GUI Programming,
Multithreading, and Animation . . . . . . . 515
CHAPTER 13 System Modeling with the UML . . . . . . 550
CHAPTER 14 Using Relational Databases . . . . . . . . 585
APPENDIX A Understanding Numbering Systems
and Computer Codes. . . . . . . . . . . 637
APPENDIX B Flowchart Symbols . . . . . . . . . . . 646
v
APPENDIX C Structures . . . . . . . . . . . . . . . 647
APPENDIX D Solving Difficult Structuring Problems . . . 649
APPENDIX E Creating Print Charts . . . . . . . . . . 658
APPENDIX F Two Variations on the Basic Structures—
case and do-while . . . . . . . . . . 660
Glossary . . . . . . . . . . . . . . . . 666
Index . . . . . . . . . . . . . . . . . 681
B R I E F C O N T E N T S
vi
Contents
Preface . . . . . . . . . . . . . . . . . xvi
CHAPTER 1 An Overview of Computers
and Programming . . . . . . . . . . . . . 1
Understanding Computer Systems. . . . . . . . . . . . . . 2
Understanding Simple Program Logic . . . . . . . . . . . . 5
Understanding the Program Development Cycle . . . . . . . 8
Understanding the Problem . . . . . . . . . . . . . . . . 8
Planning the Logic . . . . . . . . . . . . . . . . . . . .10
Coding the Program . . . . . . . . . . . . . . . . . . .10
Using Software to Translate the Program
into Machine Language . . . . . . . . . . . . . . . . .11
Testing the Program . . . . . . . . . . . . . . . . . . .12
Putting the Program into Production . . . . . . . . . . . .14
Maintaining the Program . . . . . . . . . . . . . . . . .14
Using Pseudocode Statements and Flowchart Symbols . . . .15
Writing Pseudocode . . . . . . . . . . . . . . . . . . .15
Drawing Flowcharts . . . . . . . . . . . . . . . . . . .17
Repeating Instructions . . . . . . . . . . . . . . . . . .18
Using a Sentinel Value to End a Program . . . . . . . . . . .20
Understanding Programming and User Environments . . . . .23
Understanding Programming Environments . . . . . . . . .23
Understanding User Environments . . . . . . . . . . . . .25
Understanding the Evolution of Programming Models . . . . .27
Chapter Summary . . . . . . . . . . . . . . . . . . . . .28
Key Terms . . . . . . . . . . . . . . . . . . . . . . . .29
Review Questions . . . . . . . . . . . . . . . . . . . . .32
Exercises . . . . . . . . . . . . . . . . . . . . . . . . .37
CHAPTER 2 Working with Data, Creating Modules,
and Designing High-Quality Programs . . . . . . 41
Declaring and Using Variables and Constants. . . . . . . . .42
vii
Working with Variables . . . . . . . . . . . . . . . . . .42
Naming Variables . . . . . . . . . . . . . . . . . . . .44
Understanding Unnamed, Literal Constants
and their Data Types . . . . . . . . . . . . . . . . . .45
Understanding the Data Types of Variables . . . . . . . . .46
Declaring Named Constants. . . . . . . . . . . . . . . .47
Assigning Values to Variables . . . . . . . . . . . . . . . .48
Performing Arithmetic Operations . . . . . . . . . . . . .49
Understanding the Advantages of Modularization . . . . . . . 52
Modularization Provides Abstraction . . . . . . . . . . . .53
Modularization Allows Multiple Programmers
to Work on a Problem. . . . . . . . . . . . . . . . . .54
Modularization Allows You to Reuse Your Work . . . . . . .54
Modularizing a Program . . . . . . . . . . . . . . . . . .55
Declaring Variables and Constants
within Modules . . . . . . . . . . . . . . . . . . . . .59
Understanding the Most Common Configuration
for Mainline Logic . . . . . . . . . . . . . . . . . . . .61
Creating Hierarchy Charts . . . . . . . . . . . . . . . . .66
Features of Good Program Design. . . . . . . . . . . . . .68
Using Program Comments . . . . . . . . . . . . . . . .69
Choosing Identifiers . . . . . . . . . . . . . . . . . . .71
Designing Clear Statements. . . . . . . . . . . . . . . .72
Writing Clear Prompts and Echoing Input . . . . . . . . . .74
Maintaining Good Programming Habits . . . . . . . . . . .76
Chapter Summary . . . . . . . . . . . . . . . . . . . . .77
Key Terms . . . . . . . . . . . . . . . . . . . . . . . .78
Review Questions . . . . . . . . . . . . . . . . . . . . .82
Exercises . . . . . . . . . . . . . . . . . . . . . . . . .86
CHAPTER 3 Understanding Structure . . . . . . . . . . 92
Understanding Unstructured Spaghetti Code . . . . . . . . .93
Understanding the Three Basic Structures . . . . . . . . . .95
Using a Priming Input to Structure a Program . . . . . . . 103
Understanding the Reasons for Structure . . . . . . . . . 110
Recognizing Structure . . . . . . . . . . . . . . . . . . 111
Structuring and Modularizing Unstructured Logic . . . . . . 115
Chapter Summary . . . . . . . . . . . . . . . . . . . . 121
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 122
Review Questions . . . . . . . . . . . . . . . . . . . . 123
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 127
C O N T E N T S
viii
CHAPTER 4 Making Decisions . . . . . . . . . . . . 133
Evaluating Boolean Expressions to Make Comparisons . . . 134
Using Relational Comparison Operators . . . . . . . . . . 137
Avoiding a Common Error with Relational Operators . . . . 141
Understanding AND Logic . . . . . . . . . . . . . . . . 141
Nesting AND Decisions for Efficiency . . . . . . . . . . 144
Using the AND Operator . . . . . . . . . . . . . . . . 146
Avoiding Common Errors in an AND Selection. . . . . . . 148
Understanding OR Logic . . . . . . . . . . . . . . . . . 150
Writing OR Decisions for Efficiency . . . . . . . . . . . 152
Using the OR Operator . . . . . . . . . . . . . . . . . 153
Avoiding Common Errors in an OR Selection . . . . . . . 155
Making Selections within Ranges . . . . . . . . . . . . . 159
Avoiding Common Errors When Using Range Checks . . . 162
Understanding Precedence When Combining
AND and OR Operators . . . . . . . . . . . . . . . . . 166
Chapter Summary . . . . . . . . . . . . . . . . . . . . 169
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 170
Review Questions . . . . . . . . . . . . . . . . . . . . 171
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 177
CHAPTER 5 Looping . . . . . . . . . . . . . . . . 184
Understanding the Advantages of Looping . . . . . . . . . 185
Using a Loop Control Variable. . . . . . . . . . . . . . . 186
Using a Definite Loop with a Counter . . . . . . . . . . 187
Using an Indefinite Loop with a Sentinel Value . . . . . . 188
Understanding the Loop in a Program’s Mainline Logic. . . 190
Nested Loops . . . . . . . . . . . . . . . . . . . . . . 192
Avoiding Common Loop Mistakes . . . . . . . . . . . . . 196
Mistake: Neglecting to Initialize the
Loop Control Variable . . . . . . . . . . . . . . . . . 197
Mistake: Neglecting to Alter the
Loop Control Variable . . . . . . . . . . . . . . . . . 198
Mistake: Using the Wrong Comparison with the
Loop Control Variable . . . . . . . . . . . . . . . . . 200
Mistake: Including Statements Inside the Loop
that Belong Outside the Loop . . . . . . . . . . . . . 201
Using a for Loop . . . . . . . . . . . . . . . . . . . . 206
Common Loop Applications . . . . . . . . . . . . . . . . 208
Using a Loop to Accumulate Totals . . . . . . . . . . . 208
Using a Loop to Validate Data . . . . . . . . . . . . . . 211
Limiting a Reprompting Loop . . . . . . . . . . . . . . 213
ix
C O N T E N T S
Validating a Data Type . . . . . . . . . . . . . . . . . 215
Validating Reasonableness and Consistency of Data . . . . 216
Chapter Summary . . . . . . . . . . . . . . . . . . . . 217
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 218
Review Questions . . . . . . . . . . . . . . . . . . . . 219
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 223
CHAPTER 6 Arrays . . . . . . . . . . . . . . . . . 228
Understanding Arrays and How They Occupy
Computer Memory . . . . . . . . . . . . . . . . . . . 229
How Arrays Occupy Computer Memory. . . . . . . . . . 229
Manipulating an Array to Replace Nested Decisions . . . . . 232
Using Constants with Arrays . . . . . . . . . . . . . . . 240
Using a Constant as the Size of an Array . . . . . . . . . 240
Using Constants as Array Element Values . . . . . . . . 241
Using a Constant as an Array Subscript . . . . . . . . . 241
Searching an Array . . . . . . . . . . . . . . . . . . . 242
Using Parallel Arrays . . . . . . . . . . . . . . . . . . . 246
Improving Search Efficiency. . . . . . . . . . . . . . . 251
Searching an Array for a Range Match . . . . . . . . . . . 254
Remaining within Array Bounds . . . . . . . . . . . . . . 258
Using a for Loop to Process Arrays . . . . . . . . . . . 261
Chapter Summary . . . . . . . . . . . . . . . . . . . . 262
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 263
Review Questions . . . . . . . . . . . . . . . . . . . . 264
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 268
CHAPTER 7 File Handling and Applications . . . . . . 276
Understanding Computer Files . . . . . . . . . . . . . . 277
Organizing Files . . . . . . . . . . . . . . . . . . . . 278
Understanding the Data Hierarchy . . . . . . . . . . . . . 279
Performing File Operations . . . . . . . . . . . . . . . . 280
Declaring a File . . . . . . . . . . . . . . . . . . . . 280
Opening a File . . . . . . . . . . . . . . . . . . . . . 281
Reading Data From a File . . . . . . . . . . . . . . . . 281
Writing Data to a File . . . . . . . . . . . . . . . . . . 283
Closing a File . . . . . . . . . . . . . . . . . . . . . 283
A Program that Performs File Operations. . . . . . . . . 283
Understanding Sequential Files and Control Break Logic . . . 286
Understanding Control Break Logic . . . . . . . . . . . 287
Merging Sequential Files . . . . . . . . . . . . . . . . . 293
Master and Transaction File Processing . . . . . . . . . . 303
x
C O N T E N T S
Random Access Files . . . . . . . . . . . . . . . . . . 311
Chapter Summary . . . . . . . . . . . . . . . . . . . . 313
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 314
Review Questions . . . . . . . . . . . . . . . . . . . . 316
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 320
CHAPTER 8 Advanced Array Concepts, Indexed Files,
and Linked Lists. . . . . . . . . . . . . 325
Understanding the Need for Sorting Records . . . . . . . . 326
Understanding How to Swap Two Values . . . . . . . . . . 327
Using a Bubble Sort . . . . . . . . . . . . . . . . . . . 329
Sorting a List of Variable Size. . . . . . . . . . . . . . 337
Refining the Bubble Sort to Reduce Unnecessary
Comparisons. . . . . . . . . . . . . . . . . . . . . 341
Refining the Bubble Sort to Eliminate Unnecessary
Passes . . . . . . . . . . . . . . . . . . . . . . . 343
Other Sorts . . . . . . . . . . . . . . . . . . . . . . 345
Using Multidimensional Arrays . . . . . . . . . . . . . . 345
Using Indexed Files and Linked Lists. . . . . . . . . . . . 352
Using Indexed Files . . . . . . . . . . . . . . . . . . 352
Using Linked Lists . . . . . . . . . . . . . . . . . . . 354
Chapter Summary . . . . . . . . . . . . . . . . . . . . 357
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 358
Review Questions . . . . . . . . . . . . . . . . . . . . 359
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 364
CHAPTER 9 Advanced Modularization Techniques . . . . 370
Using Methods with No Parameters . . . . . . . . . . . . 371
Creating Methods that Require a Single Parameter . . . . . 374
Creating Methods that Require Multiple Parameters . . . . . 379
Creating Methods that Return a Value . . . . . . . . . . . 381
Using an IPO Chart . . . . . . . . . . . . . . . . . . . 387
Passing an Array to a Method . . . . . . . . . . . . . . . 388
Overloading Methods. . . . . . . . . . . . . . . . . . . 395
Avoiding Ambiguous Methods . . . . . . . . . . . . . . . 398
Using Predefined Methods . . . . . . . . . . . . . . . . 401
Method Design Issues: Implementation Hiding, Cohesion,
and Coupling . . . . . . . . . . . . . . . . . . . . . 403
Understanding Implementation Hiding . . . . . . . . . . 403
Increasing Cohesion . . . . . . . . . . . . . . . . . . 404
Reducing Coupling . . . . . . . . . . . . . . . . . . . 405
Understanding Recursion . . . . . . . . . . . . . . . . . 407
xi
C O N T E N T S
Chapter Summary . . . . . . . . . . . . . . . . . . . . 411
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 413
Review Questions . . . . . . . . . . . . . . . . . . . . 415
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 419
CHAPTER 10 Object-Oriented Programming . . . . . . . 426
Principles of Object-Oriented Programming. . . . . . . . . 427
Classes and Objects . . . . . . . . . . . . . . . . . . 427
Polymorphism . . . . . . . . . . . . . . . . . . . . . 430
Inheritance . . . . . . . . . . . . . . . . . . . . . . 431
Encapsulation . . . . . . . . . . . . . . . . . . . . . 432
Defining Classes and Creating Class Diagrams . . . . . . . 433
Creating Class Diagrams . . . . . . . . . . . . . . . . 435
The Set Methods. . . . . . . . . . . . . . . . . . . . 438
The Get Methods. . . . . . . . . . . . . . . . . . . . 440
Work Methods . . . . . . . . . . . . . . . . . . . . . 440
Understanding Public and Private Access . . . . . . . . . 442
Organizing Classes . . . . . . . . . . . . . . . . . . . 446
Understanding Instance Methods . . . . . . . . . . . . . 447
Understanding Static Methods . . . . . . . . . . . . . . 453
Using Objects . . . . . . . . . . . . . . . . . . . . . . 455
Chapter Summary . . . . . . . . . . . . . . . . . . . . 459
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 460
Review Questions . . . . . . . . . . . . . . . . . . . . 462
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 466
CHAPTER 11 More Object-Oriented Programming
Concepts . . . . . . . . . . . . . . . . 469
An Introduction to Constructors . . . . . . . . . . . . . . 470
Constructors with Parameters. . . . . . . . . . . . . . 473
Overloading Class Methods and Constructors. . . . . . . 473
Understanding Destructors . . . . . . . . . . . . . . . . 476
Understanding Composition. . . . . . . . . . . . . . . . 478
Understanding Inheritance . . . . . . . . . . . . . . . . 479
Understanding Inheritance Terminology . . . . . . . . . 481
Accessing Private Members of a Parent Class . . . . . . 484
Using Inheritance to Achieve Good Software Design . . . . 490
One Example of Using Predefined Classes:
Creating GUI Objects . . . . . . . . . . . . . . . . . . 491
Understanding Exception Handling. . . . . . . . . . . . . 493
Drawbacks to Traditional Error-Handling Techniques . . . . 493
The Object-Oriented Exception Handling Model . . . . . . 495
xii
C O N T E N T S
Using Built-in Exceptions and Creating Your Own
Exceptions. . . . . . . . . . . . . . . . . . . . . . 498
Reviewing the Advantages of Object-Oriented
Programming . . . . . . . . . . . . . . . . . . . . . 499
Chapter Summary . . . . . . . . . . . . . . . . . . . . 500
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 502
Review Questions . . . . . . . . . . . . . . . . . . . . 503
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 508
CHAPTER 12 Event-Driven GUI Programming,
Multithreading, and Animation . . . . . . . 515
Understanding Event-Driven Programming . . . . . . . . . 516
User-Initiated Actions and GUI Components. . . . . . . . . 519
Designing Graphical User Interfaces . . . . . . . . . . . . 523
The Interface Should Be Natural and Predictable . . . . . 523
The Interface Should Be Attractive, Easy to Read, and
Nondistracting . . . . . . . . . . . . . . . . . . . . 524
To Some Extent, It’s Helpful If the User Can
Customize Your Applications. . . . . . . . . . . . . . 524
The Program Should Be Forgiving . . . . . . . . . . . . 525
The GUI Is Only a Means to an End . . . . . . . . . . . 525
The Steps to Developing an Event-Driven Application . . . . 526
Creating Storyboards. . . . . . . . . . . . . . . . . . 527
Defining the Storyboard’s Objects in
an Object Dictionary . . . . . . . . . . . . . . . . . 527
Defining Connections Between the User Screens . . . . . 528
Planning the Logic . . . . . . . . . . . . . . . . . . . 529
Understanding Multithreading . . . . . . . . . . . . . . . 535
Creating Animation. . . . . . . . . . . . . . . . . . . . 537
Chapter Summary . . . . . . . . . . . . . . . . . . . . 540
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 541
Review Questions . . . . . . . . . . . . . . . . . . . . 542
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 546
CHAPTER 13 System Modeling with the UML . . . . . . 550
Understanding the Need for System Modeling . . . . . . . 551
What is the UML? . . . . . . . . . . . . . . . . . . . . 552
Using Use Case Diagrams . . . . . . . . . . . . . . . . 554
Using Class and Object Diagrams . . . . . . . . . . . . . 560
Using Sequence and Communication Diagrams . . . . . . . 564
Using State Machine Diagrams . . . . . . . . . . . . . . 566
Using Activity Diagrams . . . . . . . . . . . . . . . . . 567
xiii
C O N T E N T S
Using Component, Deployment, and Profile Diagrams . . . . 570
Diagramming Exception Handling . . . . . . . . . . . . . 572
Deciding When to Use the UML and Which
UML Diagrams to Use . . . . . . . . . . . . . . . . . 573
Chapter Summary . . . . . . . . . . . . . . . . . . . . 575
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 576
Review Questions . . . . . . . . . . . . . . . . . . . . 578
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 582
CHAPTER 14 Using Relational Databases . . . . . . . . 585
Understanding Relational Database Fundamentals. . . . . . 586
Creating Databases and Table Descriptions . . . . . . . . 588
Identifying Primary Keys . . . . . . . . . . . . . . . . . 591
Understanding Database Structure Notation . . . . . . . . 594
Adding, Deleting, Updating, and Sorting Records
within Tables. . . . . . . . . . . . . . . . . . . . . . 595
Sorting the Records in a Table . . . . . . . . . . . . . 596
Creating Queries. . . . . . . . . . . . . . . . . . . . . 596
Understanding Relationships Between Tables . . . . . . . . 600
Understanding One-to-Many Relationships . . . . . . . . 600
Understanding Many-to-Many Relationships . . . . . . . . 601
Understanding One-to-One Relationships . . . . . . . . . 606
Recognizing Poor Table Design . . . . . . . . . . . . . . 607
Understanding Anomalies, Normal Forms,
and Normalization . . . . . . . . . . . . . . . . . . . 609
First Normal Form . . . . . . . . . . . . . . . . . . . 610
Second Normal Form . . . . . . . . . . . . . . . . . . 612
Third Normal Form . . . . . . . . . . . . . . . . . . . 615
Database Performance and Security Issues . . . . . . . . 618
Providing Data Integrity. . . . . . . . . . . . . . . . . 618
Recovering Lost Data . . . . . . . . . . . . . . . . . 619
Avoiding Concurrent Update Problems . . . . . . . . . . 619
Providing Authentication and Permissions . . . . . . . . 620
Providing Encryption . . . . . . . . . . . . . . . . . . 620
Chapter Summary . . . . . . . . . . . . . . . . . . . . 621
Key Terms . . . . . . . . . . . . . . . . . . . . . . . 622
Review Questions . . . . . . . . . . . . . . . . . . . . 625
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 630
xiv
C O N T E N T S
APPENDIX A Understanding Numbering Systems
and Computer Codes. . . . . . . . . . . 637
APPENDIX B Flowchart Symbols . . . . . . . . . . . 646
APPENDIX C Structures . . . . . . . . . . . . . . . 647
APPENDIX D Solving Difficult Structuring Problems . . . 649
APPENDIX E Creating Print Charts . . . . . . . . . . 658
APPENDIX F Two Variations on the Basic Structures—
case and do-while . . . . . . . . . . 660
Glossary . . . . . . . . . . . . . . . . 666
Index . . . . . . . . . . . . . . . . . 681
xv
C O N T E N T S
Preface
Programming Logic and Design, Comprehensive, Sixth Edition
provides the beginning programmer with a guide to developing
structured program logic. This textbook assumes no programming
language experience. The writing is nontechnical and emphasizes
good programming practices. The examples are business examples;
they do not assume mathematical background beyond high school
business math. Additionally, the examples illustrate one or two major
points; they do not contain so many features that students become
lost following irrelevant and extraneous details.
The examples in Programming Logic and Design have been created to
provide students with a sound background in logic, no matter what
programming languages they eventually use to write programs. This
book can be used in a stand-alone logic course that students take as a
prerequisite to a programming course, or as a companion book to an
introductory programming text using any programming language.
Organization and Coverage
Programming Logic and Design, Comprehensive, Sixth Edition
introduces students to programming concepts and enforces good
style and logical thinking. General programming concepts are intro-
duced in Chapter 1. Chapter 2 discusses using data and introduces
two important concepts: modularization and creating high-quality
programs. It is important to emphasize these topics early so that
students start thinking in a modular way and concentrate on making
their programs efficient, robust, easy to read, and easy to maintain.
Chapter 3 covers the key concepts of structure, including what
structure is, how to recognize it, and most importantly, the advan-
tages to writing structured programs. This early overview gives
students a solid foundation for thinking in a structured way before
they have to manage the details of the structures.
Chapters 4, 5, and 6 explore the intricacies of decision making, looping,
and array manipulation. Chapter 7 provides details of file handling so
students can create programs that handle a significant amount of data.
xvi
In Chapters 8 and 9, students learn more advanced techniques in
array manipulation and modularization. Chapters 10 and 11 provide
a thorough, yet accessible, introduction to concepts and terminology
used in object-oriented programming. Students learn about classes,
objects, instance and static class members, constructors, destructors,
inheritance, and the advantages provided by object-oriented thinking.
Chapter 12 explores additional object-oriented programming issues:
event-driven GUI programming, multithreading, and animation.
Chapter 13 discusses system design issues and details the features of
the Unified Modeling Language. Chapter 14 is a thorough introduc-
tion to the most important database concepts business programmers
should understand.
The first three appendices give students summaries of numbering
systems, flowchart symbols, and structures. Additional appendices
allow students to gain extra experience with structuring large
unstructured programs, creating print charts, and understanding
posttest loops and case structures.
Programming Logic and Design combines text explanation with
flowcharts and pseudocode examples to provide students with
alternative means of expressing structured logic. Numerous detailed,
full-program exercises at the end of each chapter illustrate the
concepts explained within the chapter, and reinforce understanding
and retention of the material presented.
Programming Logic and Design distinguishes itself from other
programming logic books in the following ways:
It is written and designed to be non-language specific. The logic
•
used in this book can be applied to any programming language.
The examples are everyday business examples; no special knowledge
•
of mathematics, accounting, or other disciplines is assumed.
The concept of structure is covered earlier than in many other
•
texts. Students are exposed to structure naturally, so they will
automatically create properly designed programs.
Text explanation is interspersed with flowcharts and pseudocode
•
so students can become comfortable with both logic development
tools and understand their interrelationship. Screen shots of
running programs also are included, providing students with a
clear and concrete image of the programs’ execution.
Complex programs are built through the use of complete business
•
examples. Students see how an application is constructed from
start to finish instead of studying only segments of programs.
xvii
P R E FA C E
Features
This edition of the text includes many features to help students
become better programmers and understand the big picture in
program development. Many new features have been added, and the
popular features from the first five editions are still included.
Features maintained from previous editions include:
OBJECTIVES Each chapter begins with a list of objectives so the
student knows the topics that will be presented in the chapter. In
addition to providing a quick reference to topics covered, this feature
provides a useful study aid.
FLOWCHARTS This book has plenty of figures and illustrations,
including flowcharts, which provide the reader with a visual learning
experience, rather than one that involves simply studying text. You
can see examples of flowcharts beginning in Chapter 1.
PSEUDOCODE This book also includes numerous examples of
pseudocode, which illustrate correct usage of the programming logic
and design concepts being taught.
NOTES These tips provide additional information—for
example, another location in the book that expands on a topic,
or a common error to watch out for.
THE DON’T DO IT ICON It is sometimes illustrative to
show an example of how NOT to do something—for
example, having a dead code path in a program. However,
students do not always read carefully and sometimes use logic similar
to that shown in what is intended to be a “bad” example. When the
instructor is critical, the frustrated student says, “But that’s how they
did it in the book!” Therefore, although the text will continue to
describe bad examples, and the captions for the related figures will
mention that they are bad examples, the book also includes a “Don’t
Do It” icon near the offending section of logic. This icon provides a
visual jolt to the student, emphasizing that particular figures are NOT
to be emulated.
THE TWO TRUTHS AND A LIE QUIZ This quiz appears after each
chapter section, with answers provided. The quiz contains three
statements based on the preceding section of text—two true and one
false. Over the years, students have requested answers to problems,
but we have hesitated to distribute them in case instructors want
to use problems as assignments or test questions. These true-false
mini-quizzes provide students with immediate feedback as they read,
without “giving away” answers to the multiple-choice questions and
programming problems later in the chapter.
xviii
P R E FA C E
GAME ZONE EXERCISES These exercises are included at the
end of each chapter. Students can create games as an
additional entertaining way to understand key concepts
presented in the chapter.
CHAPTER SUMMARIES Following each chapter is a summary that
recaps the programming concepts and techniques covered in the
chapter. This feature provides a concise means for students to review
and check their understanding of the main points in each chapter.
KEY TERMS Each chapter lists key terms and their definitions; the list
appears in the order the terms are encountered in the chapter. Along
with the chapter summary, the list of key terms provides a snapshot
overview of a chapter’s main ideas. A glossary at the end of the book lists
all the key terms in alphabetical order, along with working definitions.
DEBUGGING EXERCISES Because examining programs
critically and closely is a crucial programming skill, each
chapter includes a “Find the Bugs” section in which program-
ming examples are presented that contain syntax errors and logical
errors for the student to find and correct.
REVIEW QUESTIONS Twenty multiple-choice review questions
appear at the end of every chapter to allow students to test their
comprehension of the major ideas and techniques presented.
EXERCISES Multiple end-of-chapter flowcharting and pseudocoding
exercises are included so students have more opportunities to practice
concepts as they learn them. These exercises increase in difficulty and
are designed to allow students to explore logical programming concepts.
Each exercise can be completed using flowcharts, pseudocode, or both.
In addition, instructors can assign the exercises as programming prob-
lems to be coded and executed in a particular programming language.
ESSAY QUESTIONS Each chapter contains an “Up For
Discussion” section in which questions present personal and
ethical issues that programmers must consider. These ques-
tions can be used for written assignments or as a starting point for
classroom discussions.
New to this Edition!
VIDEO LESSONS Each chapter is accompanied by two or
more video lessons that help explain an important chapter
concept. A listing of the videos provided can be found on
the inside back cover of this text. These videos are designed
and narrated by the author and are available for free with a new book.
(They can also be purchased separately at iChapters.com.)
xix
P R E FA C E
If you have a new book, it will contain a URL and PIN code. Once you
go to this URL and enter your PIN code, follow the prompts to locate
the videos for this text. If you are a user of an online course cartridge,
such as BlackBoard, WebCT, or Angel, you will also have access to
these videos through that platform.
INCREASED EMPHASIS ON MODULARITY From the second chapter,
students are encouraged to write code in concise, easily manageable,
and reusable modules. Instructors have found that modularization
is a technique that should be encouraged early to instill good habits
and a clearer understanding of structure. This edition explains
modularization early, using global variables instead of local passed
and returned values, and saves parameter passing for later when the
student has become more adept.
CLEARER EXPLANATIONS This edition has been rewritten to
provide clearer, simpler explanations that are appropriate for the
beginning programming student. As a result of the new, cleaner
approach, the length of the book has been reduced.
NEW APPENDICES FOR EASY REFERENCE New appendices
have been added that cover numbering systems, flowchart symbols,
and structures.
DECREASED EMPHASIS ON CONTROL BREAKS Professional
programmers should understand control break logic, but creating
such logic is not as common a task as it was years ago. Therefore, the
topic is still covered briefly as part of the file-handling chapter, but
with reduced emphasis from previous editions of the book.
Instructor Resources
The following supplemental materials are available when this
book is used in a classroom setting. All of the instructor resources
available with this book are provided to the instructor on a single
CD-ROM.
ELECTRONIC INSTRUCTOR’S MANUAL The Instructor’s Manual
that accompanies this textbook provides additional instructional
material to assist in class preparation, including items such as Sample
Syllabi, Chapter Outlines, Technical Notes, Lecture Notes, Quick
Quizzes, Teaching Tips, Discussion Topics, and Key Terms.
EXAMVIEW® This textbook is accompanied by ExamView, a powerful
testing software package that allows instructors to create and admin-
ister printed, computer (LAN-based), and Internet exams. ExamView
includes hundreds of questions that correspond to the topics covered in
this text, enabling students to generate detailed study guides that include
page references for further review. The computer-based and Internet
xx
P R E FA C E
testing components allow students to take exams at their computers,
and save the instructor time by grading each exam automatically.
POWERPOINT PRESENTATIONS This book comes with Microsoft
PowerPoint© slides for each chapter. These are included as a teach-
ing aid for classroom presentation, to make available to students
on your network for chapter review, or to be printed for classroom
distribution. Instructors can add their own slides for additional topics
they introduce to the class.
SOLUTIONS Suggested solutions to Review Questions and Exercises
are provided on the Instructor Resources CD and may also be found
on the Course Technology Web site at www.cengage.com/coursetech-
nology. The solutions are password protected.
DISTANCE LEARNING Course Technology offers WebCT© and
Blackboard© courses for this text to provide the most complete and
dynamic learning experience possible. When you add online content
to one of your courses, you’re adding a lot: automated tests, topic
reviews, quick quizzes, and additional case projects with solutions.
For more information on how to bring distance learning to your
course, contact your Course Technology sales representative.
Software Options
You have the option to bundle software with your text! Please contact
your Course Technology sales representative for more information.
MICROSOFT® OFFICE VISIO® PROFESSIONAL Visio is a
diagramming program that helps users create flowcharts and
diagrams easily while working through the text, enabling them to
visualize concepts and learn more effectively.
VISUAL LOGIC™ This simple but powerful tool teaches program-
ming logic and design without traditional high-level programming
language syntax. Visual Logic uses flowcharts to explain essential
programming concepts, including variables, input, assignment, out-
put, conditions, loops, procedures, graphics, arrays, and files. It also
has the ability to interpret and execute flowcharts, providing students
with immediate and accurate feedback about their solutions. By exe-
cuting student solutions, Visual Logic combines the power of a high-
level language with the ease and simplicity of flowcharts.
Acknowledgments
I would like to thank all of the people who helped to make this book
a reality, especially Dan Seiter, Development Editor, whose hard work
and attention to detail have made this a high-quality textbook. I have
xxi
P R E FA C E
worked with Dan for many years now, and he is indispensable in pro-
ducing accurate and approachable technical instruction. Thanks also
to Tricia Coia, Managing Editor; Amy Jollymore, Acquisitions Editor;
Jennifer Feltri, Content Project Manager; and Green Pen QA, Technical
Editors. I am grateful to be able to work with so many fine people who
are dedicated to producing high-quality instructional materials.
I am grateful to the many reviewers who provided helpful and
insightful comments during the development of this book, including
Gilbert Armour, Virginia Western Community College; John Buerck,
Saint Louis University; Karen Cummings, McLennan Community
College; Clara Groeper, Illinois Central College; and Jeff Hedrington,
Colorado Technical University.
Thanks, too, to my husband, Geoff, and our daughters, Andrea and
Audrey, for their support. This book, as were all its previous editions,
is dedicated to them.
–Joyce Farrell
xxii
P R E FA C E
About the Inside Front Cover
Check out our interviews with recent graduates who are now
working in the IT field. One is featured on the inside front cover
of this book. If you know people who recently landed a job in IT,
we’d like to interview them too! Send your suggestions via e-mail to
Amy Jollymore, Acquisitions Editor, at Amy.Jollymore@Cengage.com. xxiii
P R E FA C E
This page intentionally left blank
C H A P T E R 1
An Overview of
Computers and
Programming
In this chapter, you will learn about:
Computer systems

Simple program logic

The steps involved in the program development cycle

Pseudocode statements and flowchart symbols

Using a sentinel value to end a program

Programming and user environments

The evolution of programming models

Understanding Computer Systems
A computer system is a combination of all the components required
to process and store data using a computer. Every computer system
is composed of multiple pieces of hardware and software.
Hardware
• is the equipment, or the physical devices, associated
with a computer. For example, keyboards, mice, speakers, and
printers are all hardware. The devices are manufactured differently
for large mainframe computers, laptops, and even smaller comput-
ers that are embedded into products such as cars and thermostats,
but the types of operations performed by different-sized comput-
ers are very similar. When you think of a computer, you often think
of its physical components first, but for a computer to be useful it
needs more than devices; a computer needs to be given instruc-
tions. Just as your stereo equipment does not do much until you
provide music, computer hardware needs instructions that control
how and when data items are input, how they are processed, and
the form in which they are output or stored.
Software
• is computer instructions that tell the hardware what to do.
Software is programs: instructions written by programmers. You can
buy prewritten programs that are stored on a disk or that you down-
load from the Web. For example, businesses use word-processing
and accounting programs, and casual computer users enjoy pro-
grams that play music and games. Alternatively, you can write your
own programs. When you write software instructions, you are
programming. This book focuses on the programming process.
Software can be classified as application software or system software.
Application software comprises all the programs you apply to a task—
word-processing programs, spreadsheets, payroll and inventory programs,
and even games. System software comprises the programs that you use
to manage your computer, including operating systems such as Windows,
Linux, or UNIX. This book focuses on the logic used to write application software pro-
grams, although many of the concepts apply to both types of software.
Together, computer hardware and software accomplish three major
operations in most programs:
Input
• —Data items enter the computer system and are put into mem-
ory, where they can be processed. Hardware devices that perform input
operations include keyboards and mice. Data items include all the text,
numbers, and other information that are processed by a computer.
In business, much of the data used is facts and figures about such entities as
products, customers, and personnel. However, data can also be items such
as the choices a player makes in a game or the notes required by a music-
playing program.
2
C H A P T E R 1 An Overview of Computers and Programming
Many computer professionals distinguish between the terms data, which
describes items that are input, and information, which describes data items
that have been processed and sent to a device where people can read and
interpret them. For example, your name, Social Security number, and
hourly pay rate are data items when they are input to a program, but the
same items are information after they have been processed and output on your
paycheck.
Processing
• —Processing data items may involve organizing or sorting
them, checking them for accuracy, or performing calculations with
them. The hardware component that performs these types of tasks is
the central processing unit, or CPU.
Output
• —After data items have been processed, the resulting infor-
mation usually is sent to a printer, monitor, or some other output
device so people can view, interpret, and use the results.
Some people consider storage as a fourth major computer operation.
Instead of sending output to a device such as a printer, monitor, or speaker
where a person can interpret it, you sometimes store output on storage
devices, such as a disk or flash media. People cannot read data directly
from these storage devices, but the devices hold information for later
retrieval. When you send output to a storage device, sometimes it is used later as input
for another program.
You write computer instructions in a computer programming
language, such as Visual Basic, C#, C++, or Java. Just as some
people speak English and others speak Japanese, programmers also
write programs in different languages. Some programmers work
exclusively in one language, whereas others know several program-
ming languages and use the one that is best suited to the task
at hand.
Every programming language has rules governing its word usage and
punctuation. These rules are called the language’s syntax. If you ask,
“How the geet too store do I?” in English, most people can figure
out what you probably mean, even though you have not used proper
English syntax—you have mixed up the word order, misspelled a
word, and used an incorrect word. However, computers are not
nearly as smart as most people; in this case, you might as well have
asked the computer, “Xpu mxv ort dod nmcad bf B?” Unless the
syntax is perfect, the computer cannot interpret the programming
language instruction at all.
When you write a program, you usually type its instructions using
a keyboard. When you type program instructions, they are stored
in computer memory, which is a computer’s temporary, internal
The instruc-
tions you write
using a pro-
gramming
language are
called program code;
when you write instruc-
tions, you are coding the
program.
3
Understanding Computer Systems
storage. Internal storage is volatile—its contents are lost when the
computer is turned off or loses power. Usually, you want to be able to
retrieve and perhaps modify the stored instructions later, so you also
store them on a permanent storage device, such as a disk. Permanent
storage devices are nonvolatile—that is, their contents are persistent
and are retained even when power is lost.
After a computer program is stored in memory, it must be trans-
lated from your programming language statements to machine
language that represents the millions of on/off circuits within the
computer. Each programming language uses a piece of software,
called a compiler or an interpreter, to translate your program
code into machine language. Machine language is also called
binary language, and is represented as a series of 0s and 1s. The
compiler or interpreter that translates your code tells you if any
programming language component has been used incorrectly.
Syntax errors are relatively easy to locate and correct because
the compiler or interpreter you use highlights every syntax error.
If you write a computer program using a language such as C++
but spell one of its words incorrectly or reverse the proper order
of two words, the software lets you know that it found a mistake
by displaying an error message as soon as you try to translate the
program.
Although there are differences in how compilers and interpreters work, their
basic function is the same—to translate your programming statements into
code the computer can use. When you use a compiler, an entire program is
translated before it can execute; when you use an interpreter, each instruc-
tion is translated just prior to execution. Usually, you do not choose which
type of translation to use—it depends on the programming language. However, there
are some languages for which both compilers and interpreters are available.
Only after program instructions are successfully translated to machine
code can the computer carry out the program instructions. When
instructions are carried out, a program runs, or executes. In a typical
program, some input will be accepted, some processing will occur,
and results will be output.
Besides the popular full-blown programming languages such as Java
and C++, many programmers use scripting languages (also called
scripting programming languages or script languages) such as Python,
Lua, Perl, and PHP. Scripts written in these languages usually can be typed
directly from a keyboard and are stored as text rather than as binary execut-
able files. Scripting language programs are interpreted line by line each time the
program executes, instead of being stored in a compiled (binary) form.
Random
access
memory, or
RAM, is a
form of inter-
nal, volatile memory. It is
hardware on which the
programs that are cur-
rently running and the
data items that are
currently being used
are stored for quick
access.
The program
statements
you write in a
programming
language are
known as source code.
The translated machine
language statements are
known as object code.
4
C H A P T E R 1 An Overview of Computers and Programming
TWO TRUTHS & A LIE
Understanding Computer Systems
In each Two Truths and a Lie section, two of the numbered statements are true,
and one is false. Identify the false statement and explain why it is false.
1. Hardware is the equipment, or the devices, associated with a computer.
Software is computer instructions.
2. The grammar rules of a computer programming language are its syntax.
3. You write programs using machine language, and translation software con-
verts the statements to a programming language.
The
false
statement
is
#3.
You
write
programs
using
a
programming
language
such
as
Visual
Basic
or
Java,
and
a
translation
program
(called
a
compiler
or
inter-
preter)
converts
the
statements
to
machine
language,
which
is
0s
and
1s.
Understanding Simple Program Logic
A program with syntax errors cannot execute. A program with no syntax
errors can execute, but might contain logical errors, and produce incor-
rect output as a result. For a program to work properly, you must give the
instructions to the computer in a specific sequence, you must not leave
any instructions out, and you must not add extraneous instructions. By
doing this, you are developing the logic of the computer program.
Suppose you instruct someone to
make a cake as follows:
Get a bowl
Stir
Add two eggs
Add a gallon of gasoline
Bake at 350 degrees for 45 minutes
Add three cups of flour
Even though you have used the English language syntax correctly, the
cake-baking instructions are out of sequence, some instructions are
missing, and some instructions belong to procedures other than baking
a cake. If you follow these instructions, you are not going to make an edi-
ble cake, and you most likely will end up with a disaster. Logical errors
are much more difficult to locate than syntax errors—it is easier for you
to determine whether “eggs” is spelled incorrectly in a recipe than it is
for you to tell if there are too many eggs or if they are added too soon.
The dangerous
cake-baking
instructions
are shown with
a Don’t Do It
icon. You will see this icon
when the book contains
an unrecommended pro-
gramming practice that is
used as an example of
what not to do.
If you misspell
a program-
ming language
word, you
commit a
syntax error, but if you
use an otherwise correct
word that does not make
sense in the current con-
text, programmers say
you have committed a
semantic error. Either
way, the program will not
execute.
Don’t Do It
Don't bake a cake like
this!
5
Understanding Simple Program Logic
Just as baking directions can be given correctly in Mandarin, Urdu,
or Spanish, the same program logic can be expressed in any number
of programming languages. Because this book is not concerned with
any specific language, the programming examples could have been
written in Visual Basic, C++, or Java. For convenience, this book uses
instructions written in English!
Most simple computer programs include steps that perform input,
processing, and output. Suppose you want to write a computer
program to double any number you provide. You can write such a
program in a programming language such as Visual Basic or Java,
but if you were to write it using English-like statements, it would
look like this:
input myNumber
set myAnswer = myNumber * 2
output myAnswer
The number-doubling process includes three instructions:
The instruction to
• input myNumber is an example of an input
operation. When the computer interprets this instruction, it
knows to look to an input device to obtain a number. When you
work in a specific programming language, you write instructions
that tell the computer which device to access for input. For exam-
ple, when a user enters a number as data for a program, the user
might click on the number with a mouse, type it from a keyboard,
or speak it into a microphone. Logically, however, it doesn’t really
matter which hardware device is used, as long as the computer
knows to look for a number. When the number is retrieved from
an input device, it is placed in the computer’s memory at the
location named myNumber. The location myNumber is a variable. A
variable is a named memory location whose value can vary—for
example, the value of myNumber might be 3 when the program is
used for the first time and 45 when it is used the next time.
From a logical perspective, when you input a value, the hardware device is
irrelevant. The same is true in your daily life. If you follow the instruction “Get
eggs for the cake,” it does not really matter if you purchase them from a
store or harvest them from your own chickens—you get the eggs either way.
There might be different practical considerations to getting the eggs, just as
there are for getting data from a large database as opposed to an inexperienced user.
For now, this book is only concerned with the logic of the operation, not the minor
details.
The instruction
• set myAnswer = myNumber * 2 is an example
of a processing operation. Mathematical operations are not the
only kind of processing operations, but they are very typical. As
with input operations, the type of hardware used for processing
After you learn
French, you
automatically
know, or can
easily figure
out, many Spanish words.
Similarly, after you learn
one programming lan-
guage, it is much easier
to understand several
other languages.
You will learn
about the odd
elimination of
the space
between
words like my and
Number in Chapter 2.
Programmers
use an aster-
isk to indicate
multiplication.
You will learn
more about arithmetic
statements in Chapter 2.
6
C H A P T E R 1 An Overview of Computers and Programming
is irrelevant—after you write a program, it can be used on comput-
ers of different brand names, sizes, and speeds. The instruction
takes the value stored in memory at the myNumber location, mul-
tiplies it by 2, and stores the result in another memory location
named myAnswer.
In the number-doubling program, the
• output myAnswer instruc-
tion is an example of an output operation. Within a particular
program, this statement could cause the output to appear on the
monitor (which might be a flat-panel plasma screen or a cathode-
ray tube), or the output could go to a printer (which could be laser
or ink-jet), or the output could be written to a disk or DVD. The
logic of the output process is the same no matter what hardware
device you use. When this instruction executes, the value stored
in memory at the location named myAnswer is sent to an output
device.
Computer memory consists of millions of numbered locations where data
can be stored. The memory location of myNumber has a specific numeric
address—for example, 48604. Your program associates myNumber with
that address. Every time you refer to myNumber within a program, the com-
puter retrieves the value at the associated memory location. When you write
programs, you seldom need to be concerned with the value of the memory address;
instead, you simply use the easy-to-remember name you created.
Computer programmers often refer to memory addresses using hexadeci-
mal notation, or base 16. Using this system, they might use a value like
42FF01A to refer to a memory address. Despite the use of letters, such an
address is still a hexadecimal number. Appendix A contains information on
this numbering system.
TWO TRUTHS & A LIE
Understanding Simple Program Logic
1. A program with syntax errors can execute but might produce incorrect results.
2. Although the syntax of programming languages differs, the same program
logic can be expressed in different languages.
3. Most simple computer programs include steps that perform input, process-
ing, and output.
The
false
statement
is
#1.
A
program
with
syntax
errors
cannot
execute;
a
program
with
no
syntax
errors
can
execute,
but
might
produce
incorrect
results.
Watch the
video A Simple
Program.
7
Understanding Simple Program Logic
Understanding the Program
Development Cycle
A programmer’s job involves writing instructions (such as those in
the doubling program in the preceding section), but a professional
programmer usually does not just sit down at a computer keyboard
and start typing. Figure 1-1 illustrates the program development
cycle, which can be broken down into at least seven steps:
1. Understand the problem.
2. Plan the logic.
3. Code the program.
4. Use software (a compiler or interpreter) to translate the
program into machine language.
5. Test the program.
6. Put the program into production.
7. Maintain the program.
Understand
the problem
Test the
program
Put the program
into production
Maintain the
program
Plan the
logic
Translate the
code
Write the
code
Figure 1-1 The program development cycle
Understanding the Problem
Professional computer programmers write programs to satisfy the
needs of others, called users or end users. Examples could include a
Human Resources department that needs a printed list of all employ-
ees, a Billing department that wants a list of clients who are 30 or
more days overdue on their payments, and an Order department that
8
C H A P T E R 1 An Overview of Computers and Programming
needs a Web site to provide buyers with an online shopping cart in
which to gather their orders. Because programmers are providing a
service to these users, programmers must first understand what the
users want. Although when a program runs, you usually think of the
logic as a cycle of input-processing-output operations; when you
plan a program, you think of the output first. After you understand
what the desired result is, you can plan what to input and process to
achieve it.
Suppose the director of Human Resources says to a programmer,
“Our department needs a list of all employees who have been here
over five years, because we want to invite them to a special thank-you
dinner.” On the surface, this seems like a simple request. An experi-
enced programmer, however, will know that the request is incom-
plete. For example, you might not know the answers to the following
questions about which employees to include:
Does the director want a list of full-time employees only, or a list
•
of full- and part-time employees together?
Does she want people who have worked for the company on a
•
month-to-month contractual basis over the past five years, or only
regular, permanent employees?
Do the listed employees need to have worked for the organization
•
for five years as of today, as of the date of the dinner, or as of some
other cutoff date?
What about an employee who, for example, worked three years,
•
took a two-year leave of absence, and has been back for three years?
The programmer cannot make any of these decisions; the user (in this
case, the Human Resources director) must address these questions.
More decisions still might be required. For example:
What data should be included for each listed employee? Should
•
the list contain both first and last names? Social Security numbers?
Phone numbers? Addresses?
Should the list be in alphabetical order? Employee ID number
•
order? Length-of-service order? Some other order?
Should the employees be grouped by any criteria, such as depart-
•
ment number or years of service?
Several pieces of documentation are often provided to help the pro-
grammer understand the problem. Documentation consists of all the
supporting paperwork for a program; it might include items such
as original requests for the program from users, sample output, and
descriptions of the data items available for input.
The term end
user distin-
guishes those
who actually
use and ben-
efit from a software prod-
uct from others in an
organization who might
purchase, install, or have
other contact with the
software.
9
Understanding the Program Development Cycle
Really understanding the problem may be one of the most difficult
aspects of programming. On any job, the description of what the user
needs may be vague—worse yet, users may not really know what they
want, and users who think they know frequently change their minds
after seeing sample output. A good programmer is often part coun-
selor, part detective!
Planning the Logic
The heart of the programming process lies in planning the program’s
logic. During this phase of the process, the programmer plans the
steps of the program, deciding what steps to include and how to order
them. You can plan the solution to a problem in many ways. The two
most common planning tools are flowcharts and pseudocode. Both
tools involve writing the steps of the program in English, much as you
would plan a trip on paper before getting into the car or plan a party
theme before shopping for food and favors.
The programmer shouldn’t worry about the syntax of any particu-
lar language at this point, but should focus on figuring out what
sequence of events will lead from the available input to the desired
output. Planning the logic includes thinking carefully about all the
possible data values a program might encounter and how you want
the program to handle each scenario. The process of walking through
a program’s logic on paper before you actually write the program is
called desk-checking. You will learn more about planning the logic
throughout this book; in fact, the book focuses on this crucial step
almost exclusively.
Coding the Program
After the logic is developed, only then can the programmer write
the program. Hundreds of programming languages are available.
Programmers choose particular languages because some have built-in
capabilities that make them more efficient than others at handling
certain types of operations. Despite their differences, programming
languages are quite alike in their basic capabilities—each can handle
input operations, arithmetic processing, output operations, and other
standard functions. The logic developed to solve a programming
problem can be executed using any number of languages. Only after
choosing a language must the programmer be concerned with proper
punctuation and the correct spelling of commands—in other words,
using the correct syntax.
Some very experienced programmers can successfully combine
logic planning and program coding in one step. This may work for
Watch the video
The Program
Development
Cycle, Part 1.
You may hear
programmers
refer to
planning a
program as
“developing an algorithm.”
An algorithm is the
sequence of steps neces-
sary to solve any problem.
You will learn
more about
flowcharts
and pseudo-
code later in
this chapter.
In addition to
flowcharts and
pseudocode,
programmers
use a variety
of other tools to help in
program development.
One such tool is an IPO
chart, which delineates
input, processing, and
output tasks. Some
object-oriented program-
mers also use TOE
charts, which list tasks,
objects, and events.
10
C H A P T E R 1 An Overview of Computers and Programming
planning and writing a very simple program, just as you can plan and
write a postcard to a friend using one step. A good term paper or a
Hollywood screenplay, however, needs planning before writing—and
so do most programs.
Which step is harder: planning the logic or coding the program?
Right now, it may seem to you that writing in a programming lan-
guage is a very difficult task, considering all the spelling and syntax
rules you must learn. However, the planning step is actually more
difficult. Which is more difficult: thinking up the twists and turns to
the plot of a best-selling mystery novel, or writing a translation of an
existing novel from English to Spanish? And who do you think gets
paid more, the writer who creates the plot or the translator? (Try
asking friends to name any famous translator!)
Using Software to Translate the Program
into Machine Language
Even though there are many programming languages, each computer
knows only one language: its machine language, which consists of 1s
and 0s. Computers understand machine language because they are
made up of thousands of tiny electrical switches, each of which can
be set in either the on or off state, which is represented by a 1 or 0,
respectively.
Languages like Java or Visual Basic are available for programmers
because someone has written a translator program (a compiler or
interpreter) that changes the programmer’s English-like high-level
programming language into the low-level machine language that
the computer understands. If you write a programming language
statement incorrectly (for example, by misspelling a word, using a
word that doesn’t exist in the language, or using “illegal” grammar),
the translator program doesn’t know how to proceed and issues
an error message identifying a syntax error, which is a misuse of a
language’s grammar rules. Although making errors is never desirable,
syntax errors are not a major concern to programmers, because the
compiler or interpreter catches every syntax error and displays a mes-
sage that notifies you of the problem. The computer will not execute a
program that contains even one syntax error.
Typically, a programmer develops a program’s logic, writes the code,
and compiles the program, receiving a list of syntax errors. The pro-
grammer then corrects the syntax errors and compiles the program
again. Correcting the first set of errors frequently reveals new errors
that originally were not apparent to the compiler. For example, if you
could use an English compiler and submit the sentence “The dg chase
When you
learn the syn-
tax of a pro-
gramming
language, the
commands you learn will
work on any machine on
which the language soft-
ware has been installed.
However, your com-
mands are translated to
machine language, which
differs depending on your
computer make and
model.
Watch the video
The Program
Development
Cycle, Part 2.
11
Understanding the Program Development Cycle
the cat,” the compiler at first might point out only one syntax error.
The second word, “dg,” is illegal because it is not part of the English
language. Only after you corrected the word to “dog” would the com-
piler find another syntax error on the third word, “chase,” because it is
the wrong verb form for the subject “dog.” This doesn’t mean “chase”
is necessarily the wrong word. Maybe “dog” is wrong; perhaps the
subject should be “dogs,” in which case “chase” is right. Compilers
don’t always know exactly what you mean, nor do they know what the
proper correction should be, but they do know when something is
wrong with your syntax.
When writing a program, a programmer might need to recompile the
code several times. An executable program is created only when the
code is free of syntax errors. When you run an executable program, it
typically also might require input data. Figure 1-2 shows a diagram of
this entire process.
Write and correct
the program code
Compile the
program
Executable
program
Data that the
program uses
List of
syntax
error
messages
Program
output
If there are no
syntax errors
If there are
syntax errors
Figure 1-2 Creating an executable program
Testing the Program
A program that is free of syntax errors is not necessarily free of logi-
cal errors. A logical error results when you use a syntactically correct
statement but use the wrong one for the current context. For exam-
ple, the English sentence “The dog chases the cat,” although syntacti-
cally perfect, is not logically correct if the dog chases a ball or the cat
is the aggressor.
After a pro-
gram has
been trans-
lated into
machine lan-
guage, the machine lan-
guage program is saved
and can be run any num-
ber of times without
repeating the translation
step. You only need to
retranslate your code if
you make changes to
your source code
statements.
12
C H A P T E R 1 An Overview of Computers and Programming
Once a program is free of syntax errors, the programmer can
test it—that is, execute it with some sample data to see whether
the results are logically correct. Recall the number-doubling
program:
input myNumber
set myAnswer = myNumber * 2
output myAnswer
If you execute the program, provide the value 2 as input to the pro-
gram, and the answer 4 is displayed, you have executed one successful
test run of the program.
However, if the answer 40 is displayed, maybe the program contains
a logical error. Maybe the second line of code was mistyped with an
extra zero, so that the program reads:
input myNumber
set myAnswer = myNumber * 20
output myAnswer
Placing 20 instead of 2 in the
multiplication statement caused a logical error. Notice that nothing is
syntactically wrong with this second program—it is just as reasonable
to multiply a number by 20 as by 2—but if the programmer intends
only to double myNumber, then a logical error has occurred.
Programs should be tested with many sets of data. For example, if
you write the program to double a number, then enter 2 and get an
output value of 4, that doesn’t
necessarily mean you have
a correct program. Perhaps
you have typed this program
by mistake:
input myNumber
set myAnswer = myNumber + 2
output myAnswer
An input of 2 results in an answer of 4, but that doesn’t mean your
program doubles numbers—it actually only adds 2 to them. If you test
your program with additional data and get the wrong answer—for
example, if you enter 7 and get an answer of 9—you know there is a
problem with your code.
Selecting test data is somewhat of an art in itself, and it should be
done carefully. If the Human Resources department wants a list
of the names of five-year employees, it would be a mistake to test
the program with a small sample file of only long-term employees.
If no newer employees are part of the data being used for testing,
you do not really know if the program would have eliminated them
The process
of finding and
correcting
program
errors is
called debugging.
Don’t Do It
The programmer typed
"20" instead of "2".
Don’t Do It
The programmer typed
"+" instead of "
*".
13
Understanding the Program Development Cycle
from the five-year list. Many companies do not know that their
software has a problem until an unusual circumstance occurs—for
example, the first time an employee has more than nine depen-
dents, the first time a customer orders more than 999 items at a
time, or when (as well-documented in the popular press) a new
century begins.
Putting the Program into
Production
Once the program is tested adequately, it is ready for the organi-
zation to use. Putting the program into production might mean
simply running the program once, if it was written to satisfy a
user’s request for a special list. However, the process might take
months if the program will be run on a regular basis, or if it is one
of a large system of programs being developed. Perhaps data-entry
people must be trained to prepare the input for the new program;
users must be trained to understand the output; or existing data
in the company must be changed to an entirely new format to
accommodate this program. Conversion, the entire set of actions
an organization must take to switch over to using a new pro-
gram or set of programs, can sometimes take months or years to
accomplish.
Maintaining the Program
After programs are put into production, making necessary
changes is called maintenance. Maintenance can be required for
many reasons: new tax rates are legislated, the format of an input
file is altered, or the end user requires additional information
not included in the original output specifications, to name a few.
Frequently, your first programming job will require maintaining
previously written programs. When you maintain the programs
others have written, you will appreciate the effort the original pro-
grammer put into writing clear code, using reasonable variable
names, and documenting his or her work. When you make changes
to existing programs, you repeat the development cycle. That is, you
must understand the changes, then plan, code, translate, and test
them before putting them into production. If a substantial number
of program changes are required, the original program might be
retired, and the program development cycle might be started for a
new program.
Chapter 4
contains more
information on
testing
programs.
Watch the video
The Program
Development
Cycle, Part 3.
14
C H A P T E R 1 An Overview of Computers and Programming
TWO TRUTHS & A LIE
Understanding the Program Development Cycle
1. Understanding the problem that must be solved can be one of the most dif-
ficult aspects of programming.
2. The two most commonly used logic-planning tools are flowcharts and
pseudocode.
3. Flowcharting a program is a very different process if you use an older
programming language instead of a newer one.
The
false
statement
is
#3.
Despite
their
differences,
programming
languages
are
quite
alike
in
their
basic
capabilities—each
can
handle
input
operations,
arithmetic
processing,
output
operations,
and
other
standard
functions.
The
logic
developed
to
solve
a
programming
problem
can
be
executed
using
any
number
of
languages.
Using Pseudocode Statements
and Flowchart Symbols
When programmers plan the logic for a solution to a programming
problem, they often use one of two tools: pseudocode (pronounced
“sue-doe-code”) or flowcharts. Pseudocode is an English-like repre-
sentation of the logical steps it takes to solve a problem. A flowchart
is a pictorial representation of the same thing. Pseudo is a prefix that
means “false,” and to code a program means to put it in a programming
language; therefore, pseudocode simply means “false code,” or sentences
that appear to have been written in a computer programming language
but do not necessarily follow all the syntax rules of any specific language.
Writing Pseudocode
You have already seen examples of statements that represent pseudo-
code earlier in this chapter, and there is nothing mysterious about
them. The following five statements constitute a pseudocode repre-
sentation of a number-doubling problem:
start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop
15
Using Pseudocode Statements and Flowchart Symbols
Using pseudocode involves writing down all the steps you will use in
a program. Usually, programmers preface their pseudocode with a
beginning statement like start and end it with a terminating state-
ment like stop. The statements between start and stop look like
English and are indented slightly so that start and stop stand out.
Most programmers do not bother with punctuation such as periods
at the end of pseudocode statements, although it would not be wrong
to use them if you prefer that style. Similarly, there is no need to capi-
talize the first word in a sentence, although you might choose to do
so. This book follows the conventions of using lowercase letters for
verbs that begin pseudocode statements and omitting periods at the
end of statements.
Pseudocode is fairly flexible because it is a planning tool, and not the
final product. Therefore, for example, you might prefer any of the
following:
Instead of
• start and stop, some pseudocode developers would
use the terms begin and end.
Instead of writing
• input myNumber, some developers would write
get myNumber or read myNumber.
Instead of writing
• set myAnswer = myNumber * 2, some develop-
ers would write calculate myAnswer = myNumber times 2 or
compute myAnswer as myNumber doubled.
Instead of writing
• output myAnswer, many pseudocode devel-
opers would write display myAnswer, print myAnswer, or
write myAnswer.
The point is, the pseudocode statements are instructions to retrieve
an original number from an input device and store it in memory
where it can be used in a calculation, and then to get the calculated
answer from memory and send it to an output device so a person can
see it. When you eventually convert your pseudocode to a specific
programming language, you do not have such flexibility because spe-
cific syntax will be required. For example, if you use the C# program-
ming language and write the statement to output the answer, you will
code the following:
Console.Write (myAnswer);
The exact use of words, capitalization, and punctuation are important
in the C# statement, but not in the pseudocode statement.
16
C H A P T E R 1 An Overview of Computers and Programming
Drawing Flowcharts
Some professional programmers prefer writing pseudocode to
drawing flowcharts, because using pseudocode is more similar to
writing the final statements in the programming language. Others
prefer drawing flowcharts to represent the logical flow, because flow-
charts allow programmers to visualize more easily how the program
statements will connect. Especially for beginning programmers, flow-
charts are an excellent tool to help them visualize how the statements
in a program are interrelated.
When you create a flowchart, you draw geometric shapes that contain
the individual statements and that are connected with arrows. You
use a parallelogram to represent
an input symbol, which indicates
an input operation. You write an
input statement in English inside the
parallelogram, as shown in Figure 1-3.
Arithmetic operation statements
are examples of processing. In a
flowchart, you use a rectangle as the
processing symbol that contains a
processing statement, as shown in
Figure 1-4.
To represent an output state-
ment, you use the same symbol as
for input statements—the output
symbol is a parallelogram, as shown
in Figure 1-5.
Some software programs that use flowcharts (such as Visual Logic) use
a left-slanting parallelogram to represent output. As long as the flowchart
creator and the flowchart reader are communicating, the actual shape
used is irrelevant. This book will follow the most standard convention
of always using the right-slanting parallelogram for both input and output.
To show the correct sequence of these statements, you use arrows, or
flowlines, to connect the steps. Whenever possible, most of a flow-
chart should read from top to bottom or from left to right on a page.
That’s the way we read English, so when flowcharts follow this con-
vention, they are easier for us to understand.
You can draw
a flowchart by
hand or use
software,
such as
Microsoft Word and
Microsoft PowerPoint,
that contains flowcharting
tools. You can use sev-
eral other software pro-
grams, such as Visio and
Visual Logic, specifically
to create flowcharts.
Because the
parallelogram
is used for
both input and
output, it is
often called
the input/output
symbol or I/O symbol.
Appendix B
contains a
summary of
all the flow-
chart symbols
you will see in this book.
input myNumber
Figure 1-3 Input symbol
set myAnswer =
myNumber * 2
Figure 1-4 Processing symbol
output myAnswer
Figure 1-5 Output symbol
17
Using Pseudocode Statements and Flowchart Symbols
To be complete, a flowchart should include two more elements:
terminal symbols, or start/stop symbols, at each end. Often, you
place a word like start or begin in the first terminal symbol and a
word like end or stop in the other. The standard terminal symbol is
shaped like a racetrack; many programmers refer to this shape as a
lozenge, because it resembles the shape of the medication you might
use to soothe a sore throat. Figure 1-6 shows a complete flowchart
for the program that doubles a number, and the pseudocode for the
same problem. You can see from the figure that the flowchart and
pseudocode statements are the same—only the presentation format
differs.
start
Flowchart Pseudocode
stop
input myNumber
output myAnswer
set myAnswer =
myNumber * 2
start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop
Figure 1-6 Flowchart and pseudocode of program that doubles a number
Repeating Instructions
After the flowchart or pseudocode has been developed, the
programmer only needs to: (1) buy a computer, (2) buy a language
compiler, (3) learn a programming language, (4) code the pro-
gram, (5) attempt to compile it, (6) fix the syntax errors, (7) com-
pile it again, (8) test it with several sets of data, and (9) put it into
production.
“Whoa!” you are probably saying to yourself. “This is simply not worth
it! All that work to create a flowchart or pseudocode, and then all those
other steps? For five dollars, I can buy a pocket calculator that will
Programmers
seldom create
both pseudo-
code and a
flowchart for
the same problem. You
usually use one or the
other. In a large program,
you might even prefer to
use pseudocode for
some parts and draw a
flowchart for others.
18
C H A P T E R 1 An Overview of Computers and Programming
double any number for me instantly!” You are absolutely right. If this
were a real computer program, and all it did was double the value of a
number, it would not be worth the effort. Writing a computer program
would be worthwhile only if you had many—let’s say 10,000—numbers
to double in a limited amount of time—let’s say the next two minutes.
Unfortunately, the number-doubling program represented in
Figure 1-6 does not double 10,000 numbers; it doubles only one. You
could execute the program 10,000 times, of course, but that would
require you to sit at the computer and tell it to run the program over
and over again. You would be better off with a program that could
process 10,000 numbers, one after the other.
One solution is to write the program shown in Figure 1-7 and execute
the same steps 10,000 times. Of course, writing this program would
be very time consuming; you might as well buy the calculator.
Figure 1-7 Inefficient pseudocode for program that doubles 10,000 numbers
start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
input myNumber
set myAnswer = myNumber * 2
output myAnswer
input myNumber
set myAnswer = myNumber * 2
output myAnswer
…and so on for 9,997 more times
A better solution is to have the computer execute the same set of
three instructions over and over again, as shown in Figure 1-8. The
repetition of a series of steps is called a loop. With this approach, the
computer gets a number, doubles it, displays the answer, and then
starts over again with the first instruction. The same spot in memory,
called myNumber, is reused for the second number and for any subse-
quent numbers. The spot in memory named myAnswer is reused each
time to store the result of the multiplication operation. The logic illus-
trated in the flowchart in Figure 1-8 contains a major problem—the
sequence of instructions never ends. This programming situation is
known as an infinite loop—a repeating flow of logic with no end. You
will learn one way to handle this problem later in this chapter; you
will learn a superior way in Chapter 3.
When you tell
a friend how
to get to your
house, you
might write a
series of instructions or
you might draw a map.
Pseudocode is similar to
written, step-by-step
instructions; a flowchart,
like a map, is a visual
representation of the
same thing.
Don’t Do It
You would never want to
write such a repetitious
list of instructions.
19
Using Pseudocode Statements and Flowchart Symbols
Another Random Scribd Document
with Unrelated Content
auf der flacheren Nordseite der Insel; zwischen ihr und der
Felsenküste von Mogistan befand sich der Hafen. Die Besatzung
bestand aus 30,000 Mann, darunter 4000 persische Bogenschützen
als Bundesgenossen. Albuquerque begrüßte bei seiner Ankunft die
Stadt durch Kanonensalven und segelte dann kühn in den Hafen
hinein. Kurzer Hand forderte er Unterwerfung und Anerkennung der
portugiesischen Oberhoheit, andernfalls drohte er mit Vernichtung.
Aber der Regent war nicht gewillt, sich bei seiner bedeutenden
Macht ohne weiteres in fremde Botmäßigkeit zu begeben, er lehnte
die Forderung des Portugiesen ab. Als Antwort darauf ließ
Albuquerque die Handelsschiffe im Hafen in den Grund bohren.
Dabei wurden seine Schiffe von zweihundert mit Bogenschützen
bemannten Böten angegriffen; aber die höher gebauten
europäischen Fahrzeuge und namentlich das europäische Geschütz
behielt den Sieg. Dann erst bequemte sich Chodscheh Atar, die
Oberhoheit des Königs Manuel anzuerkennen und einen jährlichen
Tribut von 15,000 Scherafinen (etwa à 6 Mark) zu zahlen. Auch
mußte er gestatten, daß die Portugiesen eine Festung anlegten.
Schon im October begann der Bau, aber die portugiesischen
Capitäne, welche unter Albuquerque dienten, halfen nur ungern; sie
hätten lieber gewinnreiche Jagd auf Handelsschiffe gemacht oder
wären nach Indien gesegelt, um Gewürze einzuhandeln. Sie
vereinigten sich zu einem schriftlichen Protest, aber der
Oberbefehlshaber zerriß denselben, ungelesen, unter dem Thor der
neuen Citadelle. Dadurch gekränkt und beleidigt suchten die
Capitäne nach einer Gelegenheit, sich von ihrem Führer zu trennen.
Die Uneinigkeit unter seinen Feinden ermuthigte den Regenten der
Stadt zu erneutem Widerstande. Die Gelegenheit dazu bot sich bald.
Da fünf von der Flotte entlaufene und in die Stadt gelockte
Portugiesen nicht sofort, wie Albuquerque verlangte, ausgeliefert
wurden, so brach der Krieg von neuem aus. Derselbe mußte aber
rasch abgebrochen werden, weil drei Capitäne mit ihren Schiffen auf
eigene Verantwortung den Hafen verließen und nach Indien
segelten, so daß Albuquerque, dadurch in seiner Macht geschwächt,
allein den Kampf nicht fortführen konnte, sondern sich genöthigt
sah, zur Ueberwinterung nach Sokotra zurückzuweichen. Doch
schickte er den João da Nova den Flüchtigen nach, um sich beim
Vicekönig über solche unerhörte Felonie zu beschweren.
In Sokotra fand er die Besatzung der kleinen Citadelle durch
Krankheit und Hunger erschöpft. Von Melinde mußten Lebensmittel
herbeigeschafft werden; statt Unterstützung zu finden, mußte
Albuquerque Hilfe schaffen. Sein Aufenthalt an der afrikanischen
Insel verzögerte sich bis in den Hochsommer, dann kam unter Vasco
Gomez d’Abreu Verstärkung von Lissabon. Mit dieser vereinigte er
den Rest seiner Macht, sah sich also wieder an der Spitze von 300
Mann und war kühn genug, mit dieser kleinen Schaar zum zweiten
Male vor Ormuz zu rücken. Chodscheh Atar hatte nach dem Abzuge
der Portugiesen, deren Mißerfolge er sich als Sieg anrechnete, im
Vertrauen auf seine neubefestigte Stellung und die eigne
Truppenmacht, (die persischen Bundesgenossen waren durch seinen
Uebermuth verscheucht,) klugerweise die von den Portugiesen
begonnene Festung ausgebaut[104] und mit Geschützen armirt,
welche er durch europäische Ueberläufer hatte gießen lassen. Er
war, wenn auch auf sich allein angewiesen, doch nicht so wehrlos
dem Gegner preisgegeben als das erste Mal. Daher mußte sich
Albuquerque vorläufig, als er im September 1508 wieder vor der
Stadt erschien, auf die Blokade beschränken. Inzwischen erhielt aber
Atar eine wesentliche Hilfe und Ermuthigung zum Widerstande von
einer Seite, woher er sie wohl am wenigsten erwartete, vom
Vicekönig Almeida selbst. Dieser hatte nämlich auf die Klage der drei
Capitäne, welche sich vor Ormuz von Albuquerque getrennt hatten,
im Mai 1508 eine Untersuchung der Angelegenheit befohlen und
Gonçalo Fernandez damit beauftragt. Im Verlauf derselben war
Almeida immer mehr zur Ueberzeugung gekommen, daß
Albuquerque durch seine Gewaltthaten die Interessen der
portugiesischen Krone mehr schädige als fördere. Ein von den
Portugiesen aufgebrachtes Schiff von Ormuz hatte Almeida wieder
freigegeben und mit Briefen an den Regenten von Ormuz gesandt.
Almeida’s Schreiben[105] athmete Freundschaft für die reiche
Handelsstadt, wenn er auch wünschte, der Fürst möge seinem König
jährlich ein Geschenk senden. Er sprach seinen Unwillen über die
verderbliche Kriegführung Albuquerque’s aus und sicherte, indem er
sieben Geleitsbriefe mitsandte, jedem Handelsschiffe von Ormuz
seinen Schutz zu. „Ich will,“ schrieb er, „an dem König von Portugal
zum Verräther werden, wenn ich dulde, daß ihnen auch nur ein Haar
gekrümmt werde.“
Eine Abschrift dieses Briefes ließ Chodscheh Atar an Albuquerque
übermitteln. Albuquerque bestand aber auf der Zahlung des Tributs
und erklärte die Briefe des Vicekönigs für untergeschoben, weil sie
dessen Unterschrift nicht trügen. Atar erklärte dagegen, die Stadt
werde bereit sein, in Friedenszeiten den auferlegten Tribut von
15,000 Scherafinen zu zahlen; wenn aber ihr Handel gelähmt werde,
könne sie die Summe unmöglich aufbringen. Die Briefe seien echt,
des Königs Siegel und des Vicekönigs Unterschrift bürgten dafür. —
Man weiß, welche Achtung man im ganzen Orient dem Siegel und
Namenszuge eines Mannes zollt. Albuquerque setzte darauf die
Blokade noch eine zeitlang fort und beunruhigte die Stadt in kleinen
Gefechten; da er aber die Gewißheit hatte, daß ihm von Indien her
keine Unterstützung kommen werde, und da er sah, daß es seinen
Schiffen immer schwieriger wurde, sich zu halten, weil sie leck
geworden waren, so entschloß er sich endlich den Kampf
abzubrechen und nach Indien zu gehen. Ohne Zwischenfälle
erreichte er die Andjediven, machte dort drei Tage halt und segelte
dann nach Kananor, wo er den Vicekönig fand (im Dec. 1508). Leider
mußte er hier erfahren, daß Almeida zwei von seinen rebellischen
Capitänen in Freiheit gesetzt, und den dritten, um sich zu
rechtfertigen, nach Portugal entsendet hatte. Da er zum Nachfolger
im Commando ernannt worden war, so verlangte er die Uebergabe
des Oberbefehls; aber Almeida, augenblicklich in der Ausrüstung
seines Zuges gegen Goa begriffen und begierig, noch vor Ablauf
seines Regiments die vor Tschaul den portugiesischen Waffen
zugefügte Niederlage und den Tod seines Sohnes zu rächen,
erklärte, er werde sein Amt nicht vor dem Schluß des laufenden
Jahres niederlegen, auch sei das Schiff, auf dem er, der von Portugal
ergangenen Weisung gemäß, zurückkehren solle, noch nicht
angelangt. Dieses Schiff aber war, wie bereits berichtet ist, an der
ostafrikanischen Küste gescheitert und untergegangen. Mißmuthig
wartend zog sich Albuquerque nach Kotschin zurück.
Kurz darauf, am 12. December 1508 brach Almeida mit neunzehn
Segeln gegen Norden auf; später stießen noch vier Schiffe zu ihm,
so daß seine Flotte nun dreiundzwanzig Schiffe mit 1600 Mann
Truppen zählte. Noch vor Ablauf des Jahres wurde die Stadt Dabul
erstürmt und entsetzlich verwüstet, so daß die Zerstörung dieser
Stadt im Orient noch lange mit Schaudern erzählt und sprichwörtlich
wurde als ein Beispiel unerhörter Vernichtung.
Erst am 2. Februar 1509 kam das Geschwader vor Diu an. Im
Hafen lagen die Flotten der Aegypter und des Statthalters von Diu,
Melek Eias, vereinigt; auch der Samudrin hatte eine Anzahl
bewaffneter Fusten zu Hilfe gesendet. Aber die drei Parteien trauten
einander nicht, besonders Melek Eias spielte eine zweifelhafte Rolle.
Am folgenden Tage drang Almeida in den Hafen ein und richtete
seinen Angriff lediglich auf die ägyptischen Schiffe. Eins nach dem
andern wurde geentert und versenkt, so daß der Flottenführer
Hussein nur mit Noth dem allgemeinen Verderben entrinnen konnte.
Er verließ heimlich sein Schiff, bestieg am Lande ein Pferd und jagte
flüchtig nordwärts nach Kambaya. Als die Schiffe von Diu und Kalikut
sahen, daß der Ausgang des Kampfes nicht mehr zweifelhaft blieb,
und daß man sie vorläufig schonen wollte, zogen sie sich bei Zeiten
zurück. Auch hatte sich Almeida dafür entschieden, Melek Eias vor
Diu nicht anzugreifen, obwohl derselbe die Hauptursache gewesen,
daß sein Sohn Lourenço gefallen war. Der Vicekönig mochte auch
befürchten, durch einen Angriff auf Diu den Oberherrn des Landes,
den König von Gudjerat, mit in den Krieg zu verwickeln. Ihm war vor
allem darum zu thun, die mohammedanischen Aegypter aus den
indischen Gewässern zu vertreiben; mit den einheimischen Fürsten
hoffte er dann schon wieder in ein freundlicheres Verhältniß treten
zu können. In diesem Bestreben kam ihm sogar das schlaue
Verhalten Melek Eias entgegen, welcher sich nicht entblödete, den
portugiesischen Sieger wegen seines Erfolges zu beglückwünschen
und ihm seine Dienste anzubieten. Almeida begnügte sich daher
auch, nur die Auslieferung der Portugiesen zu verlangen, die auf
dem Schiffe seines Sohnes zu Gefangenen gemacht waren.
Dieselben wurden auch alsbald durch Melek Eias zurückgesandt.
Dann kehrte der Vicekönig nach Kotschin zurück. Hier erneuerte
Albuquerque wiederum seine gerechte Forderung, ihm den
Oberbefehl zu übergeben; aber Almeida zögerte immer wieder, weil
das erwartete Schiff noch nicht angelangt sei. Erst als Fernão
Coutinho im Oktober 1509 von Portugal mit vierzehn Schiffen in
Kotschin einlief und bestimmten Befehl für den Wechsel des
Obercommandos mitbrachte, trat Almeida von seinem Amte zurück
und schiffte sich am 19. December ein. Aber er sollte die Heimat
nicht wieder sehen. Das Schiff ging an der Westküste von Südafrika,
in der Saldanhabai, vor Anker um Wasser einzunehmen. Dabei
verwickelte sich die Mannschaft in einen Kampf mit den Hottentotten
und 150 tapfere Streiter, darunter elf Hauptleute, welche in Indien
Wunder der Tapferkeit gethan, wurden sammt dem Vicekönig von
den nackten Wilden überwältigt und erschlagen. „Nie,“ so klagt de
Barros, „erlitten die portugiesischen Waffen ein größeres
Unglück!“[106]
Almeida war ein tüchtiger Soldat, ein uneigennütziger, sittlich
reiner Charakter und daher auch bei jedermann beliebt und
hochgeachtet. Er sorgte väterlich für die Soldaten, aber er stellte
auch an ihre Leistungen hohe Ansprüche. Ihre materielle Lage
suchte er zu heben, denn ihr Sold war gering, und daher kamen
häufig Desertionen vor. Der König war nur darüber unzufrieden, daß
Almeida mit seinen Belohnungen nicht geizte. Dieser aber sah sich
vielfach durch die von Portugal ergangenen Befehle in seinen
Unternehmungen gekreuzt. Namentlich tadelte er das Verfahren der
portugiesischen Verwaltung, ihm Höflinge zu senden, die nichts
leisteten, aber in Indien alsbald höhere Stellen beanspruchten, ohne
sie verdient zu haben. Dem König schrieb er: „Ich rathe Euch, dem
Vicekönig, den Ihr sendet, mehr Vertrauen zu schenken, als mir zu
Theil geworden ist, und keine Befehle zu erlassen, ehe Ihr Eure
Rathgeber in Indien gehört habt.“
Er wollte alle Macht auf die Beherrschung des Meeres an der
Westküste Indiens werfen und die Flotte nicht durch Operationen an
der afrikanischen oder arabischen Küste zersplittert sehen. Daher
seine Abneigung gegen Albuquerque, in welcher er durch die
abtrünnigen Capitäne desselben bestärkt wurde. Als ihm der König
befahl, Schiffe nach Malaka zu senden, erwiderte er, dazu habe er
noch keine Zeit, in Indien gebe es noch genug zu thun.
So handelte er stets nach einem festen Plane und ließ sich selbst
durch directe Befehle, die von Portugal an ihn ergingen, nicht davon
abbringen. Daß sein System mit ihm fallen würde, sah er voraus;
denn sein Nachfolger schlug ganz andere Bahnen ein und erweiterte
den Kampfplatz über die ganze Breite des indischen Oceans. In
trüber Stimmung, erhöht durch die Erinnerung an den herben
Verlust seines tapferen Sohnes, verließ der erste Vicekönig Indien
und fand auf afrikanischem Boden ein tragisches Ende.
7. Affonso d’Albuquerque, Generalcapitän und
Governador von Indien.
Nachdem Almeida Indien verlassen hatte, traf Albuquerque in
Gemeinschaft mit dem Marschall Coutinho seine Vorbereitungen,
Kalikut anzugreifen und den Samudrin zu züchtigen; denn König
Manuel hatte diesen Angriff dringlich befohlen. Fernão Coutinho
ergriff diese Gelegenheit, sich in Indien mit Kriegslorbeeren zu
schmücken, mit unverhohlener Freude. So wurde er des lästigen
Commandos über die Handelsflotte ledig. „Seine Vorfahren hätten
sich nicht mit Handel abgegeben, und er selbst habe auch keine
Neigung für solches Gewerbe.“ Er war durch und durch Soldat und
blickte mit Verachtung auf die Kriegsleistungen der Indier. Am Abend
des 2. Januar 1510 erschien die vereinigte Flotte vor Kalikut, sie
hatte, ungerechnet die indischen Hilfstruppen, gegen 2000
portugiesische Soldaten am Bord. Der Samudrin selbst war
wahrscheinlich auf einem Feldzuge gegen einen benachbarten
Fürsten von seiner Hauptstadt fern, als die drohende Macht vor
seiner Residenz erschien. In der Nähe der Stadt, nicht fern vom
Meere, lag auf einer Anhöhe das Schloß des Fürsten, welches in der
Zwischenzeit durch Erdwälle verschanzt und in eine Festung
umgewandelt war. Hieher mußte sich der erste Angriff richten, wenn
die unbefestigte Stadt selbst dauernd gewonnen werden sollte.
Coutinho forderte die Führung des ersten Treffens, er hoffte wohl
allein mit der feindlichen Streitmacht fertig werden zu können.
Albuquerque willigte nur ungern ein, weil er den Marschall als einen
Hitzkopf kannte, der mit den indischen Kriegslisten noch zu wenig
vertraut war und ohne viel Ueberlegung drauf los ging in der
Erwartung, schon beim ersten Waffengange seine Gegner in alle
Winde zu verjagen.
Als aber am Morgen des 3. Januar die Ausschiffung der Truppen
begann, zeigten sich die Nair doch so zäh im Widerstande und
überschütteten ihre Feinde mit einem solchen Hagel von
Geschossen, daß die Portugiesen bei ihrem Angriff sich zu theilen
beschlossen. So kam es, daß indem beide Feldherren verschiedene
Landungsplätze wählten, Albuquerque seine Leute eher ans Land
geworfen hatte und zum Sturm überging als sein Waffengefährte.
Nach einem erbitterten Kampf um den Wall, bei welchem schon viele
Streiter fielen, drang der Generalcapitän zuerst in die Schanzen ein,
ließ Feuer in die königlichen Häuser werfen und vertrieb die Indier
aus der festen Stellung. Coutinho sah sich dadurch um den
ersehnten Ruhm betrogen und nannte, vor Zorn und Schmerz
glühend, jenen ein um das andere Mal einen wortbrüchigen
Menschen, der anderen keine Ehre und Auszeichnung gönne.
Albuquerque blieb bei diesen Schmähungen kaltblütig und wies
darauf hin, daß man oft im Kriege gegen den vorgefaßten Plan
handeln müsse, wenn der günstige Augenblick es fordere. Auch sei
mit diesem ersten Erfolg der Sieg noch keineswegs entschieden. Der
Gegner sei zwar zurückgewiesen, aber seine Macht noch nicht
gebrochen. Allein Coutinho achtete nicht darauf, in blinder
Aufregung gebot er sofort den Angriff auf die Stadt. Hier wollte er
der erste sein und die Brandfackel in den großen königlichen Palast
schleudern. In einem entfernten Stadttheile lagen auf einem freien
Platze, von Mauern umgeben, die weitläufigen Gebäude des
Fürstensitzes. Trotz des Widerstandes drangen Coutinho und seine
Schaar durch Thor und Mauerlücken ein und legten Feuer an, worauf
die Indier zurückwichen. Albuquerque folgte, nachdem er vorsorglich
einen Theil seiner Mannschaft am Ufer zur Bewachung der Böte
zurückgelassen hatte, durch Kampf in den Straßen der Stadt
aufgehalten, langsam nach. Coutinho glaubte schon, im Besitze des
Palastes, sich des vollständigen Sieges erfreuen zu können, und
gestattete sorglos seinen Soldaten sich zu zerstreuen und die
königlichen Schätze zu plündern. Darauf hatten aber die Indier
gewartet; sie sammelten sich von neuem und gingen wieder zum
Angriff über. Sie umzingelten in hellen Haufen den Palast und
drangen endlich trotz der hartnäckigen Gegenwehr des
portugiesischen Hauptmanns, dem die Bewachung des einen Thores
übergeben war, wieder in den Hof ein und fielen über die zerstreuten
Portugiesen her. Albuquerque konnte nur mit Mühe bis in die Nähe
des Kampfplatzes vordringen und sandte Boten über Boten an den
Marschall, um ihn zu eiligem Rückzuge aufzufordern. Dieser aber
verachtete immer noch die drohende Gefahr und erwiderte, der
Generalcapitän möge nur ruhig den Abmarsch antreten, er selbst
werde folgen, wenn seine Mannschaft sich wieder gesammelt hätte.
Selbst von allen Seiten umdrängt, wich Albuquerque langsam
zurück. Der Rückzug ging durch einen Hohlweg, von dessen hohen
Rändern aus die Indier mit Wurfspießen, Pfeilen und Steinen die
Portugiesen überschütteten. Von Coutinho war er vollständig
abgeschnitten und konnte nur auf sich selbst Bedacht nehmen, da
seine Truppen sich weigerten, noch einmal den Versuch zu wagen,
sich bis zu dem Marschall durchzuschlagen. Albuquerque wurde im
Gewühl zuerst schwer am linken Arme verwundet, erhielt dann einen
Pfeilschuß in den Nacken und mußte endlich, als ihn ein mächtiger
Stein vor die Brust traf, besinnungslos fortgetragen werden. Der
Marschall aber fiel mit 80 Kampfgefährten. So endigte, durch die
Tollkühnheit Coutinho’s herbeiführt, dieser Angriff auf Kalikut als
vollständige Niederlage; und hätte nicht Albuquerque am Ufer die
Schiffe mit starker Mannschaft bewachen lassen und wäre die See
nicht ruhig gewesen, so hätte der Ausgang des Tages für die
Portugiesen dermaßen verhängnißvoll werden können, daß ihre
ganze Machtstellung in Indien zweifelhaft geworden wäre.
Nach dem Fall Coutinho’s erhielt Albuquerque auch das
Commando über dessen Schiffe und begab sich nach Kotschin. Kaum
war er von seinen Wunden genesen, so sann er auf neue
Kriegspläne. Ende Januar 1510 waren 21 Schiffe ausgerüstet und
bemannt. Es schien, als wollte er, dem Befehl seines Königs gemäß,
nach dem rothen Meere segeln, um dort einer neuen ägyptischen
Flotte entgegenzutreten. Aber der Generalcapitän hatte seine
wahren Absichten nur geheim gehalten, um desto erfolgreicher
einen unerwarteten Schlag zu thun. Er hatte sein Absehen auf G o a
gerichtet, welches so ziemlich auf der Mitte der Westküste Vorder-
Indiens und dazu in der Nähe der Andjediven gelegen, wohin die
von Afrika herübersteuernden Schiffe meistens ihren Lauf richteten,
besonders günstig erschien, um von hier aus das westliche Meer und
die Straßen nach Ormuz und Aden zu beherrschen. Goa lag auf einer
flachen, aber nicht feuchten Insel, welche durch die gemeinsame
Arbeit mehrerer von den Westghats herabkommender Flüsse aus
dem continentalen Ufersaume gleichsam herausgeschnitten war. Die
Insel ist von Osten nach Westen ungefähr drei Meilen lang und von
Norden nach Süden zwei Meilen breit. Das höhere, hügelige Land
läuft gegen die See in eine Spitze aus. Die gegen das Meer
bedeutend erweiterten Mündungen gestatteten den Zutritt der Flut
um die ganze Insel. Die alte Stadt lag auf der Südseite, die neue
Stadt war ungefähr vierzig Jahre vor der Ankunft der Portugiesen in
Indien von Mohammedanern gegründet, die von der etwa 18 Meilen
weiter südlich gelegenen Stadt Onor hieher geflüchtet und sich unter
der Führung Melek Husseins hier angesiedelt hatten. Die Canäle,
welche die Insel und Stadt umziehen, sind voll von Krokodilen und
durften daher, wenn sie zur Ebbezeit durchwatbar werden, nur mit
Vorsicht durchschritten werden. Alt-Goa ist jetzt fast ganz verlassen,
nur Geistliche und Mönche wohnen noch dort zwischen den
großartigen Ruinen zahlreicher Kirchen und Klöster. Der Hafen der
neuen Stadt ist wegen seiner wunderbaren landschaftlichen
Schönheit hoch gepriesen.
Die Zeit zum Angriffe war von Albuquerque insofern sehr günstig
gewählt, als der damalige Beherrscher Adil-Schah, der König von
Bidjapur, nur wenig Truppen in der Stadt unterhielt. Die Bevölkerung
des Hafenplatzes und die militärische Besatzung standen in ihren
Interessen einander gegenüber. Als Albuquerque mit seiner Flotte
vor der Einfahrt zum Hafen angelangt war, schickte er seinen Neffen
Antonio de Noronha mit bewaffneten Böten voraus, um das
Fahrwasser in den Canälen zu untersuchen. Bei einer Biegung des
Flusses sahen sich die Portugiesen plötzlich der Citadelle von Pandjin
gegenüber, welche nach der Seeseite die Stadt deckte. Unverweilt,
ehe die Besatzung sich sammelte und die Kanonen bedienen konnte,
gingen die Portugiesen zum Sturm über und drangen durch die
Schießscharten und über den Wall in die Citadelle, welche, nachdem
ihr Befehlshaber verwundet worden, von der Besatzung aufgegeben
wurde. Der Generalcapitän hörte in der Ferne das Kampfgetöse und
gab sofort Befehl, mit allen Truppen vorzugehen, fand aber bei
seiner Ankunft den befestigten Platz bereits in den Händen der
Seinigen. Die Truppen des Adil-Schah zogen sich auch aus der Stadt
zurück, und ihr Anführer empfahl den Bürgern, sich ohne Gegenwehr
zu ergeben, denn die abendländischen Feinde seien unwiderstehlich.
So erschien schon am nächsten Tage eine Gesandtschaft von
Bürgern vor Albuquerque und bot gegen Sicherheit des Lebens und
Eigenthums die Unterwerfung an. Dieselbe wurde angenommen,
doch wurde das vorhandene Kriegsmaterial als Beute erklärt,
Albuquerque zog mit seinen Truppen in die Stadt und nahm den
Palast des Statthalters in Besitz. Die eroberte Citadelle wurde
verstärkt, und die Flotte ging im Hafen vor Anker. Die Schiffe wurden
zum Theil sogar abgetakelt, damit während der Regenzeit das
Tauwerk nicht zu sehr litte; denn Albuquerque gedachte längere Zeit
in Goa zuzubringen.
Inzwischen aber sammelte der Fürst des Landes ein größeres
Heer und rückte zum Entsatz heran. Die Portugiesen konnten die
unbefestigte Stadt nicht behaupten, und zogen sich auf die Schiffe
zurück; aber gedeckt durch die Kanonen der Citadelle blieb die Flotte
noch im Hafen liegen.
Gegen Ende Mai trafen die Indier Vorkehrungen, dem Feinde den
Rückzug abzuschneiden, sie versenkten Schiffe in dem unteren
Theile des Canals, der zur See führte, und ließen brennende Flöße
den Fluß hinabtreiben, um die portugiesischen Fahrzeuge in Brand
zu setzen. Bei dieser drohender werdenden Gefahr mußte sich
Albuquerque entschließen, vorläufig das Errungene wieder
aufzugeben. Aber auch der Rückzug war mit bedeutenden
Schwierigkeiten verknüpft. Einzeln mußten seine Schiffe zwischen
den versenkten Fahrzeugen hindurch geführt werden und waren
dabei unausgesetzt dem Feuer der Feinde preisgegeben, welche an
beiden Seiten Schanzen aufgeworfen hatten. Diese mußten also erst
erstürmt werden, um das Feuer der Gegner zum Schweigen zu
bringen. Und selbst als dieses gelungen war, hemmte noch das
seichte Wasser über der Barre das Auslaufen der Flotte in die See
eine längere Zeit. Von allen Hilfsmitteln des Landes abgeschnitten,
trat Mangel an Lebensmitteln und Wasser ein, der Mann bekam
täglich nur noch vier Unzen Zwieback, und auf einigen Schiffen sah
man sich sogar gezwungen, Jagd auf Ratten zu machen. Jeder
Tropfen Wasser mußte mit Blut erkauft werden. Antonio de Noronha
wurde durch einen Pfeilschuß verwundet und starb am dritten Tage,
ein herber Verlust für Albuquerque, welcher seinen heldenmüthigen
Verwandten sehr hoch schätzte. Zwar verrichteten noch manche
Wunder der Tapferkeit und gewannen dadurch die Bewunderung
ihrer Feinde; aber bei vielen griff Mißmuth und Verzagtheit dergestalt
um sich, daß sie in ihrer Verzweiflung und von Durst und Hunger
gequält, desertirten. Albuquerque bewies auch in dieser Noth seine
Seelenstärke, feuerte seine Schaar durch Trostesworte immer von
neuem an und theilte mit ihnen alle Entbehrungen und Gefahren.
Erst im August gelang es ihm, über die Barre hinwegzukommen und
die See zu gewinnen. Es war die zweite Niederlage, die er erlitten;
aber sein Muth war nicht gebrochen und seine Absichten auf Goa
behielt er im Auge. Vorläufig allerdings mußte er seinen Truppen
Ruhe gönnen und wandte sich daher mit seiner Flotte südwärts zu
dem befreundeten Hafen nach Kananor. Auf dem Wege dahin
stießen vier Schiffe des Diogo Mendes de Vascogoncellos zu ihm, die
von Portugal aus den Auftrag erhalten hatten, einen Streifzug nach
dem berühmten Markte von Malaka zu unternehmen, weil man
damals im Mutterlande noch nicht erfahren hatte, daß, wie wir
später sehen werden, Lopez de Sequeira bereits jener Handelsstadt
einen Besuch abgestattet hatte. In Kananor stieß dann noch ein
zweites Geschwader zu ihm, welches unter der Führung des Capitän
Gonçalo de Sequeira mit sieben Handelsschiffen und frischen
Truppen im März von Lissabon ausgelaufen, aber ein Schiff an der
afrikanischen Küste verloren hatte.
Dieser Zuwachs an Macht bestärkte den Generalcapitän, einen
neuen Angriff auf Goa zu machen. Vascogoncellos erklärte sich
bereit, an diesem Zuge theilzunehmen, da der ihm gewordene
Auftrag bereits erledigt sei. Gonçalo de Sequeira dagegen glaubte
die Theilnahme ablehnen zu müssen, weil einerseits die meisten
Schiffe Privatrhedern gehörten, welche nur, um Handel zu treiben,
gekommen wären, und anderseits ihre nächste Hilfe dem Fürsten
von Kotschin gehöre, welcher von einem Nebenbuhler, den der
Samudrin mit Truppen unterstützte, hart bedrängt werde. Um diesen
zweiten Grund sofort zu erledigen, ging Albuquerque mit einigen
Schiffen und Mannschaften nach Kotschin und stellte die Ruhe und
gesetzmäßige Regierung in kurzer Frist wieder her. Dann berief er in
dieselbe Stadt einen Kriegsrath sämmtlicher Hauptleute, um sie für
seinen Plan zu gewinnen.
Dieser Rath trat am 12. October 1510 zusammen. Der
Generalcapitän legte der Versammlung die Frage vor, ob sie nicht
seinem Plane zustimmen wolle, während die Handelsschiffe in
Kotschin ihre Gewürzfrucht einnähmen, alle verfügbare Mannschaft
mit seinen Truppen zu vereinigen, um Goa von neuem zu erobern.
Diese Berathung ist in der späteren Zeit von außerordentlichen
Folgen gewesen. Hier war es, wo F e r n ã o d e M a g a l h ã e s sich
entschieden für die Ansicht Sequeira’s aussprach und Albuquerque
dadurch auf das empfindlichste verletzte: V o r dem 8. November
werde man bei den augenblicklich herrschenden Gegenwinden
schwerlich mit der Flotte vor Goa erscheinen können (—
Albuquerque kam in der That erst am 24. November dahin —); dann
werde aber die Rückfahrt der Handelsschiffe dermaßen verzögert,
daß man entweder der am Kriegszuge betheiligten Mannschaft
später keine Zeit lassen könne, ihre eigenen Angelegenheiten zu
betreiben, um sich zur beschleunigten Abreise einzurichten, oder es
werde der günstige Monsun verpaßt.
Albuquerque erklärte dagegen aufs bestimmteste, er werde den
nächsten Tag aufbrechen, er werde auch niemanden gegen seinen
Wunsch zwingen mitzugehen, aber er wünsche deshalb diesen Zug
so bald als möglich zu unternehmen, um mit der demnächst
abzufertigenden Handelsflotte seinem Könige eine erfreuliche
Botschaft aus Indien übersenden zu können.
So blieben die A n s i c h t e n getheilt und der Generalcapitän
gewann nur einen Theil der Stimmen für sich. Der Widerspruch
Magalhães legte den Grund zu dem ungünstigen Urtheile, welches
Albuquerque in einem Berichte an den König über jenen fällte, und
welches wohl die Ursache war — denn wir kennen keine andere —
daß Manuel späterhin, als Magalhães um eine bescheidene Erhöhung
seiner wohlverdienten Pension nachsuchte, die Gewährung dieser
Bitte verweigerte, wodurch der Bittsteller sich so sehr verletzt und
zurückgesetzt fühlte, daß er seinem Vaterlande den Rücken kehrte
und auf spanischen Schiffen seine berühmte, ja die berühmteste
aller Weltreisen unternahm. Magalhães scheint bald nach dem
Conflicte mit Albuquerque Indien verlassen zu haben, denn hier sah
er von da an sich aller Gelegenheit beraubt, Aufzeichnung und Ruhm
zu gewinnen.
Die portugiesische Flotte, 23 Segel stark, erschien mit 1600 Mann
Soldaten am 20. November vor Goa. Gaspar de Paiva hatte, mit drei
Schiffen vorausgesandt, schon einige Zeit vor dem Hafen gekreuzt
und kein Schiff weder hinein, noch heraus gelassen. In der Stadt war
man auf einen heißen Kampf gefaßt. Ohne Zeitverlust ging
Albuquerque zum Angriff über, schon am 25. November wurde die
Citadelle erstürmt und die Insel besetzt; aber gewarnt durch die
schlimme Erfahrung von Kalikut duldete er nicht, daß die Soldaten
sich zerstreuten. Dann wurde auch die Stadt selbst von zwei Seiten
angegriffen und erobert. Viele Einwohner verließen die Stadt, aber
bei ihrer hastigen Flucht sollen in den seichten Durchgängen der
Canäle mehrere Tausende umgekommen sein. Alles was
mohammedanisch war, wurde in dem eroberten Platze ohne Gnade
niedergemacht: Männer, Weiber und Kinder. Eine Moschee, mit
Gefangenen angefüllt, wurde den Flammen übergeben, so daß alle
in dem Gotteshause Befindlichen ihren Tod fanden.
Dann ließ Albuquerque ein starkes steinernes Kastell erbauen und
gab ihm, dem König zu Ehren, den Namen Manuel. Im Vertrauen auf
die dadurch gebotene Sicherheit ließen sich bald, neben den
befreundeten Indiern, welche nach dem Sturm zurückkehrten, auch
Portugiesen dauernd an diesem Platze nieder, welcher von den
Siegern zum Mittelpunkte der portugiesischen Macht in Indien
erhoben wurde.
Der Fall Goa’s machte auf die Fürsten der Nachbarschaft einen
bedeutenden Eindruck, weshalb sie sich beeilten, die Freundschaft
der neuen Herren zu gewinnen. Der König von Kambaya gab den
Neffen des Generalcapitäns Affonso de Noronha, der sich in seiner
Gefangenschaft befand, nicht nur ohne Bedingung los, sondern
erklärte sich auch bereit, den Bau einer Festung in Diu zu gestatten.
Es erschienen Gesandtschaften von Gudjerat, von Kalikut, selbst aus
dem Binnenlande von Bisnaga, alle bezeugten ihre Friedensliebe und
wünschten bezüglich eines friedlichen Handelsverkehrs in
Unterhandlung zu treten. Da indeß der Samudrin den geforderten
Bau einer portugiesischen Citadelle nicht zugeben wollte, so
zerschlug sich mit diesem Fürsten die Verhandlung. Emir Hussein,
welcher damals in Kambaya sich befand, kehrte nach Kairo zurück,
da er alle Hoffnung aufgegeben hatte, in Indien noch wieder zum
Siege zu gelangen, und der Sultan von Aegypten ließ gleichfalls mit
dem weiteren Bau einer Flotte innehalten.
So war die Wirkung der Eroberung Goa’s nach allen Seiten eine
tiefgehende. Goa hatte nicht blos eine dauernde Besatzung von 400
Mann in der Burg, sondern wurde eine portugiesische Stadt, sie war
Eigenthum ihres Königs, und die Fürsten Indiens mußten diesen
staatlichen Besitz anerkennen. Und daß die Portugiesen die neuen
Verhältnisse in Goa in ähnlicher Weise auffaßten, beweist die
Thatsache, daß bald darauf eine Münzstätte in der Stadt errichtet
wurde, wo nicht blos neues Geld geprägt, sondern auch alles
indische Geld, wenn es allgemein gültig sein sollte im Verkehr, mit
einem portugiesischen Stempel versehen wurde. Aber der
portugiesische Feldherr war nicht gewillt, von Goa aus die friedliche
Entwicklung seiner Macht zu leiten. Seine Blicke schweiften bereits
über Vorder-Indien hinaus nach Malaka, welches als bedeutendster
Gewürzmarkt Hinter-Indiens galt, und ohne dessen Besitz die
Portugiesen nie das Monopol erwarben; denn von Malaka aus gingen
die Handelsschiffe direct, mit Umgehung Vorder-Indiens, nach dem
rothen Meere. Sollte also Goa gehoben und zum Mittelpunkte des
Verkehrs in Vorder-Indien gemacht werden, dann konnte dies nur
erreicht werden, wenn Malaka gleichfalls in portugiesischen Besitz
übergegangen war.
Diogo Lopez de Sequeira war der erste gewesen, der jenen
fernen Handelsplatz erreicht hatte. Er war 1508 von Portugal mit vier
Schiffen abgegangen, hatte unterwegs Madagascar besucht und
langte im Frühjahr 1509 in Kotschin an. Der Vicekönig Almeida gab
ihm noch ein fünftes Schiff, auf welchem Francisco Serrão, dessen
abenteuerliche Reise nach den Molukken uns später beschäftigen
wird, und Fernão de Magelhães dienten. Am 8. September desselben
Jahres war Sequeira wieder von Kotschin aufgebrochen, war an
Ceylon und den Nikobaren vorüber nach Nordsumatra gesteuert, wo
er die Landschaft Pedir besuchte, denn Sumatra lieferte schon
damals am meisten Pfeffer, und war endlich glücklich in Malaka
angelaufen. Die Mauren gaben sich auch hier sofort alle erdenkliche
Mühe, die Ankömmlinge zu verdächtigen, trotzdem wurden die
Portugiesen wohlwollend aufgenommen, wenn auch der Sultan
Mahmud durch seine Grausamkeit berüchtigt war und nicht blos
seinen Bruder, sondern sogar seine Gemahlin hatte hinrichten lassen.
Die Chinesen kamen den Portugiesen zuerst in freundlicher Weise
entgegen. Es war das erstemal, daß man mit den Söhnen aus dem
Reiche der Mitte zusammentraf. Die weiße Hautfarbe dieser Leute
aus dem Osten, ihre unbefangene Art, sorglos zu den fremden
Schiffen wie zu den asiatischen heranzurudern und den Kleinhandel
zu eröffnen, selbst manche ihrer Sitten und ihre Tracht wollte mehr
ans Abendland, als an den fernsten Osten gemahnen. Man darf nicht
vergessen, daß die Chinesen damals noch keinen Zopf trugen.
Damian de Goes (a. a. O. S. 300) fand eine Aehnlichkeit mit
vlaamischen oder niederdeutschen Gewohnheiten, und ähnlich
äußert sich auch Barros.[107] Man fand bei ihnen nicht den
hemmenden Kastengeist, denn sie scheuten sich ja auch nicht, mit
den Portugiesen aus e i n e r Schüssel zu essen. So war es natürlich,
daß Europäer und Chinesen, beide in der Stadt Fremdlinge, sich
einander freundschaftlich näherten, und daß diese ihren neuen
Geschäftsfreunden die Warnung zukommen ließen, den Malayen
nicht zu sehr zu trauen. Darum ging auch der portugiesische Capitän
nicht selbst zur Audienz, sondern entsendete den Jeronimo Texeira,
welcher indeß eine gute Aufnahme fand und vom Sultan ein
Lagerhaus angewiesen erhielt, um von da aus den Handel mit den
einheimischen Kaufleuten zu eröffnen. Die Portugiesen gingen dann
ungehindert in der Stadt umher, waren aber leider unbedachtsam
genug, sich auch nach der Kriegsflotte des Sultans umzusehen, was
die Mohammedaner, und unter ihnen namentlich der abgefeimte
Schatzmeister, sofort zu ihrem Vortheile ausbeuteten, um die
Fremden als Spione zu verdächtigen. Mit Einverständniß des Sultans
wurde ein Plan entworfen, die Portugiesen zu vernichten. Zuerst
hoffte man den Anführer und einige der vornehmeren Offiziere bei
einem Gastmahl überfallen und ermorden zu können, aber Sequeira
lehnte die Einladung ab und entschuldigte sich mit Krankheit. Dann
wollte man die portugiesische Mannschaft in der Stadt, an
verschiedenen Orten, wohin man sie gelockt, um ihnen Lebensmittel
zu verkaufen, einzeln überfallen, inzwischen aber auch eine Anzahl
von kleineren Schiffen bereithalten, um das Geschwader der
Fremden anzugreifen, wenn es von Mannschaft halb entblößt sei.
Glücklicherweise gelang der Verrath nur zum Theil. Die Wache auf
den Schiffen machte, als sie die Unruhe in der Stadt gewahrte,
rechtzeitig Lärm, sodaß die Mannschaft an Bord augenblicklich zur
Vertheidigung bereit war. Aber etwa 30 Portugiesen, die sich am
Hafen und in der Stadt befanden, wurden theils getödtet, theils
gefangen. Francisco Serrão, welcher sich in der Nähe des
Landungsplatzes aufhielt, konnte sich nur mit einigen Matrosen
retten, die übrigen mußte man vorläufig ihrem Schicksale
überlassen, denn Sequeira fühlte sich keineswegs stark genug, die
volkreiche Stadt anzugreifen; er begnügte sich damit, einige
feindliche Schiffe in den Grund zu bohren und kehrte dann nach
Vorder-Indien zurück. Als das Gerücht von der zweiten Eroberung
Goa’s auch bis nach Malaka gedrungen war, ließ der Hafenmeister
(Schahbender) den neunzehn noch am Leben befindlichen
gefangenen Portugiesen eine bessere Behandlung zutheilwerden;
ihre Freiheit erhielten sie aber erst wieder, nachdem Albuquerque die
Stadt erobert hatte.
An seinen Plan, gegen Malaka zu ziehen, wurde der
Generalcapitän bald nach der Besitzergreifung von Goa in
unangenehmer Weise erinnert, als der Capitän Mendes de
Vascogoncellos, dessen kleines Geschwader ursprünglich nach
Malaka bestimmt war, von dem Oberfeldherrn sich Urlaub erbat, um
seinen Auftrag auszurichten. Albuquerque zögerte mit der
Abfertigung, weil er entweder der Ueberzeugung war, daß ein so
kleines Geschwader nicht die genügende Sicherheit auf Erfolg biete,
oder weil er selbst erst noch mehr Mittel aufbieten wollte.
Vascogoncellos wollte daher heimlich entweichen, ging bei Nacht mit
seinen Schiffen über die Barre von Goa in See, wurde aber von
einigen nachgesandten Böten eingeholt und sah sich genöthigt, dem
strengen Befehl Albuquerque’s, zurückzukehren, Folge zu leisten. Er
selbst blieb längere Zeit in Goa in Gefangenschaft, ein Steuermann
aber und der Lotse wurden zur Strafe für diese Flucht an der Rae
aufgeknüpft.
Der Generalcapitän wäre am liebsten selbst nach Malaka sofort
aufgebrochen; allein dem stand ein Befehl Don Manuels entgegen,
einen Zug nach dem rothen Meere zu unternehmen, um diesen
Handelsweg endlich für die Mohammedaner zu schließen. Er lief
auch wirklich mit 23 Schiffen aus, sah sich aber durch widrigen
Monsun zuerst aufgehalten und dann ganz an die Küste
zurückgetrieben, so daß er wieder in Goa einlaufen mußte. Derselbe
Monsun aber, welcher die Fahrt nach NW. nicht gestattete,
begünstigte eine Expedition nach SO. und so entschloß sich
Albuquerque kurzer Hand mit der schlagfertigen Flotte vor Malaka zu
ziehen und sie für ihren Verrath an Sequeira zu strafen. Es war noch
im Frühjahr 1511, als die Flotte von neunzehn Segeln, mit 800
Portugiesen und 600 indischen Hilfstruppen von Kotschin nach
Malaka abging. Den Feldherrn begleiteten Antonio d’Abreu und
Francisco Serrão, die späteren Entdecker der Molukken und Fernão
Peres d’Andrade, einer der ersten Chinafahrer.
Das Gebiet von Malaka war ursprünglich von Siam abhängig
gewesen; die in früherer Zeit berühmte Hafenstadt Singapur war
aber hinter Malaka zurückgetreten, seitdem sich im 15. Jahrhundert
der Islam in diesem Gebiete verbreitet hatte, denn in Malaka
herrschte der Glaube Mohammeds vor. Aber die ehemaligen
Statthalter hatten sich seit fast 100 Jahren zu selbstständigen Herren
aufgeworfen. Durch geschickte Begünstigung und Ausbeutung des
Handels zu großem Reichthum gelangt, verwandte Mahmud seine
bedeutenden Mittel auf die Gründung einer Kriegsflotte, welche ihm
den Besitz des Hafens und die Herrschaft über die See sichern
mußte. Nun dehnten sich die Handelsbeziehungen noch weiter aus,
denn die Hauptnationen waren in freier Weise durch Berufsbeamte
im Handel gedeckt. Diese Schahbender (Hafenmeister) vertraten
China, Java, Kambaya und Bengalen. Die Handelsverbindungen
reichten bis nach Japan, und der Platz wurde von allen
umwohnenden Völkern besucht, nur nicht von den Siamesen, die
sich immer noch mit dem Sultan auf Kriegsfuß befanden und ihren
frühern Verlust nicht verschmerzen konnten. Das Königreich Malaka
erstreckte sich etwa 100 Meilen an der Küste hin, reichte aber
nirgends über 10 Meilen weit ins Binnenland.
Die Stadt liegt sehr günstig an der Grenze verschiedener
Monsune, denn in den chinesischen Gewässern herrschen andere
Winde als im bengalischen Meere, daher sich hier ein natürlicher
Sammelplatz für Araber, Inder und Chinesen bot. Die Häuser des
Handelsplatzes dehnten sich eine Meile am Wasser hin, — es ist der
Canal, welcher die hinter-indische Halbinsel von Sumatra scheidet.
Ein Fluß trennte die Häusermenge in zwei Theile, aber eine Brücke
verband wiederum beide Hälften. Albuquerque, welcher denselben
Weg eingeschlagen hatte wie Sequeira, langte am 1. Juli vor Malaka
an, bereits in Pedir auf Sumatra waren acht Portugiesen, die noch in
Malaka gefangen gewesen waren und die Flucht ergriffen hatten, zu
ihm aufs Schiff gekommen. Von ihnen erfuhr er auch, daß der
Hauptanstifter des Verrathes, der javanische Hafenmeister, eine
Intrigue gegen den Fürsten angesponnen und seine Verschwörung
mit dem Leben bezahlt hatte; er erfuhr ferner, daß Sultan Mahmud
8000 Geschütze besitze, um die lange, dem Meere zugekehrte Seite
kräftig vertheidigen zu können, daß er 30,000 Mann Soldaten und
selbst Kriegselephanten zu seiner Verfügung habe. Albuquerque ließ
sich durch die großen Zahlen nicht schrecken, sondern forderte ohne
Umschweife die Auslieferung der noch zurückbehaltenen
Gefangenen. Eine sofortige Erledigung würde im Orient als Feigheit
angesehen sein; der Sultan weigerte sich also, ohne weiteres darauf
einzugehen. Als Antwort darauf ließ der portugiesische Admiral die
Häuser am Strande und die Schiffe im Hafen in Brand stecken. Dann
gab man die Gefangenen frei und unter ihnen auch den
Handelsfactor Ruy d’Araujo, einen Freund Albuquerque’s.
Man war in der Stadt zu einem friedlichen Abkommen geneigt,
aber die allzuhohen Forderungen der Portugiesen trieben zum
Widerstande. Albuquerque verlangte nicht blos Schadenersatz für
Sequeira, sondern auch noch 300,000 Cruzados Kriegskosten und
überdies die Einwilligung in den Bau eines Kastelles.
Im Rathe des Fürsten von Malaka, des alten Mohammed, waren,
als diese Forderungen bekannt wurden, die Meinungen getheilt.
Diejenigen, welche besonders den Handel nicht geschädigt sehen
wollten, empfahlen Frieden und Geldzahlung, die andern, welche
fürchteten, durch Zugeständnisse das Ansehen des Fürsten zu
erniedrigen, forderten bewaffneten Widerstand. Mahmud überließ
die Leitung seinem Sohne, und dieser hoffte, gestützt auf eine
Heeresmacht von 30,000 Mann, auf das zahlreiche Geschütz und
seine Kriegselephanten, den Angriff abschlagen zu können. Aber auf
die fremden Kaufleute in der Stadt war kein Verlaß, selbst der
javanischen Truppen war man nicht ganz sicher. Es war
vorauszusehen, daß der feindliche Admiral, sobald er die Lage der
Stadt und ihre Gruppirung richtig erkannt habe, seine Angriffe auf
den gefährlichsten Punkt, auf die Brücke richten werde, welche die
beiden Stadttheile mit einander verbindet. Denn wer sich der Brücke
bemeisterte, war leicht auch Herr in der Stadt. Diese
Verbindungsbrücke wurde darum verschanzt und stark mit Kanonen
besetzt; aber trotzdem richtete, nach dem Rathe des Ruy d’Araujo,
welcher bei seinem längeren unfreiwilligen Aufenthalt die Wichtigkeit
dieses Punktes erkannt hatte, Albuquerque grade hieher seine ersten
Angriffe. In der Morgendämmerung des St. Jacobstages, 25. Juli,
gingen die Portugiesen in zwei Abtheilungen gegen die Stadt vor.
Albuquerque mit seiner Schaar stieg in der Nähe der Brücke ans
Land, João de Lima mit der zweiten Truppe weiter östlich bei einer
steinernen Moschee, welche nicht fern vom fürstlichen Palaste lag.
Wenn ihm der Angriff gelänge, sollte er sich auch gegen die Brücke
wenden. An beiden Orten ward mit großer Hartnäckigkeit gekämpft.
Die Malayen bewiesen sich tapfer, schossen vergiftete Pfeile und
brauchten im Nahkampf den Kries. Sie fochten in einzelnen Haufen
unter Anführung eines Hauptmannes. Albuquerque stürmte die
Brücke und trieb die Malayen mit gefällten Lanzen nach der Vorstadt
zu. João de Lima hatte einen schweren Stand und konnte nicht so
rasch vordringen, er sah sich sogar genöthigt, persönlich am Kampfe
gegen die Kriegselephanten theilzunehmen, welche dann auch,
durch Lanzenstiche verwundet, auf die eigenen Truppen
zurückgetrieben wurden. Dann erst erreichte er die Brücke und
vereinigte sich mit dem Oberfeldherrn. Von den Dächern der
nächsten Häuser wurde aber der Kampf noch fortgesetzt, bis man
die umliegenden Gebäude in Brand gesteckt hatte und so die Feinde
vertrieb. Allein von der Waffenarbeit erschöpft und fortwährend, bei
dem Versuch, die Brücke durch Vertheidigungswerke zu sichern,
durch erneute Angriffe der Malayen beunruhigt, sah Albuquerque
bald die Unmöglichkeit, diesen wichtigen Platz auf die Dauer zu
behaupten. Er gab also den Befehl zum Rückzug und zog sich auf
die Flotte zurück. Einige seiner Hauptleute meinten nun zwar,
nachdem der Sultan für die erste Verrätherei genügend gestraft sei,
solle man mit günstigen Fahrwinden nach Vorder-Indien
zurückkehren, denn an eine dauernde Besetzung dieses entfernten
Platzes sei doch wohl nicht zu denken; allein sie wurden von der
Mehrzahl überstimmt, welche sich für eine Fortsetzung des Kampfes
entschied.
Während der Vorbereitungen zum zweiten Angriffe hatte
Mahmud allerorten neue Verschanzungen aufwerfen und mit
Kanonen besetzen lassen, in den Straßen waren Minen und
Fußangeln gelegt, um die Feinde bei ihrem Einbruche in die Stadt
aufzuhalten oder zu vernichten. Am 10. August griff Albuquerque die
Brücke zum zweitenmale an und obwohl man dieselbe hartnäckig
vertheidigte, wurde sie doch endlich erobert und die malayischen
Truppen gegen die steinerne Moschee hin vertrieben, wo sich in
Gegenwart des Sultans das letzte verzweifelte Handgemenge
entspann. Das Quartier der Kaufleute, darunter zuerst die Peguaner,
begab sich alsbald unter den Schutz des Eroberers, aber die östliche,
höher gelegene Stadt wurde nur langsam von den Malayen geräumt.
Neun Tage dauerte der kleine Kampf in den Straßen noch fort, bis
diese endlich von den eingeborenen Truppen aufgegeben wurden.
Den Mauren wurde kein Pardon gegeben, denn die Mohammedaner
waren auch hier die erbittertsten Gegner gewesen. Als Lohn für ihre
Arbeit gestattete Albuquerque seinen Leuten, die Stadt drei Tage
lang zu plündern. Dreitausend Kanonen fielen dem Sieger in die
Hände. Zum Bau einer steinernen Burg wurden die Steine der im
Kampf theilweise zerstörten Moschee verwendet, und weiteres
Baumaterial aus den in der Nähe gelegenen alten Fürstengräbern
genommen. In der Burg erhob sich ein fünf Stockwerke hoher, mit
Blei gedeckter Thurm. Albuquerque gab ihr den Namen Famosa.
Auch eine Kirche wurde errichtet und das Dach dazu von einem
königlichen Grabmal genommen.
Um den Handel wieder zu beleben und das Vertrauen in die
neuen Verhältnisse zu wecken, wurden eingeborene Schahbender
(Hafenmeister) ernannt, welche die handeltreibenden Nationen zu
vertreten hatten. Um den Marktverkehr zu ordnen, ließ Albuquerque
goldene und silberne Münzen prägen, denn unter den früheren
Herrschern hatte es nur zinnerne Münzen gegeben. Die großen
Silbermünzen hießen Malaquezes, die Goldmünzen, zu 1000 Realen,
Catholicos. Durch diese zweckmäßigen Einrichtungen wurde der
Handel bald wieder gehoben, und fremde Handelsschiffe liefen
wieder in den Hafen ein.
Mit den großen Staaten Ostasiens suchte Albuquerque in
friedliche, freundschaftliche Beziehungen zu treten. Durch die
Vertreibung des mohammedanischen Herrschers war er nur an die
Stelle eines fremden Eindringlings getreten, welcher sich die
Freundschaft der fürstlichen Nachbaren nicht erworben hatte; er
hoffte also mit Recht, nicht als Feind der eingeborenen Dynastien
betrachtet zu werden. Nach allen Seiten wurden Botschafter
abgeordnet. Auf einer chinesischen Dschunke, welche nach Siam
ging, segelte Duarte Fernandez, welcher mit Ruy Araujo gefangen
gewesen war und in Malaka malayisch gelernt hatte, mit nach Siam.
Er war der erste Portugiese, welcher diesen mächtigen hinter-
indischen Staat betrat. Er sollte dem Könige von Siam die Eroberung
von Malaka melden und zugleich die officielle Erklärung abgeben,
daß die Kaufleute des Landes sich des besonderen Schutzes der
Portugiesen erfreuen sollten und in Malaka’s Hafen willkommen sein
würden. Fernandez wurde am siamesischen Fürstenhofe zu
Ajuthia[108] wohlwollend aufgenommen, man zeigte ihm unter
anderen Merkwürdigkeiten auch einen weißen Elephanten. Dann
wurde er mit einem siamesischen Gesandten wieder
zurückgeschickt, welcher außer Briefen an den König Manuel als
Geschenke eine Krone, ein Schwert von Gold und einen kostbaren
Rubinring überreichen sollte.
Zur Erwiderung gingen mit demselben Gesandten reiche
Geschenke wieder an den König von Siam zurück. Die Ueberbringer
derselben, Antonio de Miranda d’Azevedo und Duarte Coelho, reisten
zu Lande über Tenasserim nach Siam. Eine andere Gesandtschaft
ging unter Ruy da Cunha nach Pegu, um auch mit diesem Reiche
einen Vertrag zu schließen. Malayische Fürsten von Sumatra und
Java beeilten sich ihre freundschaftliche Gesinnung für die
Portugiesen ebenfalls durch Geschenke zu bethätigen. Nur mit
Arakan, dessen Hafenstadt von João da Silveira angegriffen war, und
mit dem Königreiche Atschin in Nord-Sumatra blieb man auf
feindlichem Fuße. Das letztere Reich, in nächster Nachbarschaft von
Malaka gelegen, unterstützte in der Folgezeit mehrfach die immer
wiederholten Angriffe der vertriebenen Mauren auf die Stadt und
suchte Jahrzehnte lang den Handel zu beeinträchtigen.
Da die Chinesen schon bei dem ersten Besuche Sequeira’s in
Malaka sich durchaus freundlichgesinnt bewiesen, so suchte
Albuquerque auch mit China freundschaftliche Beziehungen
anzuknüpfen. Doch unterblieb die Absendung einer Gesandtschaft
noch in den nächsten Jahren. Dagegen ist gewiß, daß bereits 1515
das Reich der Mitte von portugiesischen Handelsschiffen aufgesucht
wurde, welche zwar ihre Waaren absetzen durften, aber für ihre
Mannschaft nicht die Erlaubniß erhielten, das Land zu betreten.
Der Eindruck, den die Kunde von der Eroberung Malaka’s in
Europa machte, war ein außerordentlicher. Derselbe wurde noch
gesteigert durch eine pomphafte Gesandtschaft, welche König
Manuel 1513 unter Tristão da Cunha mit großem Gefolge an den
Papst Leo X. entsendete. Außer reichen mit Gold und Edelsteinen
geschmückten kirchlichen Ornaten und schweren goldenen Gefäßen
wurde bei dem prächtigen Einzuge der Gesandtschaft in Rom, am
12. März 1514, dem erstaunten Volke auch die gewaltige Thierwelt
Indiens in Gestalt eines riesigen Elephanten, den man seit dem
Alterthum in Italien nicht mehr gesehen hatte, eines Jagdleoparden,
der auf einem reich aufgezäumten persischen Rosse saß — es war
ein Geschenk des Königs von Ormuz — vorgeführt. Ein Herold mit
den portugiesischen Abzeichen schritt in dem festlichen Zuge, der
eine Huldigung des Orients vor dem Haupte der Christenheit
vorstellen sollte, dem Gesandten voraus. Die Menschenmenge,
welche um dieses Schauspiel zu sehen, herbeigeströmt war, hatte
Kopf an Kopf alle Straßen dermaßen besetzt, daß der Zug kaum
hindurchdringen konnte.
Als derselbe endlich die Engelsburg erreicht, wurde mit allen
Kanonen geschossen, daß der Donner der Geschütze und dichter
Pulverdampf weithin über die Stadt rollten. Dann erschien der Papst
an einem Fenster und nahm den Zug in Augenschein. Der riesige
Elephant mußte vor Seiner Heiligkeit dreimal die Knie beugen, zu
nicht geringer Verwunderung der Zuschauer.[109] Am folgenden Tage
wurden die Geschenke in feierlicher Audienz überreicht durch den
portugiesischen Abgesandten Diogo Pacheco, welcher bei dieser
Gelegenheit eine glänzende Rede über die Waffenthaten seiner
Landsleute in Indien hielt und dabei einen Brief seines Königs
überreichte, in welchem gleichfalls die Siege Albuquerque’s
verherrlicht waren. Nach der deutschen Uebersetzung (Die New Welt
der Landschafften u. s. w. Straßburg 1534. Fol. 57) lautet der
Anfang dieses Briefes folgendermaßen:
Ein sendbrieff des mechtigsten vnd vnuberwintlichsten Emanuels
des Königs jnn Portugal, vnd Algarbien von den sygen, die er gehabt
hat jnn India vnd Malacha, zu dem Heyligsten jnn Gott vatter, vnd
vnserm Herrn, Herrn Leoni dem zehenden des namens Babst zu
Rom.
„Wie vast wir vns mit Gott dem Herrn vnd dir frewen sollen,
Allerheyligster vatter das erscheynet aus der bottschaft, die vnser
Indische schiffrüstung bracht hat. Dweyl vnder dir Römischem
Bischoff, und presidenten der Römischen vnd Christlichen Kirchen so
wunderbarliche Ding, zu lob vnd eher dem Allmechtigen nach
wunsch ergangen seind, das man dir billich zum lob und eher
rechnet. Darumb hat vns fur billich angesehen, was in India sich
verloffen hat, mit der Hilff Gots, vnd vnsern waffen zu deiner
Heyligkeyt als zu eym Haupt der gmeynen Christenheyt vnd
richtschyt aller Christlichen Religion kurtz vnd summarien weys
zubeschreyben, das alle Ding nach jhrem werd geschetzt werden,
vnd Gott dem Herren darumb gedanckt. Auch dz wir hoffen mögen
tägliche merung deines lobs sambt zunemung des Christlichen
glaubens vnd leren.“
Es wurden also auch die indischen Siege als Glaubenssiege
aufgefaßt; aber der Schauplatz dieser Kreuzzüge lag viel weiter im
Osten, „am güldenen Chersoneso, in den auswendigsten
Morgenländern“, wo durch die portugiesischen Waffen auch das
Christenthum verbreitet werden sollte. Albuquerque’s Verdienst
wurde mit höchster Anerkennung gepriesen. Der Generalcapitän
Indiens stand damals auf der Höhe seines Ruhmes. In Asien und
Afrika erscholl sein Name mit Schrecken, in Europa mit
Bewunderung.
Noch von Malaka aus wurden drei Schiffe am Schluß des Jahres
1511 abgesendet, um das letzte Ziel der Portugiesen, die
G e w ü r z i n s e l n o d e r M o l u k k e n a u f z u s u c h e n. Das
kleine Geschwader stand unter der Führung des A n t o n i o
d ’ A b r e u. Derselbe hatte sich beim zweiten Sturm auf Malaka
ausgezeichnet, war dabei durch einen Schuß in die Backe, welcher
ihm mehrere Zähne und einen Theil der Zunge nahm, verwundet,
hatte aber trotzdem nach Anlegung eines Verbandes sich am Kampfe
wieder betheiligt. Wie diese erste Kundschaft nach den Molukken
verlief, werden wir später im Zusammenhange mit den folgenden
Vorfällen auf den Gewürzinseln zu schildern haben.
Die Angelegenheiten zu Malaka ordnete Albuquerque der Art, daß
er Ruy d’Araujo zum Richter und Factor (alcaide mór e feitor), Ruy
de Brito Patalim zum Commandanten der Festung einsetzte. Die
Besatzung belief sich auf 300 Mann, ebenso stark war die
Mannschaft auf der dort stationirten Flotte von zehn Segeln, welche
unter dem Befehle des Fernão Peres d’Andrade zurückblieb. Diese
beträchtliche Macht war erforderlich, um Malaka gegen Angriffe von
der Land- und Seeseite vertheidigen zu können. Und solche Angriffe
waren um so mehr zu erwarten, als die Macht des früheren
Herrschers keineswegs gebrochen war; denn Mahmud hatte sich auf
Bintang, südöstlich von der alten Residenz Singapur, und sein Sohn
Alaeddin in Dschohor festgesetzt, so daß sie von da aus die Straße
nach den Gewürzinseln und nach China nicht nur beherrschten,
sondern die Portugiesen in Malaka beständig beunruhigen konnten.
Im Januar 1512 ging Albuquerque mit drei Schiffen nach Indien
zurück. Auch nahm er eine Anzahl (gegen 60) javanischer
Zimmerleute sammt ihren Familien mit, welche ihm beim Schiffbau
dienlich sein sollten. An der gefährlichen Küste von Sumatra ging
Albuquerque’s Schiff, Flor de la mar, auf einer Sandbank zu Grunde.
Er selbst verlor alle Beute und Siegeszeichen in diesem Schiffbruche
sammt den Manuscripten, in denen er seine Thaten aufgezeichnet
hatte. Die Mannschaft rettete sich zwar auf das folgende
portugiesische Schiff, aber die malayischen Zimmerleute benutzten
die Gelegenheit zu einer Meuterei, bemächtigten sich des
Fahrzeuges, auf dem sie segelten, mit Gewalt und gingen an der
Küste von Sumatra ans Land. Albuquerque selbst erreichte in den
ersten Tagen des Februar den Hafen von Kotschin.
In Goa waren unterdessen, während der Abwesenheit des
Oberbefehlshabers, die Portugiesen belagert worden und arg
bedrängt. Die verhältnißmäßig kleine Besatzung von 450 Portugiesen
und 1250 indischen Hilfstruppen wurde fortwährend beunruhigt und
durch kleine Gefechte ermüdet. Sie verlor sogar zwei ihrer besten
Hauptleute und sah sich genöthigt, den noch gefangen gehaltenen
Diogo Mendes de Vascogoncellos seiner Bande zu entledigen und an
die Spitze zu stellen. Die Feinde hatten der Stadt gegenüber eine
starke Burg in Benestarim errichtet und drohten von da aus, die
Fremdlinge zu vertreiben. Zum Glück kamen im Sommer 1512
nacheinander mehrere Schiffe mit Mannschaft und Lebensmitteln zu
Hilfe, und als im August sogar eine größere Flotte von dreizehn
Schiffen mit 1800 Soldaten einlief, gewann man allen Muth wieder
und ging selbst zum Angriff über. Albuquerque durfte es daher
wagen, seine Ankunft zu verzögern, um vorher die Handelsflotte
nach Europa abzufertigen, und ging erst am 16. September mit
sechzehn Segeln nach Goa.
Sein Erscheinen änderte die Lage vollständig. Aus den bisher
Bedrängten wurden wieder Bedränger und siegesgewisse Angreifer.
Benestarim wurde erobert. Den portugiesischen Ueberläufern in der
Festung hatte Albuquerque das Leben gesichert, aber er ließ ihnen
zur Strafe, anderen zur Warnung, Ohren und Nase abschneiden, die
rechte Hand, sowie den linken Daumen abhauen und schickte die
Verstümmelten nach Portugal zurück. Benestarim wurde noch
stärker befestigt und Goa bei dem folgenden Friedensschlusse an
Portugal abgetreten. Der verhältnißmäßig leichte Sieg ist zum Theil
auch der steten Eifersucht der dekhanischen Fürsten untereinander
zuzuschreiben, die einerseits nie gemeinschaftliche Sache gegen die
Abendländer machten, andererseits sich im Geheimen um die
Freundschaft der Portugiesen bewarben. Dann wurde durch eine an
der Küste kreuzende Flotte der Hafen von Kalikut gesperrt und
dadurch der Fürst auch zur Nachgiebigkeit gezwungen. Dagegen
begann Goa als Handelsplatz aufzublühen. Albuquerque hatte dafür
gesorgt, daß nur nach Goa die Pferde aus Persien eingeführt werden
durften. Die einheimischen Kriege wurden damals in Indien aber
hauptsächlich durch Reiterei entschieden. Die indischen Fürsten
waren also dadurch, daß Goa allein der Einfuhrhafen für Pferde
wurde, auf den guten Willen und die Freundschaft der Portugiesen
angewiesen, wenn sie ihre Reiterei verstärken wollten.
In Portugal selbst erkannte man die Bedeutung Goa’s noch nicht,
oder wurde durch falsche Berichte, die möglicherweise absichtlich
von den Gegnern Albuquerque’s verbreitet wurden, über die wahre
Sachlage getäuscht. Nur so erklärt es sich, daß Manuel in einem
Schreiben an den Oberbefehlshaber anordnen konnte, Albuquerque
möge mit seinen Hauptleuten wohl überlegen, ob Goa behauptet
werden solle oder nicht. Goa sei ein ungesunder Ort und seine
Behauptung koste unnützes Geld.[110] Man werde dadurch in immer
erneute Kriege mit den nächsten Landesherren verwickelt und es
werde sehr fraglich sein, ob jemals die Abgaben vom festen Lande
eingezogen werden könnten, welche der Generalcapitän als nicht
unbeträchtlich bezeichnet hatte. Albuquerque aber legte auf die
Wiedereroberung Goa’s das größte Gewicht. Er schrieb dem Könige,
daß dieser Sieg in Indien mehr gewirkt habe für die Macht des
Königs, als alle Flotten, die seit fünfzehn Jahren dahin abgeschickt
worden seien. Der Bund der feindlichen Fürsten sei dadurch
gesprengt. Die Räthe des Königs wüßten die indischen
Angelegenheiten nicht richtig zu beurtheilen. Ohne feste Stütze auf
dem Lande sei in Indien die portugiesische Macht ohne Dauer. Alle
Citadellen in Kotschin, Kananor und anderen Orten hielten in Werth
und Bedeutung keinen Vergleich mit Goa aus. Er wisse wohl, daß er
in Portugal Feinde habe; aber der König möge nicht auf sie hören;
denn wenn Goa wieder aufgegeben würde, dürfte auch die
portugiesische Herrschaft in Indien ihrem Ende nahe sein. Er
verdiene mehr Dank vom Könige dafür, daß er Goa gegen
Portugiesen vertheidige, als dafür, daß er es zweimal den Feinden
abgenommen.[111]
Osorio stellt bei dieser Gelegenheit folgenden interessanten
Vergleich zwischen der Politik Almeida’s und Albuquerque’s an:[112]
das Ziel beider Feldherrn ging auf die Verherrlichung und den Ruhm
ihres Königs und der portugiesischen Waffen, sowie auf die
Verbreitung des Christenthums in Indien; aber sie schlugen
verschiedene Wege ein. Almeida wollte sich mit einem Stützpunkt
am Lande begnügen und dagegen mit stets vereinigten Flotten die
See beherrschen. Seine Truppen wollte er nicht in einzelnen
Besatzungen zersplittern, welche von großen feindlichen Mächten
leicht überwältigt werden könnten. Albuquerque aber strebte vor
allem danach, Herr des Landes zu werden, in der festen
Ueberzeugung, daß er dann auch über die See gebiete. Sein Blick
ging dabei über das Nächstliegende hinaus. Er wollte nicht blos
dafür sorgen, für die Gegenwart alljährlich kostbare Gewürzfrachten
heimzusenden, er wollte diesen Handel auch für die Zukunft sichern.
Dazu brauchte er eine imponirende Stellung auf dem Lande und
damit verbunden eine vollkommene Beherrschung der wichtigsten
Handelsplätze. Eine große Flotte, meinte er, könne in einem Sturme
untergehen, eine feste Stellung auf indischem Boden sei sicherer. Ein
solcher Platz sei aber nicht sicher, wenn er blos an sich fest sei,
sondern erst dann, wenn man demselben auf verschiedenen Wegen
Hilfe bringen könne. Solche Stützpunkte aber verminderten nicht,
sondern stärkten auch die Machtstellung auf der See.
Wie richtig Albuquerque’s Urtheil in Bezug auf Goa war, erwies
sich in der Folgezeit, als Soliman von Aegypten Diu angriff und durch
eine von Goa kommende Flotte zum Rückzug genöthigt wurde;
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!
ebookultra.com

Weitere ähnliche Inhalte

PDF
Programming: Principles and Practice Using C++ 2nd Edition, (Ebook PDF)
PDF
Structure And Interpretation Of Computer Programs 2e Javascript Edition 2nd E...
PDF
(eBook PDF) Starting Out with Java: From Control Structures through Objects, ...
PDF
Test Bank for Starting out with Visual C#, 5th Edition, Tony Gaddis
PDF
Introducing Python Modern Computing in Simple Packages 1st Edition Bill Luban...
PDF
Solution Manual for C++ How to Program: Late Objects Version, 7/E 7th Edition...
PDF
A comprehensive introduction to object oriented programming with Java 1st Edi...
PDF
Coding Python Raspberry Pi Larry Lutz Richard Ray
Programming: Principles and Practice Using C++ 2nd Edition, (Ebook PDF)
Structure And Interpretation Of Computer Programs 2e Javascript Edition 2nd E...
(eBook PDF) Starting Out with Java: From Control Structures through Objects, ...
Test Bank for Starting out with Visual C#, 5th Edition, Tony Gaddis
Introducing Python Modern Computing in Simple Packages 1st Edition Bill Luban...
Solution Manual for C++ How to Program: Late Objects Version, 7/E 7th Edition...
A comprehensive introduction to object oriented programming with Java 1st Edi...
Coding Python Raspberry Pi Larry Lutz Richard Ray

Ähnlich wie Programming Logic and Design Comprehensive 6th Edition Joyce Farrell (20)

PDF
Solution Manual for C How to Program, 7/E 7th Edition Paul Deitel, Harvey Deitel
PDF
The Rust Programming Language Steve Klabnik
PDF
Technology In Action Complete 12th Edition Evans Test Bank
PDF
Solution Manual for C How to Program, 7/E 7th Edition Paul Deitel, Harvey Deitel
PDF
iOS 9 Programming Fundamentals with Swift Swift Xcode and Cocoa Basics 2nd Ed...
PDF
Digital Design 4th Edition M. Morris Mano
PDF
Begin to Code with JavaScript 1st Edition Miles
PDF
Rational Application Developer V6 Programming Guide 2 Volume Set Ibm Redbooks
PDF
Download full ebook of Professional C++ 6th Edition Gregoire instant download...
PDF
Computer Knowledge For Sbi Ibps Bank Clerk Po So Rrb Rbi Exams 1st Shikha Aga...
PDF
X Machines for Agent Based Modeling FLAME Perspectives 1st Edition Mariam Kiran
PDF
Beginning Mac Os X Tiger Dashboard Widget Development Fred Terry
PDF
Real Time Systems Design and Analysis 3rd Edition Phillip A. Laplante
PDF
Database Systems. The Complete Book 2nd ed. Hector Garcia-Molina
PDF
Building Applications with Scala 1st Edition Pacheco
PDF
The Computer from Pascal to von Neumann Herman H. Goldstine
PPTX
0b101000 years of computing: a personal timeline - decade "0", the 1980's
PDF
C How to Program 7th Edition Deitel Test Bank
PDF
(eBook PDF) Software Engineering 10th Edition
PDF
Download full ebook of Notes of C language Anjana Chaudhary instant download pdf
Solution Manual for C How to Program, 7/E 7th Edition Paul Deitel, Harvey Deitel
The Rust Programming Language Steve Klabnik
Technology In Action Complete 12th Edition Evans Test Bank
Solution Manual for C How to Program, 7/E 7th Edition Paul Deitel, Harvey Deitel
iOS 9 Programming Fundamentals with Swift Swift Xcode and Cocoa Basics 2nd Ed...
Digital Design 4th Edition M. Morris Mano
Begin to Code with JavaScript 1st Edition Miles
Rational Application Developer V6 Programming Guide 2 Volume Set Ibm Redbooks
Download full ebook of Professional C++ 6th Edition Gregoire instant download...
Computer Knowledge For Sbi Ibps Bank Clerk Po So Rrb Rbi Exams 1st Shikha Aga...
X Machines for Agent Based Modeling FLAME Perspectives 1st Edition Mariam Kiran
Beginning Mac Os X Tiger Dashboard Widget Development Fred Terry
Real Time Systems Design and Analysis 3rd Edition Phillip A. Laplante
Database Systems. The Complete Book 2nd ed. Hector Garcia-Molina
Building Applications with Scala 1st Edition Pacheco
The Computer from Pascal to von Neumann Herman H. Goldstine
0b101000 years of computing: a personal timeline - decade "0", the 1980's
C How to Program 7th Edition Deitel Test Bank
(eBook PDF) Software Engineering 10th Edition
Download full ebook of Notes of C language Anjana Chaudhary instant download pdf
Anzeige

Programming Logic and Design Comprehensive 6th Edition Joyce Farrell

  • 1. Visit https://ebookultra.com to download the full version and explore more ebooks Programming Logic and Design Comprehensive 6th Edition Joyce Farrell _____ Click the link below to download _____ https://ebookultra.com/download/programming-logic-and- design-comprehensive-6th-edition-joyce-farrell/ Explore and download more ebooks at ebookultra.com
  • 2. Here are some suggested products you might be interested in. Click the link to download Java Programming 7th Edition Joyce Farrell https://ebookultra.com/download/java-programming-7th-edition-joyce- farrell/ Java Programming 8th Edition Joyce Farrell https://ebookultra.com/download/java-programming-8th-edition-joyce- farrell/ Java Programs to Accompany Programming Logic and Design 7th Edition Jo Ann Smith https://ebookultra.com/download/java-programs-to-accompany- programming-logic-and-design-7th-edition-jo-ann-smith/ Microsoft Visual Basic Programs to Accompany Programming Logic and Design 3rd Edition Jo Ann Smith https://ebookultra.com/download/microsoft-visual-basic-programs-to- accompany-programming-logic-and-design-3rd-edition-jo-ann-smith/
  • 3. Computer programming for teens 1st Edition Mary E. Farrell https://ebookultra.com/download/computer-programming-for-teens-1st- edition-mary-e-farrell/ Programming and Problem Solving with C Comprehensive Comprehensive Edition Nell B. Dale https://ebookultra.com/download/programming-and-problem-solving-with- c-comprehensive-comprehensive-edition-nell-b-dale/ Comprehensive Gynecology 6th Edition Gretchen M Lentz https://ebookultra.com/download/comprehensive-gynecology-6th-edition- gretchen-m-lentz/ The Haskell Road to Logic Maths and Programming 1st Edition Kees Doets https://ebookultra.com/download/the-haskell-road-to-logic-maths-and- programming-1st-edition-kees-doets/ Logic and Computer Design Fundamentals Third Edition M. Morris Mano https://ebookultra.com/download/logic-and-computer-design- fundamentals-third-edition-m-morris-mano/
  • 5. Programming Logic and Design Comprehensive 6th Edition Joyce Farrell Digital Instant Download Author(s): Joyce Farrell ISBN(s): 0538744766 Edition: 6 File Details: PDF, 18.81 MB Year: 2010 Language: english
  • 9. S I X T H E D I T I O N PR OGRAMMING LOGIC AND DESIGN COMPREHENSIVE JO YCE FARRELL Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
  • 10. This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may be suppressed. Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. The publisher reserves the right to remove content from this title at any time if subsequent rights restrictions require it. For valuable information on pricing, previous editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for materials in your areas of interest.
  • 11. © 2011 Course Technology, Cengage Learning ALL RIGHTS RESERVED. No part of this work covered by the copyright herein may be reproduced, transmitted, stored or used in any form or by any means—graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, information networks, or information storage and retrieval systems, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act—without the prior written permission of the publisher. Library of Congress Control Number: 2009938501 ISBN-13: 978-0-5387-4476-8 ISBN-10: 0-538-74476-6 Course Technology 20 Channel Center Street Boston, MA 02210 USA Some of the product names and company names used in this book have been used for identification purposes only and may be trademarks or registered trademarks of their respective manufacturers and sellers. Course Technology, a part of Cengage Learning, reserves the right to revise this publication and make changes from time to time in its content without notice. Cengage Learning is a leading provider of customized learning solutions with office locations around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at: www.cengage.com/global Cengage Learning products are represented in Canada by Nelson Education, Ltd. To learn more about Course Technology, visit www.cengage.com/coursetechnology Purchase any of our products at your local college store or at our preferred online store www.ichapters.com Programming Logic and Design, Comprehensive, Sixth Edition Joyce Farrell Executive Editor: Marie Lee Acquisitions Editor: Amy Jollymore Managing Editor: Tricia Coia Developmental Editor: Dan Seiter Content Project Manager: Jennifer Feltri Editorial Assistant: Zina Kresin Marketing Manager: Bryant Chrzan Art Director: Marissa Falco Text Designer: Shawn Girsberger Cover Designer: Cabbage Design Company Cover Image: iStockphoto Print Buyer: Julio Esperas Copy Editor: Michael Beckett Proofreader: Vicki Zimmer Indexer: Alexandra Nickerson Compositor: Integra Printed in Canada 1 2 3 4 5 6 7 14 13 12 11 10 For product information and technology assistance, contact us at Cengage Learning Customer & Sales Support, 1-800-354-9706 For permission to use material from this text or product, submit all requests online at cengage.com/permissions Further permissions questions can be emailed to permissionrequest@cengage.com
  • 12. Brief Contents Preface . . . . . . . . . . . . . . . . . xvi CHAPTER 1 An Overview of Computers and Programming . . 1 CHAPTER 2 Working with Data, Creating Modules, and Designing High-Quality Programs . . . . 41 CHAPTER 3 Understanding Structure . . . . . . . . . . 92 CHAPTER 4 Making Decisions . . . . . . . . . . . . 133 CHAPTER 5 Looping . . . . . . . . . . . . . . . . 184 CHAPTER 6 Arrays . . . . . . . . . . . . . . . . . 228 CHAPTER 7 File Handling and Applications . . . . . . 276 CHAPTER 8 Advanced Array Concepts, Indexed Files, and Linked Lists. . . . . . . . . . . . . 325 CHAPTER 9 Advanced Modularization Techniques . . . . 370 CHAPTER 10 Object-Oriented Programming . . . . . . . 426 CHAPTER 11 More Object-Oriented Programming Concepts . . . . . . . . . . . . . . . . 469 CHAPTER 12 Event-Driven GUI Programming, Multithreading, and Animation . . . . . . . 515 CHAPTER 13 System Modeling with the UML . . . . . . 550 CHAPTER 14 Using Relational Databases . . . . . . . . 585 APPENDIX A Understanding Numbering Systems and Computer Codes. . . . . . . . . . . 637 APPENDIX B Flowchart Symbols . . . . . . . . . . . 646 v
  • 13. APPENDIX C Structures . . . . . . . . . . . . . . . 647 APPENDIX D Solving Difficult Structuring Problems . . . 649 APPENDIX E Creating Print Charts . . . . . . . . . . 658 APPENDIX F Two Variations on the Basic Structures— case and do-while . . . . . . . . . . 660 Glossary . . . . . . . . . . . . . . . . 666 Index . . . . . . . . . . . . . . . . . 681 B R I E F C O N T E N T S vi
  • 14. Contents Preface . . . . . . . . . . . . . . . . . xvi CHAPTER 1 An Overview of Computers and Programming . . . . . . . . . . . . . 1 Understanding Computer Systems. . . . . . . . . . . . . . 2 Understanding Simple Program Logic . . . . . . . . . . . . 5 Understanding the Program Development Cycle . . . . . . . 8 Understanding the Problem . . . . . . . . . . . . . . . . 8 Planning the Logic . . . . . . . . . . . . . . . . . . . .10 Coding the Program . . . . . . . . . . . . . . . . . . .10 Using Software to Translate the Program into Machine Language . . . . . . . . . . . . . . . . .11 Testing the Program . . . . . . . . . . . . . . . . . . .12 Putting the Program into Production . . . . . . . . . . . .14 Maintaining the Program . . . . . . . . . . . . . . . . .14 Using Pseudocode Statements and Flowchart Symbols . . . .15 Writing Pseudocode . . . . . . . . . . . . . . . . . . .15 Drawing Flowcharts . . . . . . . . . . . . . . . . . . .17 Repeating Instructions . . . . . . . . . . . . . . . . . .18 Using a Sentinel Value to End a Program . . . . . . . . . . .20 Understanding Programming and User Environments . . . . .23 Understanding Programming Environments . . . . . . . . .23 Understanding User Environments . . . . . . . . . . . . .25 Understanding the Evolution of Programming Models . . . . .27 Chapter Summary . . . . . . . . . . . . . . . . . . . . .28 Key Terms . . . . . . . . . . . . . . . . . . . . . . . .29 Review Questions . . . . . . . . . . . . . . . . . . . . .32 Exercises . . . . . . . . . . . . . . . . . . . . . . . . .37 CHAPTER 2 Working with Data, Creating Modules, and Designing High-Quality Programs . . . . . . 41 Declaring and Using Variables and Constants. . . . . . . . .42 vii
  • 15. Working with Variables . . . . . . . . . . . . . . . . . .42 Naming Variables . . . . . . . . . . . . . . . . . . . .44 Understanding Unnamed, Literal Constants and their Data Types . . . . . . . . . . . . . . . . . .45 Understanding the Data Types of Variables . . . . . . . . .46 Declaring Named Constants. . . . . . . . . . . . . . . .47 Assigning Values to Variables . . . . . . . . . . . . . . . .48 Performing Arithmetic Operations . . . . . . . . . . . . .49 Understanding the Advantages of Modularization . . . . . . . 52 Modularization Provides Abstraction . . . . . . . . . . . .53 Modularization Allows Multiple Programmers to Work on a Problem. . . . . . . . . . . . . . . . . .54 Modularization Allows You to Reuse Your Work . . . . . . .54 Modularizing a Program . . . . . . . . . . . . . . . . . .55 Declaring Variables and Constants within Modules . . . . . . . . . . . . . . . . . . . . .59 Understanding the Most Common Configuration for Mainline Logic . . . . . . . . . . . . . . . . . . . .61 Creating Hierarchy Charts . . . . . . . . . . . . . . . . .66 Features of Good Program Design. . . . . . . . . . . . . .68 Using Program Comments . . . . . . . . . . . . . . . .69 Choosing Identifiers . . . . . . . . . . . . . . . . . . .71 Designing Clear Statements. . . . . . . . . . . . . . . .72 Writing Clear Prompts and Echoing Input . . . . . . . . . .74 Maintaining Good Programming Habits . . . . . . . . . . .76 Chapter Summary . . . . . . . . . . . . . . . . . . . . .77 Key Terms . . . . . . . . . . . . . . . . . . . . . . . .78 Review Questions . . . . . . . . . . . . . . . . . . . . .82 Exercises . . . . . . . . . . . . . . . . . . . . . . . . .86 CHAPTER 3 Understanding Structure . . . . . . . . . . 92 Understanding Unstructured Spaghetti Code . . . . . . . . .93 Understanding the Three Basic Structures . . . . . . . . . .95 Using a Priming Input to Structure a Program . . . . . . . 103 Understanding the Reasons for Structure . . . . . . . . . 110 Recognizing Structure . . . . . . . . . . . . . . . . . . 111 Structuring and Modularizing Unstructured Logic . . . . . . 115 Chapter Summary . . . . . . . . . . . . . . . . . . . . 121 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 122 Review Questions . . . . . . . . . . . . . . . . . . . . 123 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 127 C O N T E N T S viii
  • 16. CHAPTER 4 Making Decisions . . . . . . . . . . . . 133 Evaluating Boolean Expressions to Make Comparisons . . . 134 Using Relational Comparison Operators . . . . . . . . . . 137 Avoiding a Common Error with Relational Operators . . . . 141 Understanding AND Logic . . . . . . . . . . . . . . . . 141 Nesting AND Decisions for Efficiency . . . . . . . . . . 144 Using the AND Operator . . . . . . . . . . . . . . . . 146 Avoiding Common Errors in an AND Selection. . . . . . . 148 Understanding OR Logic . . . . . . . . . . . . . . . . . 150 Writing OR Decisions for Efficiency . . . . . . . . . . . 152 Using the OR Operator . . . . . . . . . . . . . . . . . 153 Avoiding Common Errors in an OR Selection . . . . . . . 155 Making Selections within Ranges . . . . . . . . . . . . . 159 Avoiding Common Errors When Using Range Checks . . . 162 Understanding Precedence When Combining AND and OR Operators . . . . . . . . . . . . . . . . . 166 Chapter Summary . . . . . . . . . . . . . . . . . . . . 169 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 170 Review Questions . . . . . . . . . . . . . . . . . . . . 171 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 177 CHAPTER 5 Looping . . . . . . . . . . . . . . . . 184 Understanding the Advantages of Looping . . . . . . . . . 185 Using a Loop Control Variable. . . . . . . . . . . . . . . 186 Using a Definite Loop with a Counter . . . . . . . . . . 187 Using an Indefinite Loop with a Sentinel Value . . . . . . 188 Understanding the Loop in a Program’s Mainline Logic. . . 190 Nested Loops . . . . . . . . . . . . . . . . . . . . . . 192 Avoiding Common Loop Mistakes . . . . . . . . . . . . . 196 Mistake: Neglecting to Initialize the Loop Control Variable . . . . . . . . . . . . . . . . . 197 Mistake: Neglecting to Alter the Loop Control Variable . . . . . . . . . . . . . . . . . 198 Mistake: Using the Wrong Comparison with the Loop Control Variable . . . . . . . . . . . . . . . . . 200 Mistake: Including Statements Inside the Loop that Belong Outside the Loop . . . . . . . . . . . . . 201 Using a for Loop . . . . . . . . . . . . . . . . . . . . 206 Common Loop Applications . . . . . . . . . . . . . . . . 208 Using a Loop to Accumulate Totals . . . . . . . . . . . 208 Using a Loop to Validate Data . . . . . . . . . . . . . . 211 Limiting a Reprompting Loop . . . . . . . . . . . . . . 213 ix C O N T E N T S
  • 17. Validating a Data Type . . . . . . . . . . . . . . . . . 215 Validating Reasonableness and Consistency of Data . . . . 216 Chapter Summary . . . . . . . . . . . . . . . . . . . . 217 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 218 Review Questions . . . . . . . . . . . . . . . . . . . . 219 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 223 CHAPTER 6 Arrays . . . . . . . . . . . . . . . . . 228 Understanding Arrays and How They Occupy Computer Memory . . . . . . . . . . . . . . . . . . . 229 How Arrays Occupy Computer Memory. . . . . . . . . . 229 Manipulating an Array to Replace Nested Decisions . . . . . 232 Using Constants with Arrays . . . . . . . . . . . . . . . 240 Using a Constant as the Size of an Array . . . . . . . . . 240 Using Constants as Array Element Values . . . . . . . . 241 Using a Constant as an Array Subscript . . . . . . . . . 241 Searching an Array . . . . . . . . . . . . . . . . . . . 242 Using Parallel Arrays . . . . . . . . . . . . . . . . . . . 246 Improving Search Efficiency. . . . . . . . . . . . . . . 251 Searching an Array for a Range Match . . . . . . . . . . . 254 Remaining within Array Bounds . . . . . . . . . . . . . . 258 Using a for Loop to Process Arrays . . . . . . . . . . . 261 Chapter Summary . . . . . . . . . . . . . . . . . . . . 262 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 263 Review Questions . . . . . . . . . . . . . . . . . . . . 264 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 268 CHAPTER 7 File Handling and Applications . . . . . . 276 Understanding Computer Files . . . . . . . . . . . . . . 277 Organizing Files . . . . . . . . . . . . . . . . . . . . 278 Understanding the Data Hierarchy . . . . . . . . . . . . . 279 Performing File Operations . . . . . . . . . . . . . . . . 280 Declaring a File . . . . . . . . . . . . . . . . . . . . 280 Opening a File . . . . . . . . . . . . . . . . . . . . . 281 Reading Data From a File . . . . . . . . . . . . . . . . 281 Writing Data to a File . . . . . . . . . . . . . . . . . . 283 Closing a File . . . . . . . . . . . . . . . . . . . . . 283 A Program that Performs File Operations. . . . . . . . . 283 Understanding Sequential Files and Control Break Logic . . . 286 Understanding Control Break Logic . . . . . . . . . . . 287 Merging Sequential Files . . . . . . . . . . . . . . . . . 293 Master and Transaction File Processing . . . . . . . . . . 303 x C O N T E N T S
  • 18. Random Access Files . . . . . . . . . . . . . . . . . . 311 Chapter Summary . . . . . . . . . . . . . . . . . . . . 313 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 314 Review Questions . . . . . . . . . . . . . . . . . . . . 316 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 320 CHAPTER 8 Advanced Array Concepts, Indexed Files, and Linked Lists. . . . . . . . . . . . . 325 Understanding the Need for Sorting Records . . . . . . . . 326 Understanding How to Swap Two Values . . . . . . . . . . 327 Using a Bubble Sort . . . . . . . . . . . . . . . . . . . 329 Sorting a List of Variable Size. . . . . . . . . . . . . . 337 Refining the Bubble Sort to Reduce Unnecessary Comparisons. . . . . . . . . . . . . . . . . . . . . 341 Refining the Bubble Sort to Eliminate Unnecessary Passes . . . . . . . . . . . . . . . . . . . . . . . 343 Other Sorts . . . . . . . . . . . . . . . . . . . . . . 345 Using Multidimensional Arrays . . . . . . . . . . . . . . 345 Using Indexed Files and Linked Lists. . . . . . . . . . . . 352 Using Indexed Files . . . . . . . . . . . . . . . . . . 352 Using Linked Lists . . . . . . . . . . . . . . . . . . . 354 Chapter Summary . . . . . . . . . . . . . . . . . . . . 357 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 358 Review Questions . . . . . . . . . . . . . . . . . . . . 359 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 364 CHAPTER 9 Advanced Modularization Techniques . . . . 370 Using Methods with No Parameters . . . . . . . . . . . . 371 Creating Methods that Require a Single Parameter . . . . . 374 Creating Methods that Require Multiple Parameters . . . . . 379 Creating Methods that Return a Value . . . . . . . . . . . 381 Using an IPO Chart . . . . . . . . . . . . . . . . . . . 387 Passing an Array to a Method . . . . . . . . . . . . . . . 388 Overloading Methods. . . . . . . . . . . . . . . . . . . 395 Avoiding Ambiguous Methods . . . . . . . . . . . . . . . 398 Using Predefined Methods . . . . . . . . . . . . . . . . 401 Method Design Issues: Implementation Hiding, Cohesion, and Coupling . . . . . . . . . . . . . . . . . . . . . 403 Understanding Implementation Hiding . . . . . . . . . . 403 Increasing Cohesion . . . . . . . . . . . . . . . . . . 404 Reducing Coupling . . . . . . . . . . . . . . . . . . . 405 Understanding Recursion . . . . . . . . . . . . . . . . . 407 xi C O N T E N T S
  • 19. Chapter Summary . . . . . . . . . . . . . . . . . . . . 411 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 413 Review Questions . . . . . . . . . . . . . . . . . . . . 415 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 419 CHAPTER 10 Object-Oriented Programming . . . . . . . 426 Principles of Object-Oriented Programming. . . . . . . . . 427 Classes and Objects . . . . . . . . . . . . . . . . . . 427 Polymorphism . . . . . . . . . . . . . . . . . . . . . 430 Inheritance . . . . . . . . . . . . . . . . . . . . . . 431 Encapsulation . . . . . . . . . . . . . . . . . . . . . 432 Defining Classes and Creating Class Diagrams . . . . . . . 433 Creating Class Diagrams . . . . . . . . . . . . . . . . 435 The Set Methods. . . . . . . . . . . . . . . . . . . . 438 The Get Methods. . . . . . . . . . . . . . . . . . . . 440 Work Methods . . . . . . . . . . . . . . . . . . . . . 440 Understanding Public and Private Access . . . . . . . . . 442 Organizing Classes . . . . . . . . . . . . . . . . . . . 446 Understanding Instance Methods . . . . . . . . . . . . . 447 Understanding Static Methods . . . . . . . . . . . . . . 453 Using Objects . . . . . . . . . . . . . . . . . . . . . . 455 Chapter Summary . . . . . . . . . . . . . . . . . . . . 459 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 460 Review Questions . . . . . . . . . . . . . . . . . . . . 462 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 466 CHAPTER 11 More Object-Oriented Programming Concepts . . . . . . . . . . . . . . . . 469 An Introduction to Constructors . . . . . . . . . . . . . . 470 Constructors with Parameters. . . . . . . . . . . . . . 473 Overloading Class Methods and Constructors. . . . . . . 473 Understanding Destructors . . . . . . . . . . . . . . . . 476 Understanding Composition. . . . . . . . . . . . . . . . 478 Understanding Inheritance . . . . . . . . . . . . . . . . 479 Understanding Inheritance Terminology . . . . . . . . . 481 Accessing Private Members of a Parent Class . . . . . . 484 Using Inheritance to Achieve Good Software Design . . . . 490 One Example of Using Predefined Classes: Creating GUI Objects . . . . . . . . . . . . . . . . . . 491 Understanding Exception Handling. . . . . . . . . . . . . 493 Drawbacks to Traditional Error-Handling Techniques . . . . 493 The Object-Oriented Exception Handling Model . . . . . . 495 xii C O N T E N T S
  • 20. Using Built-in Exceptions and Creating Your Own Exceptions. . . . . . . . . . . . . . . . . . . . . . 498 Reviewing the Advantages of Object-Oriented Programming . . . . . . . . . . . . . . . . . . . . . 499 Chapter Summary . . . . . . . . . . . . . . . . . . . . 500 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 502 Review Questions . . . . . . . . . . . . . . . . . . . . 503 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 508 CHAPTER 12 Event-Driven GUI Programming, Multithreading, and Animation . . . . . . . 515 Understanding Event-Driven Programming . . . . . . . . . 516 User-Initiated Actions and GUI Components. . . . . . . . . 519 Designing Graphical User Interfaces . . . . . . . . . . . . 523 The Interface Should Be Natural and Predictable . . . . . 523 The Interface Should Be Attractive, Easy to Read, and Nondistracting . . . . . . . . . . . . . . . . . . . . 524 To Some Extent, It’s Helpful If the User Can Customize Your Applications. . . . . . . . . . . . . . 524 The Program Should Be Forgiving . . . . . . . . . . . . 525 The GUI Is Only a Means to an End . . . . . . . . . . . 525 The Steps to Developing an Event-Driven Application . . . . 526 Creating Storyboards. . . . . . . . . . . . . . . . . . 527 Defining the Storyboard’s Objects in an Object Dictionary . . . . . . . . . . . . . . . . . 527 Defining Connections Between the User Screens . . . . . 528 Planning the Logic . . . . . . . . . . . . . . . . . . . 529 Understanding Multithreading . . . . . . . . . . . . . . . 535 Creating Animation. . . . . . . . . . . . . . . . . . . . 537 Chapter Summary . . . . . . . . . . . . . . . . . . . . 540 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 541 Review Questions . . . . . . . . . . . . . . . . . . . . 542 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 546 CHAPTER 13 System Modeling with the UML . . . . . . 550 Understanding the Need for System Modeling . . . . . . . 551 What is the UML? . . . . . . . . . . . . . . . . . . . . 552 Using Use Case Diagrams . . . . . . . . . . . . . . . . 554 Using Class and Object Diagrams . . . . . . . . . . . . . 560 Using Sequence and Communication Diagrams . . . . . . . 564 Using State Machine Diagrams . . . . . . . . . . . . . . 566 Using Activity Diagrams . . . . . . . . . . . . . . . . . 567 xiii C O N T E N T S
  • 21. Using Component, Deployment, and Profile Diagrams . . . . 570 Diagramming Exception Handling . . . . . . . . . . . . . 572 Deciding When to Use the UML and Which UML Diagrams to Use . . . . . . . . . . . . . . . . . 573 Chapter Summary . . . . . . . . . . . . . . . . . . . . 575 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 576 Review Questions . . . . . . . . . . . . . . . . . . . . 578 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 582 CHAPTER 14 Using Relational Databases . . . . . . . . 585 Understanding Relational Database Fundamentals. . . . . . 586 Creating Databases and Table Descriptions . . . . . . . . 588 Identifying Primary Keys . . . . . . . . . . . . . . . . . 591 Understanding Database Structure Notation . . . . . . . . 594 Adding, Deleting, Updating, and Sorting Records within Tables. . . . . . . . . . . . . . . . . . . . . . 595 Sorting the Records in a Table . . . . . . . . . . . . . 596 Creating Queries. . . . . . . . . . . . . . . . . . . . . 596 Understanding Relationships Between Tables . . . . . . . . 600 Understanding One-to-Many Relationships . . . . . . . . 600 Understanding Many-to-Many Relationships . . . . . . . . 601 Understanding One-to-One Relationships . . . . . . . . . 606 Recognizing Poor Table Design . . . . . . . . . . . . . . 607 Understanding Anomalies, Normal Forms, and Normalization . . . . . . . . . . . . . . . . . . . 609 First Normal Form . . . . . . . . . . . . . . . . . . . 610 Second Normal Form . . . . . . . . . . . . . . . . . . 612 Third Normal Form . . . . . . . . . . . . . . . . . . . 615 Database Performance and Security Issues . . . . . . . . 618 Providing Data Integrity. . . . . . . . . . . . . . . . . 618 Recovering Lost Data . . . . . . . . . . . . . . . . . 619 Avoiding Concurrent Update Problems . . . . . . . . . . 619 Providing Authentication and Permissions . . . . . . . . 620 Providing Encryption . . . . . . . . . . . . . . . . . . 620 Chapter Summary . . . . . . . . . . . . . . . . . . . . 621 Key Terms . . . . . . . . . . . . . . . . . . . . . . . 622 Review Questions . . . . . . . . . . . . . . . . . . . . 625 Exercises . . . . . . . . . . . . . . . . . . . . . . . . 630 xiv C O N T E N T S
  • 22. APPENDIX A Understanding Numbering Systems and Computer Codes. . . . . . . . . . . 637 APPENDIX B Flowchart Symbols . . . . . . . . . . . 646 APPENDIX C Structures . . . . . . . . . . . . . . . 647 APPENDIX D Solving Difficult Structuring Problems . . . 649 APPENDIX E Creating Print Charts . . . . . . . . . . 658 APPENDIX F Two Variations on the Basic Structures— case and do-while . . . . . . . . . . 660 Glossary . . . . . . . . . . . . . . . . 666 Index . . . . . . . . . . . . . . . . . 681 xv C O N T E N T S
  • 23. Preface Programming Logic and Design, Comprehensive, Sixth Edition provides the beginning programmer with a guide to developing structured program logic. This textbook assumes no programming language experience. The writing is nontechnical and emphasizes good programming practices. The examples are business examples; they do not assume mathematical background beyond high school business math. Additionally, the examples illustrate one or two major points; they do not contain so many features that students become lost following irrelevant and extraneous details. The examples in Programming Logic and Design have been created to provide students with a sound background in logic, no matter what programming languages they eventually use to write programs. This book can be used in a stand-alone logic course that students take as a prerequisite to a programming course, or as a companion book to an introductory programming text using any programming language. Organization and Coverage Programming Logic and Design, Comprehensive, Sixth Edition introduces students to programming concepts and enforces good style and logical thinking. General programming concepts are intro- duced in Chapter 1. Chapter 2 discusses using data and introduces two important concepts: modularization and creating high-quality programs. It is important to emphasize these topics early so that students start thinking in a modular way and concentrate on making their programs efficient, robust, easy to read, and easy to maintain. Chapter 3 covers the key concepts of structure, including what structure is, how to recognize it, and most importantly, the advan- tages to writing structured programs. This early overview gives students a solid foundation for thinking in a structured way before they have to manage the details of the structures. Chapters 4, 5, and 6 explore the intricacies of decision making, looping, and array manipulation. Chapter 7 provides details of file handling so students can create programs that handle a significant amount of data. xvi
  • 24. In Chapters 8 and 9, students learn more advanced techniques in array manipulation and modularization. Chapters 10 and 11 provide a thorough, yet accessible, introduction to concepts and terminology used in object-oriented programming. Students learn about classes, objects, instance and static class members, constructors, destructors, inheritance, and the advantages provided by object-oriented thinking. Chapter 12 explores additional object-oriented programming issues: event-driven GUI programming, multithreading, and animation. Chapter 13 discusses system design issues and details the features of the Unified Modeling Language. Chapter 14 is a thorough introduc- tion to the most important database concepts business programmers should understand. The first three appendices give students summaries of numbering systems, flowchart symbols, and structures. Additional appendices allow students to gain extra experience with structuring large unstructured programs, creating print charts, and understanding posttest loops and case structures. Programming Logic and Design combines text explanation with flowcharts and pseudocode examples to provide students with alternative means of expressing structured logic. Numerous detailed, full-program exercises at the end of each chapter illustrate the concepts explained within the chapter, and reinforce understanding and retention of the material presented. Programming Logic and Design distinguishes itself from other programming logic books in the following ways: It is written and designed to be non-language specific. The logic • used in this book can be applied to any programming language. The examples are everyday business examples; no special knowledge • of mathematics, accounting, or other disciplines is assumed. The concept of structure is covered earlier than in many other • texts. Students are exposed to structure naturally, so they will automatically create properly designed programs. Text explanation is interspersed with flowcharts and pseudocode • so students can become comfortable with both logic development tools and understand their interrelationship. Screen shots of running programs also are included, providing students with a clear and concrete image of the programs’ execution. Complex programs are built through the use of complete business • examples. Students see how an application is constructed from start to finish instead of studying only segments of programs. xvii P R E FA C E
  • 25. Features This edition of the text includes many features to help students become better programmers and understand the big picture in program development. Many new features have been added, and the popular features from the first five editions are still included. Features maintained from previous editions include: OBJECTIVES Each chapter begins with a list of objectives so the student knows the topics that will be presented in the chapter. In addition to providing a quick reference to topics covered, this feature provides a useful study aid. FLOWCHARTS This book has plenty of figures and illustrations, including flowcharts, which provide the reader with a visual learning experience, rather than one that involves simply studying text. You can see examples of flowcharts beginning in Chapter 1. PSEUDOCODE This book also includes numerous examples of pseudocode, which illustrate correct usage of the programming logic and design concepts being taught. NOTES These tips provide additional information—for example, another location in the book that expands on a topic, or a common error to watch out for. THE DON’T DO IT ICON It is sometimes illustrative to show an example of how NOT to do something—for example, having a dead code path in a program. However, students do not always read carefully and sometimes use logic similar to that shown in what is intended to be a “bad” example. When the instructor is critical, the frustrated student says, “But that’s how they did it in the book!” Therefore, although the text will continue to describe bad examples, and the captions for the related figures will mention that they are bad examples, the book also includes a “Don’t Do It” icon near the offending section of logic. This icon provides a visual jolt to the student, emphasizing that particular figures are NOT to be emulated. THE TWO TRUTHS AND A LIE QUIZ This quiz appears after each chapter section, with answers provided. The quiz contains three statements based on the preceding section of text—two true and one false. Over the years, students have requested answers to problems, but we have hesitated to distribute them in case instructors want to use problems as assignments or test questions. These true-false mini-quizzes provide students with immediate feedback as they read, without “giving away” answers to the multiple-choice questions and programming problems later in the chapter. xviii P R E FA C E
  • 26. GAME ZONE EXERCISES These exercises are included at the end of each chapter. Students can create games as an additional entertaining way to understand key concepts presented in the chapter. CHAPTER SUMMARIES Following each chapter is a summary that recaps the programming concepts and techniques covered in the chapter. This feature provides a concise means for students to review and check their understanding of the main points in each chapter. KEY TERMS Each chapter lists key terms and their definitions; the list appears in the order the terms are encountered in the chapter. Along with the chapter summary, the list of key terms provides a snapshot overview of a chapter’s main ideas. A glossary at the end of the book lists all the key terms in alphabetical order, along with working definitions. DEBUGGING EXERCISES Because examining programs critically and closely is a crucial programming skill, each chapter includes a “Find the Bugs” section in which program- ming examples are presented that contain syntax errors and logical errors for the student to find and correct. REVIEW QUESTIONS Twenty multiple-choice review questions appear at the end of every chapter to allow students to test their comprehension of the major ideas and techniques presented. EXERCISES Multiple end-of-chapter flowcharting and pseudocoding exercises are included so students have more opportunities to practice concepts as they learn them. These exercises increase in difficulty and are designed to allow students to explore logical programming concepts. Each exercise can be completed using flowcharts, pseudocode, or both. In addition, instructors can assign the exercises as programming prob- lems to be coded and executed in a particular programming language. ESSAY QUESTIONS Each chapter contains an “Up For Discussion” section in which questions present personal and ethical issues that programmers must consider. These ques- tions can be used for written assignments or as a starting point for classroom discussions. New to this Edition! VIDEO LESSONS Each chapter is accompanied by two or more video lessons that help explain an important chapter concept. A listing of the videos provided can be found on the inside back cover of this text. These videos are designed and narrated by the author and are available for free with a new book. (They can also be purchased separately at iChapters.com.) xix P R E FA C E
  • 27. If you have a new book, it will contain a URL and PIN code. Once you go to this URL and enter your PIN code, follow the prompts to locate the videos for this text. If you are a user of an online course cartridge, such as BlackBoard, WebCT, or Angel, you will also have access to these videos through that platform. INCREASED EMPHASIS ON MODULARITY From the second chapter, students are encouraged to write code in concise, easily manageable, and reusable modules. Instructors have found that modularization is a technique that should be encouraged early to instill good habits and a clearer understanding of structure. This edition explains modularization early, using global variables instead of local passed and returned values, and saves parameter passing for later when the student has become more adept. CLEARER EXPLANATIONS This edition has been rewritten to provide clearer, simpler explanations that are appropriate for the beginning programming student. As a result of the new, cleaner approach, the length of the book has been reduced. NEW APPENDICES FOR EASY REFERENCE New appendices have been added that cover numbering systems, flowchart symbols, and structures. DECREASED EMPHASIS ON CONTROL BREAKS Professional programmers should understand control break logic, but creating such logic is not as common a task as it was years ago. Therefore, the topic is still covered briefly as part of the file-handling chapter, but with reduced emphasis from previous editions of the book. Instructor Resources The following supplemental materials are available when this book is used in a classroom setting. All of the instructor resources available with this book are provided to the instructor on a single CD-ROM. ELECTRONIC INSTRUCTOR’S MANUAL The Instructor’s Manual that accompanies this textbook provides additional instructional material to assist in class preparation, including items such as Sample Syllabi, Chapter Outlines, Technical Notes, Lecture Notes, Quick Quizzes, Teaching Tips, Discussion Topics, and Key Terms. EXAMVIEW® This textbook is accompanied by ExamView, a powerful testing software package that allows instructors to create and admin- ister printed, computer (LAN-based), and Internet exams. ExamView includes hundreds of questions that correspond to the topics covered in this text, enabling students to generate detailed study guides that include page references for further review. The computer-based and Internet xx P R E FA C E
  • 28. testing components allow students to take exams at their computers, and save the instructor time by grading each exam automatically. POWERPOINT PRESENTATIONS This book comes with Microsoft PowerPoint© slides for each chapter. These are included as a teach- ing aid for classroom presentation, to make available to students on your network for chapter review, or to be printed for classroom distribution. Instructors can add their own slides for additional topics they introduce to the class. SOLUTIONS Suggested solutions to Review Questions and Exercises are provided on the Instructor Resources CD and may also be found on the Course Technology Web site at www.cengage.com/coursetech- nology. The solutions are password protected. DISTANCE LEARNING Course Technology offers WebCT© and Blackboard© courses for this text to provide the most complete and dynamic learning experience possible. When you add online content to one of your courses, you’re adding a lot: automated tests, topic reviews, quick quizzes, and additional case projects with solutions. For more information on how to bring distance learning to your course, contact your Course Technology sales representative. Software Options You have the option to bundle software with your text! Please contact your Course Technology sales representative for more information. MICROSOFT® OFFICE VISIO® PROFESSIONAL Visio is a diagramming program that helps users create flowcharts and diagrams easily while working through the text, enabling them to visualize concepts and learn more effectively. VISUAL LOGIC™ This simple but powerful tool teaches program- ming logic and design without traditional high-level programming language syntax. Visual Logic uses flowcharts to explain essential programming concepts, including variables, input, assignment, out- put, conditions, loops, procedures, graphics, arrays, and files. It also has the ability to interpret and execute flowcharts, providing students with immediate and accurate feedback about their solutions. By exe- cuting student solutions, Visual Logic combines the power of a high- level language with the ease and simplicity of flowcharts. Acknowledgments I would like to thank all of the people who helped to make this book a reality, especially Dan Seiter, Development Editor, whose hard work and attention to detail have made this a high-quality textbook. I have xxi P R E FA C E
  • 29. worked with Dan for many years now, and he is indispensable in pro- ducing accurate and approachable technical instruction. Thanks also to Tricia Coia, Managing Editor; Amy Jollymore, Acquisitions Editor; Jennifer Feltri, Content Project Manager; and Green Pen QA, Technical Editors. I am grateful to be able to work with so many fine people who are dedicated to producing high-quality instructional materials. I am grateful to the many reviewers who provided helpful and insightful comments during the development of this book, including Gilbert Armour, Virginia Western Community College; John Buerck, Saint Louis University; Karen Cummings, McLennan Community College; Clara Groeper, Illinois Central College; and Jeff Hedrington, Colorado Technical University. Thanks, too, to my husband, Geoff, and our daughters, Andrea and Audrey, for their support. This book, as were all its previous editions, is dedicated to them. –Joyce Farrell xxii P R E FA C E
  • 30. About the Inside Front Cover Check out our interviews with recent graduates who are now working in the IT field. One is featured on the inside front cover of this book. If you know people who recently landed a job in IT, we’d like to interview them too! Send your suggestions via e-mail to Amy Jollymore, Acquisitions Editor, at Amy.Jollymore@Cengage.com. xxiii P R E FA C E
  • 32. C H A P T E R 1 An Overview of Computers and Programming In this chapter, you will learn about: Computer systems  Simple program logic  The steps involved in the program development cycle  Pseudocode statements and flowchart symbols  Using a sentinel value to end a program  Programming and user environments  The evolution of programming models 
  • 33. Understanding Computer Systems A computer system is a combination of all the components required to process and store data using a computer. Every computer system is composed of multiple pieces of hardware and software. Hardware • is the equipment, or the physical devices, associated with a computer. For example, keyboards, mice, speakers, and printers are all hardware. The devices are manufactured differently for large mainframe computers, laptops, and even smaller comput- ers that are embedded into products such as cars and thermostats, but the types of operations performed by different-sized comput- ers are very similar. When you think of a computer, you often think of its physical components first, but for a computer to be useful it needs more than devices; a computer needs to be given instruc- tions. Just as your stereo equipment does not do much until you provide music, computer hardware needs instructions that control how and when data items are input, how they are processed, and the form in which they are output or stored. Software • is computer instructions that tell the hardware what to do. Software is programs: instructions written by programmers. You can buy prewritten programs that are stored on a disk or that you down- load from the Web. For example, businesses use word-processing and accounting programs, and casual computer users enjoy pro- grams that play music and games. Alternatively, you can write your own programs. When you write software instructions, you are programming. This book focuses on the programming process. Software can be classified as application software or system software. Application software comprises all the programs you apply to a task— word-processing programs, spreadsheets, payroll and inventory programs, and even games. System software comprises the programs that you use to manage your computer, including operating systems such as Windows, Linux, or UNIX. This book focuses on the logic used to write application software pro- grams, although many of the concepts apply to both types of software. Together, computer hardware and software accomplish three major operations in most programs: Input • —Data items enter the computer system and are put into mem- ory, where they can be processed. Hardware devices that perform input operations include keyboards and mice. Data items include all the text, numbers, and other information that are processed by a computer. In business, much of the data used is facts and figures about such entities as products, customers, and personnel. However, data can also be items such as the choices a player makes in a game or the notes required by a music- playing program. 2 C H A P T E R 1 An Overview of Computers and Programming
  • 34. Many computer professionals distinguish between the terms data, which describes items that are input, and information, which describes data items that have been processed and sent to a device where people can read and interpret them. For example, your name, Social Security number, and hourly pay rate are data items when they are input to a program, but the same items are information after they have been processed and output on your paycheck. Processing • —Processing data items may involve organizing or sorting them, checking them for accuracy, or performing calculations with them. The hardware component that performs these types of tasks is the central processing unit, or CPU. Output • —After data items have been processed, the resulting infor- mation usually is sent to a printer, monitor, or some other output device so people can view, interpret, and use the results. Some people consider storage as a fourth major computer operation. Instead of sending output to a device such as a printer, monitor, or speaker where a person can interpret it, you sometimes store output on storage devices, such as a disk or flash media. People cannot read data directly from these storage devices, but the devices hold information for later retrieval. When you send output to a storage device, sometimes it is used later as input for another program. You write computer instructions in a computer programming language, such as Visual Basic, C#, C++, or Java. Just as some people speak English and others speak Japanese, programmers also write programs in different languages. Some programmers work exclusively in one language, whereas others know several program- ming languages and use the one that is best suited to the task at hand. Every programming language has rules governing its word usage and punctuation. These rules are called the language’s syntax. If you ask, “How the geet too store do I?” in English, most people can figure out what you probably mean, even though you have not used proper English syntax—you have mixed up the word order, misspelled a word, and used an incorrect word. However, computers are not nearly as smart as most people; in this case, you might as well have asked the computer, “Xpu mxv ort dod nmcad bf B?” Unless the syntax is perfect, the computer cannot interpret the programming language instruction at all. When you write a program, you usually type its instructions using a keyboard. When you type program instructions, they are stored in computer memory, which is a computer’s temporary, internal The instruc- tions you write using a pro- gramming language are called program code; when you write instruc- tions, you are coding the program. 3 Understanding Computer Systems
  • 35. storage. Internal storage is volatile—its contents are lost when the computer is turned off or loses power. Usually, you want to be able to retrieve and perhaps modify the stored instructions later, so you also store them on a permanent storage device, such as a disk. Permanent storage devices are nonvolatile—that is, their contents are persistent and are retained even when power is lost. After a computer program is stored in memory, it must be trans- lated from your programming language statements to machine language that represents the millions of on/off circuits within the computer. Each programming language uses a piece of software, called a compiler or an interpreter, to translate your program code into machine language. Machine language is also called binary language, and is represented as a series of 0s and 1s. The compiler or interpreter that translates your code tells you if any programming language component has been used incorrectly. Syntax errors are relatively easy to locate and correct because the compiler or interpreter you use highlights every syntax error. If you write a computer program using a language such as C++ but spell one of its words incorrectly or reverse the proper order of two words, the software lets you know that it found a mistake by displaying an error message as soon as you try to translate the program. Although there are differences in how compilers and interpreters work, their basic function is the same—to translate your programming statements into code the computer can use. When you use a compiler, an entire program is translated before it can execute; when you use an interpreter, each instruc- tion is translated just prior to execution. Usually, you do not choose which type of translation to use—it depends on the programming language. However, there are some languages for which both compilers and interpreters are available. Only after program instructions are successfully translated to machine code can the computer carry out the program instructions. When instructions are carried out, a program runs, or executes. In a typical program, some input will be accepted, some processing will occur, and results will be output. Besides the popular full-blown programming languages such as Java and C++, many programmers use scripting languages (also called scripting programming languages or script languages) such as Python, Lua, Perl, and PHP. Scripts written in these languages usually can be typed directly from a keyboard and are stored as text rather than as binary execut- able files. Scripting language programs are interpreted line by line each time the program executes, instead of being stored in a compiled (binary) form. Random access memory, or RAM, is a form of inter- nal, volatile memory. It is hardware on which the programs that are cur- rently running and the data items that are currently being used are stored for quick access. The program statements you write in a programming language are known as source code. The translated machine language statements are known as object code. 4 C H A P T E R 1 An Overview of Computers and Programming
  • 36. TWO TRUTHS & A LIE Understanding Computer Systems In each Two Truths and a Lie section, two of the numbered statements are true, and one is false. Identify the false statement and explain why it is false. 1. Hardware is the equipment, or the devices, associated with a computer. Software is computer instructions. 2. The grammar rules of a computer programming language are its syntax. 3. You write programs using machine language, and translation software con- verts the statements to a programming language. The false statement is #3. You write programs using a programming language such as Visual Basic or Java, and a translation program (called a compiler or inter- preter) converts the statements to machine language, which is 0s and 1s. Understanding Simple Program Logic A program with syntax errors cannot execute. A program with no syntax errors can execute, but might contain logical errors, and produce incor- rect output as a result. For a program to work properly, you must give the instructions to the computer in a specific sequence, you must not leave any instructions out, and you must not add extraneous instructions. By doing this, you are developing the logic of the computer program. Suppose you instruct someone to make a cake as follows: Get a bowl Stir Add two eggs Add a gallon of gasoline Bake at 350 degrees for 45 minutes Add three cups of flour Even though you have used the English language syntax correctly, the cake-baking instructions are out of sequence, some instructions are missing, and some instructions belong to procedures other than baking a cake. If you follow these instructions, you are not going to make an edi- ble cake, and you most likely will end up with a disaster. Logical errors are much more difficult to locate than syntax errors—it is easier for you to determine whether “eggs” is spelled incorrectly in a recipe than it is for you to tell if there are too many eggs or if they are added too soon. The dangerous cake-baking instructions are shown with a Don’t Do It icon. You will see this icon when the book contains an unrecommended pro- gramming practice that is used as an example of what not to do. If you misspell a program- ming language word, you commit a syntax error, but if you use an otherwise correct word that does not make sense in the current con- text, programmers say you have committed a semantic error. Either way, the program will not execute. Don’t Do It Don't bake a cake like this! 5 Understanding Simple Program Logic
  • 37. Just as baking directions can be given correctly in Mandarin, Urdu, or Spanish, the same program logic can be expressed in any number of programming languages. Because this book is not concerned with any specific language, the programming examples could have been written in Visual Basic, C++, or Java. For convenience, this book uses instructions written in English! Most simple computer programs include steps that perform input, processing, and output. Suppose you want to write a computer program to double any number you provide. You can write such a program in a programming language such as Visual Basic or Java, but if you were to write it using English-like statements, it would look like this: input myNumber set myAnswer = myNumber * 2 output myAnswer The number-doubling process includes three instructions: The instruction to • input myNumber is an example of an input operation. When the computer interprets this instruction, it knows to look to an input device to obtain a number. When you work in a specific programming language, you write instructions that tell the computer which device to access for input. For exam- ple, when a user enters a number as data for a program, the user might click on the number with a mouse, type it from a keyboard, or speak it into a microphone. Logically, however, it doesn’t really matter which hardware device is used, as long as the computer knows to look for a number. When the number is retrieved from an input device, it is placed in the computer’s memory at the location named myNumber. The location myNumber is a variable. A variable is a named memory location whose value can vary—for example, the value of myNumber might be 3 when the program is used for the first time and 45 when it is used the next time. From a logical perspective, when you input a value, the hardware device is irrelevant. The same is true in your daily life. If you follow the instruction “Get eggs for the cake,” it does not really matter if you purchase them from a store or harvest them from your own chickens—you get the eggs either way. There might be different practical considerations to getting the eggs, just as there are for getting data from a large database as opposed to an inexperienced user. For now, this book is only concerned with the logic of the operation, not the minor details. The instruction • set myAnswer = myNumber * 2 is an example of a processing operation. Mathematical operations are not the only kind of processing operations, but they are very typical. As with input operations, the type of hardware used for processing After you learn French, you automatically know, or can easily figure out, many Spanish words. Similarly, after you learn one programming lan- guage, it is much easier to understand several other languages. You will learn about the odd elimination of the space between words like my and Number in Chapter 2. Programmers use an aster- isk to indicate multiplication. You will learn more about arithmetic statements in Chapter 2. 6 C H A P T E R 1 An Overview of Computers and Programming
  • 38. is irrelevant—after you write a program, it can be used on comput- ers of different brand names, sizes, and speeds. The instruction takes the value stored in memory at the myNumber location, mul- tiplies it by 2, and stores the result in another memory location named myAnswer. In the number-doubling program, the • output myAnswer instruc- tion is an example of an output operation. Within a particular program, this statement could cause the output to appear on the monitor (which might be a flat-panel plasma screen or a cathode- ray tube), or the output could go to a printer (which could be laser or ink-jet), or the output could be written to a disk or DVD. The logic of the output process is the same no matter what hardware device you use. When this instruction executes, the value stored in memory at the location named myAnswer is sent to an output device. Computer memory consists of millions of numbered locations where data can be stored. The memory location of myNumber has a specific numeric address—for example, 48604. Your program associates myNumber with that address. Every time you refer to myNumber within a program, the com- puter retrieves the value at the associated memory location. When you write programs, you seldom need to be concerned with the value of the memory address; instead, you simply use the easy-to-remember name you created. Computer programmers often refer to memory addresses using hexadeci- mal notation, or base 16. Using this system, they might use a value like 42FF01A to refer to a memory address. Despite the use of letters, such an address is still a hexadecimal number. Appendix A contains information on this numbering system. TWO TRUTHS & A LIE Understanding Simple Program Logic 1. A program with syntax errors can execute but might produce incorrect results. 2. Although the syntax of programming languages differs, the same program logic can be expressed in different languages. 3. Most simple computer programs include steps that perform input, process- ing, and output. The false statement is #1. A program with syntax errors cannot execute; a program with no syntax errors can execute, but might produce incorrect results. Watch the video A Simple Program. 7 Understanding Simple Program Logic
  • 39. Understanding the Program Development Cycle A programmer’s job involves writing instructions (such as those in the doubling program in the preceding section), but a professional programmer usually does not just sit down at a computer keyboard and start typing. Figure 1-1 illustrates the program development cycle, which can be broken down into at least seven steps: 1. Understand the problem. 2. Plan the logic. 3. Code the program. 4. Use software (a compiler or interpreter) to translate the program into machine language. 5. Test the program. 6. Put the program into production. 7. Maintain the program. Understand the problem Test the program Put the program into production Maintain the program Plan the logic Translate the code Write the code Figure 1-1 The program development cycle Understanding the Problem Professional computer programmers write programs to satisfy the needs of others, called users or end users. Examples could include a Human Resources department that needs a printed list of all employ- ees, a Billing department that wants a list of clients who are 30 or more days overdue on their payments, and an Order department that 8 C H A P T E R 1 An Overview of Computers and Programming
  • 40. needs a Web site to provide buyers with an online shopping cart in which to gather their orders. Because programmers are providing a service to these users, programmers must first understand what the users want. Although when a program runs, you usually think of the logic as a cycle of input-processing-output operations; when you plan a program, you think of the output first. After you understand what the desired result is, you can plan what to input and process to achieve it. Suppose the director of Human Resources says to a programmer, “Our department needs a list of all employees who have been here over five years, because we want to invite them to a special thank-you dinner.” On the surface, this seems like a simple request. An experi- enced programmer, however, will know that the request is incom- plete. For example, you might not know the answers to the following questions about which employees to include: Does the director want a list of full-time employees only, or a list • of full- and part-time employees together? Does she want people who have worked for the company on a • month-to-month contractual basis over the past five years, or only regular, permanent employees? Do the listed employees need to have worked for the organization • for five years as of today, as of the date of the dinner, or as of some other cutoff date? What about an employee who, for example, worked three years, • took a two-year leave of absence, and has been back for three years? The programmer cannot make any of these decisions; the user (in this case, the Human Resources director) must address these questions. More decisions still might be required. For example: What data should be included for each listed employee? Should • the list contain both first and last names? Social Security numbers? Phone numbers? Addresses? Should the list be in alphabetical order? Employee ID number • order? Length-of-service order? Some other order? Should the employees be grouped by any criteria, such as depart- • ment number or years of service? Several pieces of documentation are often provided to help the pro- grammer understand the problem. Documentation consists of all the supporting paperwork for a program; it might include items such as original requests for the program from users, sample output, and descriptions of the data items available for input. The term end user distin- guishes those who actually use and ben- efit from a software prod- uct from others in an organization who might purchase, install, or have other contact with the software. 9 Understanding the Program Development Cycle
  • 41. Really understanding the problem may be one of the most difficult aspects of programming. On any job, the description of what the user needs may be vague—worse yet, users may not really know what they want, and users who think they know frequently change their minds after seeing sample output. A good programmer is often part coun- selor, part detective! Planning the Logic The heart of the programming process lies in planning the program’s logic. During this phase of the process, the programmer plans the steps of the program, deciding what steps to include and how to order them. You can plan the solution to a problem in many ways. The two most common planning tools are flowcharts and pseudocode. Both tools involve writing the steps of the program in English, much as you would plan a trip on paper before getting into the car or plan a party theme before shopping for food and favors. The programmer shouldn’t worry about the syntax of any particu- lar language at this point, but should focus on figuring out what sequence of events will lead from the available input to the desired output. Planning the logic includes thinking carefully about all the possible data values a program might encounter and how you want the program to handle each scenario. The process of walking through a program’s logic on paper before you actually write the program is called desk-checking. You will learn more about planning the logic throughout this book; in fact, the book focuses on this crucial step almost exclusively. Coding the Program After the logic is developed, only then can the programmer write the program. Hundreds of programming languages are available. Programmers choose particular languages because some have built-in capabilities that make them more efficient than others at handling certain types of operations. Despite their differences, programming languages are quite alike in their basic capabilities—each can handle input operations, arithmetic processing, output operations, and other standard functions. The logic developed to solve a programming problem can be executed using any number of languages. Only after choosing a language must the programmer be concerned with proper punctuation and the correct spelling of commands—in other words, using the correct syntax. Some very experienced programmers can successfully combine logic planning and program coding in one step. This may work for Watch the video The Program Development Cycle, Part 1. You may hear programmers refer to planning a program as “developing an algorithm.” An algorithm is the sequence of steps neces- sary to solve any problem. You will learn more about flowcharts and pseudo- code later in this chapter. In addition to flowcharts and pseudocode, programmers use a variety of other tools to help in program development. One such tool is an IPO chart, which delineates input, processing, and output tasks. Some object-oriented program- mers also use TOE charts, which list tasks, objects, and events. 10 C H A P T E R 1 An Overview of Computers and Programming
  • 42. planning and writing a very simple program, just as you can plan and write a postcard to a friend using one step. A good term paper or a Hollywood screenplay, however, needs planning before writing—and so do most programs. Which step is harder: planning the logic or coding the program? Right now, it may seem to you that writing in a programming lan- guage is a very difficult task, considering all the spelling and syntax rules you must learn. However, the planning step is actually more difficult. Which is more difficult: thinking up the twists and turns to the plot of a best-selling mystery novel, or writing a translation of an existing novel from English to Spanish? And who do you think gets paid more, the writer who creates the plot or the translator? (Try asking friends to name any famous translator!) Using Software to Translate the Program into Machine Language Even though there are many programming languages, each computer knows only one language: its machine language, which consists of 1s and 0s. Computers understand machine language because they are made up of thousands of tiny electrical switches, each of which can be set in either the on or off state, which is represented by a 1 or 0, respectively. Languages like Java or Visual Basic are available for programmers because someone has written a translator program (a compiler or interpreter) that changes the programmer’s English-like high-level programming language into the low-level machine language that the computer understands. If you write a programming language statement incorrectly (for example, by misspelling a word, using a word that doesn’t exist in the language, or using “illegal” grammar), the translator program doesn’t know how to proceed and issues an error message identifying a syntax error, which is a misuse of a language’s grammar rules. Although making errors is never desirable, syntax errors are not a major concern to programmers, because the compiler or interpreter catches every syntax error and displays a mes- sage that notifies you of the problem. The computer will not execute a program that contains even one syntax error. Typically, a programmer develops a program’s logic, writes the code, and compiles the program, receiving a list of syntax errors. The pro- grammer then corrects the syntax errors and compiles the program again. Correcting the first set of errors frequently reveals new errors that originally were not apparent to the compiler. For example, if you could use an English compiler and submit the sentence “The dg chase When you learn the syn- tax of a pro- gramming language, the commands you learn will work on any machine on which the language soft- ware has been installed. However, your com- mands are translated to machine language, which differs depending on your computer make and model. Watch the video The Program Development Cycle, Part 2. 11 Understanding the Program Development Cycle
  • 43. the cat,” the compiler at first might point out only one syntax error. The second word, “dg,” is illegal because it is not part of the English language. Only after you corrected the word to “dog” would the com- piler find another syntax error on the third word, “chase,” because it is the wrong verb form for the subject “dog.” This doesn’t mean “chase” is necessarily the wrong word. Maybe “dog” is wrong; perhaps the subject should be “dogs,” in which case “chase” is right. Compilers don’t always know exactly what you mean, nor do they know what the proper correction should be, but they do know when something is wrong with your syntax. When writing a program, a programmer might need to recompile the code several times. An executable program is created only when the code is free of syntax errors. When you run an executable program, it typically also might require input data. Figure 1-2 shows a diagram of this entire process. Write and correct the program code Compile the program Executable program Data that the program uses List of syntax error messages Program output If there are no syntax errors If there are syntax errors Figure 1-2 Creating an executable program Testing the Program A program that is free of syntax errors is not necessarily free of logi- cal errors. A logical error results when you use a syntactically correct statement but use the wrong one for the current context. For exam- ple, the English sentence “The dog chases the cat,” although syntacti- cally perfect, is not logically correct if the dog chases a ball or the cat is the aggressor. After a pro- gram has been trans- lated into machine lan- guage, the machine lan- guage program is saved and can be run any num- ber of times without repeating the translation step. You only need to retranslate your code if you make changes to your source code statements. 12 C H A P T E R 1 An Overview of Computers and Programming
  • 44. Once a program is free of syntax errors, the programmer can test it—that is, execute it with some sample data to see whether the results are logically correct. Recall the number-doubling program: input myNumber set myAnswer = myNumber * 2 output myAnswer If you execute the program, provide the value 2 as input to the pro- gram, and the answer 4 is displayed, you have executed one successful test run of the program. However, if the answer 40 is displayed, maybe the program contains a logical error. Maybe the second line of code was mistyped with an extra zero, so that the program reads: input myNumber set myAnswer = myNumber * 20 output myAnswer Placing 20 instead of 2 in the multiplication statement caused a logical error. Notice that nothing is syntactically wrong with this second program—it is just as reasonable to multiply a number by 20 as by 2—but if the programmer intends only to double myNumber, then a logical error has occurred. Programs should be tested with many sets of data. For example, if you write the program to double a number, then enter 2 and get an output value of 4, that doesn’t necessarily mean you have a correct program. Perhaps you have typed this program by mistake: input myNumber set myAnswer = myNumber + 2 output myAnswer An input of 2 results in an answer of 4, but that doesn’t mean your program doubles numbers—it actually only adds 2 to them. If you test your program with additional data and get the wrong answer—for example, if you enter 7 and get an answer of 9—you know there is a problem with your code. Selecting test data is somewhat of an art in itself, and it should be done carefully. If the Human Resources department wants a list of the names of five-year employees, it would be a mistake to test the program with a small sample file of only long-term employees. If no newer employees are part of the data being used for testing, you do not really know if the program would have eliminated them The process of finding and correcting program errors is called debugging. Don’t Do It The programmer typed "20" instead of "2". Don’t Do It The programmer typed "+" instead of " *". 13 Understanding the Program Development Cycle
  • 45. from the five-year list. Many companies do not know that their software has a problem until an unusual circumstance occurs—for example, the first time an employee has more than nine depen- dents, the first time a customer orders more than 999 items at a time, or when (as well-documented in the popular press) a new century begins. Putting the Program into Production Once the program is tested adequately, it is ready for the organi- zation to use. Putting the program into production might mean simply running the program once, if it was written to satisfy a user’s request for a special list. However, the process might take months if the program will be run on a regular basis, or if it is one of a large system of programs being developed. Perhaps data-entry people must be trained to prepare the input for the new program; users must be trained to understand the output; or existing data in the company must be changed to an entirely new format to accommodate this program. Conversion, the entire set of actions an organization must take to switch over to using a new pro- gram or set of programs, can sometimes take months or years to accomplish. Maintaining the Program After programs are put into production, making necessary changes is called maintenance. Maintenance can be required for many reasons: new tax rates are legislated, the format of an input file is altered, or the end user requires additional information not included in the original output specifications, to name a few. Frequently, your first programming job will require maintaining previously written programs. When you maintain the programs others have written, you will appreciate the effort the original pro- grammer put into writing clear code, using reasonable variable names, and documenting his or her work. When you make changes to existing programs, you repeat the development cycle. That is, you must understand the changes, then plan, code, translate, and test them before putting them into production. If a substantial number of program changes are required, the original program might be retired, and the program development cycle might be started for a new program. Chapter 4 contains more information on testing programs. Watch the video The Program Development Cycle, Part 3. 14 C H A P T E R 1 An Overview of Computers and Programming
  • 46. TWO TRUTHS & A LIE Understanding the Program Development Cycle 1. Understanding the problem that must be solved can be one of the most dif- ficult aspects of programming. 2. The two most commonly used logic-planning tools are flowcharts and pseudocode. 3. Flowcharting a program is a very different process if you use an older programming language instead of a newer one. The false statement is #3. Despite their differences, programming languages are quite alike in their basic capabilities—each can handle input operations, arithmetic processing, output operations, and other standard functions. The logic developed to solve a programming problem can be executed using any number of languages. Using Pseudocode Statements and Flowchart Symbols When programmers plan the logic for a solution to a programming problem, they often use one of two tools: pseudocode (pronounced “sue-doe-code”) or flowcharts. Pseudocode is an English-like repre- sentation of the logical steps it takes to solve a problem. A flowchart is a pictorial representation of the same thing. Pseudo is a prefix that means “false,” and to code a program means to put it in a programming language; therefore, pseudocode simply means “false code,” or sentences that appear to have been written in a computer programming language but do not necessarily follow all the syntax rules of any specific language. Writing Pseudocode You have already seen examples of statements that represent pseudo- code earlier in this chapter, and there is nothing mysterious about them. The following five statements constitute a pseudocode repre- sentation of a number-doubling problem: start input myNumber set myAnswer = myNumber * 2 output myAnswer stop 15 Using Pseudocode Statements and Flowchart Symbols
  • 47. Using pseudocode involves writing down all the steps you will use in a program. Usually, programmers preface their pseudocode with a beginning statement like start and end it with a terminating state- ment like stop. The statements between start and stop look like English and are indented slightly so that start and stop stand out. Most programmers do not bother with punctuation such as periods at the end of pseudocode statements, although it would not be wrong to use them if you prefer that style. Similarly, there is no need to capi- talize the first word in a sentence, although you might choose to do so. This book follows the conventions of using lowercase letters for verbs that begin pseudocode statements and omitting periods at the end of statements. Pseudocode is fairly flexible because it is a planning tool, and not the final product. Therefore, for example, you might prefer any of the following: Instead of • start and stop, some pseudocode developers would use the terms begin and end. Instead of writing • input myNumber, some developers would write get myNumber or read myNumber. Instead of writing • set myAnswer = myNumber * 2, some develop- ers would write calculate myAnswer = myNumber times 2 or compute myAnswer as myNumber doubled. Instead of writing • output myAnswer, many pseudocode devel- opers would write display myAnswer, print myAnswer, or write myAnswer. The point is, the pseudocode statements are instructions to retrieve an original number from an input device and store it in memory where it can be used in a calculation, and then to get the calculated answer from memory and send it to an output device so a person can see it. When you eventually convert your pseudocode to a specific programming language, you do not have such flexibility because spe- cific syntax will be required. For example, if you use the C# program- ming language and write the statement to output the answer, you will code the following: Console.Write (myAnswer); The exact use of words, capitalization, and punctuation are important in the C# statement, but not in the pseudocode statement. 16 C H A P T E R 1 An Overview of Computers and Programming
  • 48. Drawing Flowcharts Some professional programmers prefer writing pseudocode to drawing flowcharts, because using pseudocode is more similar to writing the final statements in the programming language. Others prefer drawing flowcharts to represent the logical flow, because flow- charts allow programmers to visualize more easily how the program statements will connect. Especially for beginning programmers, flow- charts are an excellent tool to help them visualize how the statements in a program are interrelated. When you create a flowchart, you draw geometric shapes that contain the individual statements and that are connected with arrows. You use a parallelogram to represent an input symbol, which indicates an input operation. You write an input statement in English inside the parallelogram, as shown in Figure 1-3. Arithmetic operation statements are examples of processing. In a flowchart, you use a rectangle as the processing symbol that contains a processing statement, as shown in Figure 1-4. To represent an output state- ment, you use the same symbol as for input statements—the output symbol is a parallelogram, as shown in Figure 1-5. Some software programs that use flowcharts (such as Visual Logic) use a left-slanting parallelogram to represent output. As long as the flowchart creator and the flowchart reader are communicating, the actual shape used is irrelevant. This book will follow the most standard convention of always using the right-slanting parallelogram for both input and output. To show the correct sequence of these statements, you use arrows, or flowlines, to connect the steps. Whenever possible, most of a flow- chart should read from top to bottom or from left to right on a page. That’s the way we read English, so when flowcharts follow this con- vention, they are easier for us to understand. You can draw a flowchart by hand or use software, such as Microsoft Word and Microsoft PowerPoint, that contains flowcharting tools. You can use sev- eral other software pro- grams, such as Visio and Visual Logic, specifically to create flowcharts. Because the parallelogram is used for both input and output, it is often called the input/output symbol or I/O symbol. Appendix B contains a summary of all the flow- chart symbols you will see in this book. input myNumber Figure 1-3 Input symbol set myAnswer = myNumber * 2 Figure 1-4 Processing symbol output myAnswer Figure 1-5 Output symbol 17 Using Pseudocode Statements and Flowchart Symbols
  • 49. To be complete, a flowchart should include two more elements: terminal symbols, or start/stop symbols, at each end. Often, you place a word like start or begin in the first terminal symbol and a word like end or stop in the other. The standard terminal symbol is shaped like a racetrack; many programmers refer to this shape as a lozenge, because it resembles the shape of the medication you might use to soothe a sore throat. Figure 1-6 shows a complete flowchart for the program that doubles a number, and the pseudocode for the same problem. You can see from the figure that the flowchart and pseudocode statements are the same—only the presentation format differs. start Flowchart Pseudocode stop input myNumber output myAnswer set myAnswer = myNumber * 2 start input myNumber set myAnswer = myNumber * 2 output myAnswer stop Figure 1-6 Flowchart and pseudocode of program that doubles a number Repeating Instructions After the flowchart or pseudocode has been developed, the programmer only needs to: (1) buy a computer, (2) buy a language compiler, (3) learn a programming language, (4) code the pro- gram, (5) attempt to compile it, (6) fix the syntax errors, (7) com- pile it again, (8) test it with several sets of data, and (9) put it into production. “Whoa!” you are probably saying to yourself. “This is simply not worth it! All that work to create a flowchart or pseudocode, and then all those other steps? For five dollars, I can buy a pocket calculator that will Programmers seldom create both pseudo- code and a flowchart for the same problem. You usually use one or the other. In a large program, you might even prefer to use pseudocode for some parts and draw a flowchart for others. 18 C H A P T E R 1 An Overview of Computers and Programming
  • 50. double any number for me instantly!” You are absolutely right. If this were a real computer program, and all it did was double the value of a number, it would not be worth the effort. Writing a computer program would be worthwhile only if you had many—let’s say 10,000—numbers to double in a limited amount of time—let’s say the next two minutes. Unfortunately, the number-doubling program represented in Figure 1-6 does not double 10,000 numbers; it doubles only one. You could execute the program 10,000 times, of course, but that would require you to sit at the computer and tell it to run the program over and over again. You would be better off with a program that could process 10,000 numbers, one after the other. One solution is to write the program shown in Figure 1-7 and execute the same steps 10,000 times. Of course, writing this program would be very time consuming; you might as well buy the calculator. Figure 1-7 Inefficient pseudocode for program that doubles 10,000 numbers start input myNumber set myAnswer = myNumber * 2 output myAnswer input myNumber set myAnswer = myNumber * 2 output myAnswer input myNumber set myAnswer = myNumber * 2 output myAnswer …and so on for 9,997 more times A better solution is to have the computer execute the same set of three instructions over and over again, as shown in Figure 1-8. The repetition of a series of steps is called a loop. With this approach, the computer gets a number, doubles it, displays the answer, and then starts over again with the first instruction. The same spot in memory, called myNumber, is reused for the second number and for any subse- quent numbers. The spot in memory named myAnswer is reused each time to store the result of the multiplication operation. The logic illus- trated in the flowchart in Figure 1-8 contains a major problem—the sequence of instructions never ends. This programming situation is known as an infinite loop—a repeating flow of logic with no end. You will learn one way to handle this problem later in this chapter; you will learn a superior way in Chapter 3. When you tell a friend how to get to your house, you might write a series of instructions or you might draw a map. Pseudocode is similar to written, step-by-step instructions; a flowchart, like a map, is a visual representation of the same thing. Don’t Do It You would never want to write such a repetitious list of instructions. 19 Using Pseudocode Statements and Flowchart Symbols
  • 51. Another Random Scribd Document with Unrelated Content
  • 52. auf der flacheren Nordseite der Insel; zwischen ihr und der Felsenküste von Mogistan befand sich der Hafen. Die Besatzung bestand aus 30,000 Mann, darunter 4000 persische Bogenschützen als Bundesgenossen. Albuquerque begrüßte bei seiner Ankunft die Stadt durch Kanonensalven und segelte dann kühn in den Hafen hinein. Kurzer Hand forderte er Unterwerfung und Anerkennung der portugiesischen Oberhoheit, andernfalls drohte er mit Vernichtung. Aber der Regent war nicht gewillt, sich bei seiner bedeutenden Macht ohne weiteres in fremde Botmäßigkeit zu begeben, er lehnte die Forderung des Portugiesen ab. Als Antwort darauf ließ Albuquerque die Handelsschiffe im Hafen in den Grund bohren. Dabei wurden seine Schiffe von zweihundert mit Bogenschützen bemannten Böten angegriffen; aber die höher gebauten europäischen Fahrzeuge und namentlich das europäische Geschütz behielt den Sieg. Dann erst bequemte sich Chodscheh Atar, die Oberhoheit des Königs Manuel anzuerkennen und einen jährlichen Tribut von 15,000 Scherafinen (etwa à 6 Mark) zu zahlen. Auch mußte er gestatten, daß die Portugiesen eine Festung anlegten. Schon im October begann der Bau, aber die portugiesischen Capitäne, welche unter Albuquerque dienten, halfen nur ungern; sie hätten lieber gewinnreiche Jagd auf Handelsschiffe gemacht oder wären nach Indien gesegelt, um Gewürze einzuhandeln. Sie vereinigten sich zu einem schriftlichen Protest, aber der Oberbefehlshaber zerriß denselben, ungelesen, unter dem Thor der neuen Citadelle. Dadurch gekränkt und beleidigt suchten die Capitäne nach einer Gelegenheit, sich von ihrem Führer zu trennen. Die Uneinigkeit unter seinen Feinden ermuthigte den Regenten der Stadt zu erneutem Widerstande. Die Gelegenheit dazu bot sich bald. Da fünf von der Flotte entlaufene und in die Stadt gelockte Portugiesen nicht sofort, wie Albuquerque verlangte, ausgeliefert wurden, so brach der Krieg von neuem aus. Derselbe mußte aber rasch abgebrochen werden, weil drei Capitäne mit ihren Schiffen auf eigene Verantwortung den Hafen verließen und nach Indien segelten, so daß Albuquerque, dadurch in seiner Macht geschwächt, allein den Kampf nicht fortführen konnte, sondern sich genöthigt sah, zur Ueberwinterung nach Sokotra zurückzuweichen. Doch
  • 53. schickte er den João da Nova den Flüchtigen nach, um sich beim Vicekönig über solche unerhörte Felonie zu beschweren. In Sokotra fand er die Besatzung der kleinen Citadelle durch Krankheit und Hunger erschöpft. Von Melinde mußten Lebensmittel herbeigeschafft werden; statt Unterstützung zu finden, mußte Albuquerque Hilfe schaffen. Sein Aufenthalt an der afrikanischen Insel verzögerte sich bis in den Hochsommer, dann kam unter Vasco Gomez d’Abreu Verstärkung von Lissabon. Mit dieser vereinigte er den Rest seiner Macht, sah sich also wieder an der Spitze von 300 Mann und war kühn genug, mit dieser kleinen Schaar zum zweiten Male vor Ormuz zu rücken. Chodscheh Atar hatte nach dem Abzuge der Portugiesen, deren Mißerfolge er sich als Sieg anrechnete, im Vertrauen auf seine neubefestigte Stellung und die eigne Truppenmacht, (die persischen Bundesgenossen waren durch seinen Uebermuth verscheucht,) klugerweise die von den Portugiesen begonnene Festung ausgebaut[104] und mit Geschützen armirt, welche er durch europäische Ueberläufer hatte gießen lassen. Er war, wenn auch auf sich allein angewiesen, doch nicht so wehrlos dem Gegner preisgegeben als das erste Mal. Daher mußte sich Albuquerque vorläufig, als er im September 1508 wieder vor der Stadt erschien, auf die Blokade beschränken. Inzwischen erhielt aber Atar eine wesentliche Hilfe und Ermuthigung zum Widerstande von einer Seite, woher er sie wohl am wenigsten erwartete, vom Vicekönig Almeida selbst. Dieser hatte nämlich auf die Klage der drei Capitäne, welche sich vor Ormuz von Albuquerque getrennt hatten, im Mai 1508 eine Untersuchung der Angelegenheit befohlen und Gonçalo Fernandez damit beauftragt. Im Verlauf derselben war Almeida immer mehr zur Ueberzeugung gekommen, daß Albuquerque durch seine Gewaltthaten die Interessen der portugiesischen Krone mehr schädige als fördere. Ein von den Portugiesen aufgebrachtes Schiff von Ormuz hatte Almeida wieder freigegeben und mit Briefen an den Regenten von Ormuz gesandt. Almeida’s Schreiben[105] athmete Freundschaft für die reiche Handelsstadt, wenn er auch wünschte, der Fürst möge seinem König jährlich ein Geschenk senden. Er sprach seinen Unwillen über die
  • 54. verderbliche Kriegführung Albuquerque’s aus und sicherte, indem er sieben Geleitsbriefe mitsandte, jedem Handelsschiffe von Ormuz seinen Schutz zu. „Ich will,“ schrieb er, „an dem König von Portugal zum Verräther werden, wenn ich dulde, daß ihnen auch nur ein Haar gekrümmt werde.“ Eine Abschrift dieses Briefes ließ Chodscheh Atar an Albuquerque übermitteln. Albuquerque bestand aber auf der Zahlung des Tributs und erklärte die Briefe des Vicekönigs für untergeschoben, weil sie dessen Unterschrift nicht trügen. Atar erklärte dagegen, die Stadt werde bereit sein, in Friedenszeiten den auferlegten Tribut von 15,000 Scherafinen zu zahlen; wenn aber ihr Handel gelähmt werde, könne sie die Summe unmöglich aufbringen. Die Briefe seien echt, des Königs Siegel und des Vicekönigs Unterschrift bürgten dafür. — Man weiß, welche Achtung man im ganzen Orient dem Siegel und Namenszuge eines Mannes zollt. Albuquerque setzte darauf die Blokade noch eine zeitlang fort und beunruhigte die Stadt in kleinen Gefechten; da er aber die Gewißheit hatte, daß ihm von Indien her keine Unterstützung kommen werde, und da er sah, daß es seinen Schiffen immer schwieriger wurde, sich zu halten, weil sie leck geworden waren, so entschloß er sich endlich den Kampf abzubrechen und nach Indien zu gehen. Ohne Zwischenfälle erreichte er die Andjediven, machte dort drei Tage halt und segelte dann nach Kananor, wo er den Vicekönig fand (im Dec. 1508). Leider mußte er hier erfahren, daß Almeida zwei von seinen rebellischen Capitänen in Freiheit gesetzt, und den dritten, um sich zu rechtfertigen, nach Portugal entsendet hatte. Da er zum Nachfolger im Commando ernannt worden war, so verlangte er die Uebergabe des Oberbefehls; aber Almeida, augenblicklich in der Ausrüstung seines Zuges gegen Goa begriffen und begierig, noch vor Ablauf seines Regiments die vor Tschaul den portugiesischen Waffen zugefügte Niederlage und den Tod seines Sohnes zu rächen, erklärte, er werde sein Amt nicht vor dem Schluß des laufenden Jahres niederlegen, auch sei das Schiff, auf dem er, der von Portugal ergangenen Weisung gemäß, zurückkehren solle, noch nicht angelangt. Dieses Schiff aber war, wie bereits berichtet ist, an der
  • 55. ostafrikanischen Küste gescheitert und untergegangen. Mißmuthig wartend zog sich Albuquerque nach Kotschin zurück. Kurz darauf, am 12. December 1508 brach Almeida mit neunzehn Segeln gegen Norden auf; später stießen noch vier Schiffe zu ihm, so daß seine Flotte nun dreiundzwanzig Schiffe mit 1600 Mann Truppen zählte. Noch vor Ablauf des Jahres wurde die Stadt Dabul erstürmt und entsetzlich verwüstet, so daß die Zerstörung dieser Stadt im Orient noch lange mit Schaudern erzählt und sprichwörtlich wurde als ein Beispiel unerhörter Vernichtung. Erst am 2. Februar 1509 kam das Geschwader vor Diu an. Im Hafen lagen die Flotten der Aegypter und des Statthalters von Diu, Melek Eias, vereinigt; auch der Samudrin hatte eine Anzahl bewaffneter Fusten zu Hilfe gesendet. Aber die drei Parteien trauten einander nicht, besonders Melek Eias spielte eine zweifelhafte Rolle. Am folgenden Tage drang Almeida in den Hafen ein und richtete seinen Angriff lediglich auf die ägyptischen Schiffe. Eins nach dem andern wurde geentert und versenkt, so daß der Flottenführer Hussein nur mit Noth dem allgemeinen Verderben entrinnen konnte. Er verließ heimlich sein Schiff, bestieg am Lande ein Pferd und jagte flüchtig nordwärts nach Kambaya. Als die Schiffe von Diu und Kalikut sahen, daß der Ausgang des Kampfes nicht mehr zweifelhaft blieb, und daß man sie vorläufig schonen wollte, zogen sie sich bei Zeiten zurück. Auch hatte sich Almeida dafür entschieden, Melek Eias vor Diu nicht anzugreifen, obwohl derselbe die Hauptursache gewesen, daß sein Sohn Lourenço gefallen war. Der Vicekönig mochte auch befürchten, durch einen Angriff auf Diu den Oberherrn des Landes, den König von Gudjerat, mit in den Krieg zu verwickeln. Ihm war vor allem darum zu thun, die mohammedanischen Aegypter aus den indischen Gewässern zu vertreiben; mit den einheimischen Fürsten hoffte er dann schon wieder in ein freundlicheres Verhältniß treten zu können. In diesem Bestreben kam ihm sogar das schlaue Verhalten Melek Eias entgegen, welcher sich nicht entblödete, den portugiesischen Sieger wegen seines Erfolges zu beglückwünschen und ihm seine Dienste anzubieten. Almeida begnügte sich daher auch, nur die Auslieferung der Portugiesen zu verlangen, die auf
  • 56. dem Schiffe seines Sohnes zu Gefangenen gemacht waren. Dieselben wurden auch alsbald durch Melek Eias zurückgesandt. Dann kehrte der Vicekönig nach Kotschin zurück. Hier erneuerte Albuquerque wiederum seine gerechte Forderung, ihm den Oberbefehl zu übergeben; aber Almeida zögerte immer wieder, weil das erwartete Schiff noch nicht angelangt sei. Erst als Fernão Coutinho im Oktober 1509 von Portugal mit vierzehn Schiffen in Kotschin einlief und bestimmten Befehl für den Wechsel des Obercommandos mitbrachte, trat Almeida von seinem Amte zurück und schiffte sich am 19. December ein. Aber er sollte die Heimat nicht wieder sehen. Das Schiff ging an der Westküste von Südafrika, in der Saldanhabai, vor Anker um Wasser einzunehmen. Dabei verwickelte sich die Mannschaft in einen Kampf mit den Hottentotten und 150 tapfere Streiter, darunter elf Hauptleute, welche in Indien Wunder der Tapferkeit gethan, wurden sammt dem Vicekönig von den nackten Wilden überwältigt und erschlagen. „Nie,“ so klagt de Barros, „erlitten die portugiesischen Waffen ein größeres Unglück!“[106] Almeida war ein tüchtiger Soldat, ein uneigennütziger, sittlich reiner Charakter und daher auch bei jedermann beliebt und hochgeachtet. Er sorgte väterlich für die Soldaten, aber er stellte auch an ihre Leistungen hohe Ansprüche. Ihre materielle Lage suchte er zu heben, denn ihr Sold war gering, und daher kamen häufig Desertionen vor. Der König war nur darüber unzufrieden, daß Almeida mit seinen Belohnungen nicht geizte. Dieser aber sah sich vielfach durch die von Portugal ergangenen Befehle in seinen Unternehmungen gekreuzt. Namentlich tadelte er das Verfahren der portugiesischen Verwaltung, ihm Höflinge zu senden, die nichts leisteten, aber in Indien alsbald höhere Stellen beanspruchten, ohne sie verdient zu haben. Dem König schrieb er: „Ich rathe Euch, dem Vicekönig, den Ihr sendet, mehr Vertrauen zu schenken, als mir zu Theil geworden ist, und keine Befehle zu erlassen, ehe Ihr Eure Rathgeber in Indien gehört habt.“ Er wollte alle Macht auf die Beherrschung des Meeres an der Westküste Indiens werfen und die Flotte nicht durch Operationen an
  • 57. der afrikanischen oder arabischen Küste zersplittert sehen. Daher seine Abneigung gegen Albuquerque, in welcher er durch die abtrünnigen Capitäne desselben bestärkt wurde. Als ihm der König befahl, Schiffe nach Malaka zu senden, erwiderte er, dazu habe er noch keine Zeit, in Indien gebe es noch genug zu thun. So handelte er stets nach einem festen Plane und ließ sich selbst durch directe Befehle, die von Portugal an ihn ergingen, nicht davon abbringen. Daß sein System mit ihm fallen würde, sah er voraus; denn sein Nachfolger schlug ganz andere Bahnen ein und erweiterte den Kampfplatz über die ganze Breite des indischen Oceans. In trüber Stimmung, erhöht durch die Erinnerung an den herben Verlust seines tapferen Sohnes, verließ der erste Vicekönig Indien und fand auf afrikanischem Boden ein tragisches Ende. 7. Affonso d’Albuquerque, Generalcapitän und Governador von Indien. Nachdem Almeida Indien verlassen hatte, traf Albuquerque in Gemeinschaft mit dem Marschall Coutinho seine Vorbereitungen, Kalikut anzugreifen und den Samudrin zu züchtigen; denn König Manuel hatte diesen Angriff dringlich befohlen. Fernão Coutinho ergriff diese Gelegenheit, sich in Indien mit Kriegslorbeeren zu schmücken, mit unverhohlener Freude. So wurde er des lästigen Commandos über die Handelsflotte ledig. „Seine Vorfahren hätten sich nicht mit Handel abgegeben, und er selbst habe auch keine Neigung für solches Gewerbe.“ Er war durch und durch Soldat und blickte mit Verachtung auf die Kriegsleistungen der Indier. Am Abend des 2. Januar 1510 erschien die vereinigte Flotte vor Kalikut, sie hatte, ungerechnet die indischen Hilfstruppen, gegen 2000 portugiesische Soldaten am Bord. Der Samudrin selbst war wahrscheinlich auf einem Feldzuge gegen einen benachbarten Fürsten von seiner Hauptstadt fern, als die drohende Macht vor seiner Residenz erschien. In der Nähe der Stadt, nicht fern vom
  • 58. Meere, lag auf einer Anhöhe das Schloß des Fürsten, welches in der Zwischenzeit durch Erdwälle verschanzt und in eine Festung umgewandelt war. Hieher mußte sich der erste Angriff richten, wenn die unbefestigte Stadt selbst dauernd gewonnen werden sollte. Coutinho forderte die Führung des ersten Treffens, er hoffte wohl allein mit der feindlichen Streitmacht fertig werden zu können. Albuquerque willigte nur ungern ein, weil er den Marschall als einen Hitzkopf kannte, der mit den indischen Kriegslisten noch zu wenig vertraut war und ohne viel Ueberlegung drauf los ging in der Erwartung, schon beim ersten Waffengange seine Gegner in alle Winde zu verjagen. Als aber am Morgen des 3. Januar die Ausschiffung der Truppen begann, zeigten sich die Nair doch so zäh im Widerstande und überschütteten ihre Feinde mit einem solchen Hagel von Geschossen, daß die Portugiesen bei ihrem Angriff sich zu theilen beschlossen. So kam es, daß indem beide Feldherren verschiedene Landungsplätze wählten, Albuquerque seine Leute eher ans Land geworfen hatte und zum Sturm überging als sein Waffengefährte. Nach einem erbitterten Kampf um den Wall, bei welchem schon viele Streiter fielen, drang der Generalcapitän zuerst in die Schanzen ein, ließ Feuer in die königlichen Häuser werfen und vertrieb die Indier aus der festen Stellung. Coutinho sah sich dadurch um den ersehnten Ruhm betrogen und nannte, vor Zorn und Schmerz glühend, jenen ein um das andere Mal einen wortbrüchigen Menschen, der anderen keine Ehre und Auszeichnung gönne. Albuquerque blieb bei diesen Schmähungen kaltblütig und wies darauf hin, daß man oft im Kriege gegen den vorgefaßten Plan handeln müsse, wenn der günstige Augenblick es fordere. Auch sei mit diesem ersten Erfolg der Sieg noch keineswegs entschieden. Der Gegner sei zwar zurückgewiesen, aber seine Macht noch nicht gebrochen. Allein Coutinho achtete nicht darauf, in blinder Aufregung gebot er sofort den Angriff auf die Stadt. Hier wollte er der erste sein und die Brandfackel in den großen königlichen Palast schleudern. In einem entfernten Stadttheile lagen auf einem freien Platze, von Mauern umgeben, die weitläufigen Gebäude des
  • 59. Fürstensitzes. Trotz des Widerstandes drangen Coutinho und seine Schaar durch Thor und Mauerlücken ein und legten Feuer an, worauf die Indier zurückwichen. Albuquerque folgte, nachdem er vorsorglich einen Theil seiner Mannschaft am Ufer zur Bewachung der Böte zurückgelassen hatte, durch Kampf in den Straßen der Stadt aufgehalten, langsam nach. Coutinho glaubte schon, im Besitze des Palastes, sich des vollständigen Sieges erfreuen zu können, und gestattete sorglos seinen Soldaten sich zu zerstreuen und die königlichen Schätze zu plündern. Darauf hatten aber die Indier gewartet; sie sammelten sich von neuem und gingen wieder zum Angriff über. Sie umzingelten in hellen Haufen den Palast und drangen endlich trotz der hartnäckigen Gegenwehr des portugiesischen Hauptmanns, dem die Bewachung des einen Thores übergeben war, wieder in den Hof ein und fielen über die zerstreuten Portugiesen her. Albuquerque konnte nur mit Mühe bis in die Nähe des Kampfplatzes vordringen und sandte Boten über Boten an den Marschall, um ihn zu eiligem Rückzuge aufzufordern. Dieser aber verachtete immer noch die drohende Gefahr und erwiderte, der Generalcapitän möge nur ruhig den Abmarsch antreten, er selbst werde folgen, wenn seine Mannschaft sich wieder gesammelt hätte. Selbst von allen Seiten umdrängt, wich Albuquerque langsam zurück. Der Rückzug ging durch einen Hohlweg, von dessen hohen Rändern aus die Indier mit Wurfspießen, Pfeilen und Steinen die Portugiesen überschütteten. Von Coutinho war er vollständig abgeschnitten und konnte nur auf sich selbst Bedacht nehmen, da seine Truppen sich weigerten, noch einmal den Versuch zu wagen, sich bis zu dem Marschall durchzuschlagen. Albuquerque wurde im Gewühl zuerst schwer am linken Arme verwundet, erhielt dann einen Pfeilschuß in den Nacken und mußte endlich, als ihn ein mächtiger Stein vor die Brust traf, besinnungslos fortgetragen werden. Der Marschall aber fiel mit 80 Kampfgefährten. So endigte, durch die Tollkühnheit Coutinho’s herbeiführt, dieser Angriff auf Kalikut als vollständige Niederlage; und hätte nicht Albuquerque am Ufer die Schiffe mit starker Mannschaft bewachen lassen und wäre die See nicht ruhig gewesen, so hätte der Ausgang des Tages für die
  • 60. Portugiesen dermaßen verhängnißvoll werden können, daß ihre ganze Machtstellung in Indien zweifelhaft geworden wäre. Nach dem Fall Coutinho’s erhielt Albuquerque auch das Commando über dessen Schiffe und begab sich nach Kotschin. Kaum war er von seinen Wunden genesen, so sann er auf neue Kriegspläne. Ende Januar 1510 waren 21 Schiffe ausgerüstet und bemannt. Es schien, als wollte er, dem Befehl seines Königs gemäß, nach dem rothen Meere segeln, um dort einer neuen ägyptischen Flotte entgegenzutreten. Aber der Generalcapitän hatte seine wahren Absichten nur geheim gehalten, um desto erfolgreicher einen unerwarteten Schlag zu thun. Er hatte sein Absehen auf G o a gerichtet, welches so ziemlich auf der Mitte der Westküste Vorder- Indiens und dazu in der Nähe der Andjediven gelegen, wohin die von Afrika herübersteuernden Schiffe meistens ihren Lauf richteten, besonders günstig erschien, um von hier aus das westliche Meer und die Straßen nach Ormuz und Aden zu beherrschen. Goa lag auf einer flachen, aber nicht feuchten Insel, welche durch die gemeinsame Arbeit mehrerer von den Westghats herabkommender Flüsse aus dem continentalen Ufersaume gleichsam herausgeschnitten war. Die Insel ist von Osten nach Westen ungefähr drei Meilen lang und von Norden nach Süden zwei Meilen breit. Das höhere, hügelige Land läuft gegen die See in eine Spitze aus. Die gegen das Meer bedeutend erweiterten Mündungen gestatteten den Zutritt der Flut um die ganze Insel. Die alte Stadt lag auf der Südseite, die neue Stadt war ungefähr vierzig Jahre vor der Ankunft der Portugiesen in Indien von Mohammedanern gegründet, die von der etwa 18 Meilen weiter südlich gelegenen Stadt Onor hieher geflüchtet und sich unter der Führung Melek Husseins hier angesiedelt hatten. Die Canäle, welche die Insel und Stadt umziehen, sind voll von Krokodilen und durften daher, wenn sie zur Ebbezeit durchwatbar werden, nur mit Vorsicht durchschritten werden. Alt-Goa ist jetzt fast ganz verlassen, nur Geistliche und Mönche wohnen noch dort zwischen den großartigen Ruinen zahlreicher Kirchen und Klöster. Der Hafen der neuen Stadt ist wegen seiner wunderbaren landschaftlichen Schönheit hoch gepriesen.
  • 61. Die Zeit zum Angriffe war von Albuquerque insofern sehr günstig gewählt, als der damalige Beherrscher Adil-Schah, der König von Bidjapur, nur wenig Truppen in der Stadt unterhielt. Die Bevölkerung des Hafenplatzes und die militärische Besatzung standen in ihren Interessen einander gegenüber. Als Albuquerque mit seiner Flotte vor der Einfahrt zum Hafen angelangt war, schickte er seinen Neffen Antonio de Noronha mit bewaffneten Böten voraus, um das Fahrwasser in den Canälen zu untersuchen. Bei einer Biegung des Flusses sahen sich die Portugiesen plötzlich der Citadelle von Pandjin gegenüber, welche nach der Seeseite die Stadt deckte. Unverweilt, ehe die Besatzung sich sammelte und die Kanonen bedienen konnte, gingen die Portugiesen zum Sturm über und drangen durch die Schießscharten und über den Wall in die Citadelle, welche, nachdem ihr Befehlshaber verwundet worden, von der Besatzung aufgegeben wurde. Der Generalcapitän hörte in der Ferne das Kampfgetöse und gab sofort Befehl, mit allen Truppen vorzugehen, fand aber bei seiner Ankunft den befestigten Platz bereits in den Händen der Seinigen. Die Truppen des Adil-Schah zogen sich auch aus der Stadt zurück, und ihr Anführer empfahl den Bürgern, sich ohne Gegenwehr zu ergeben, denn die abendländischen Feinde seien unwiderstehlich. So erschien schon am nächsten Tage eine Gesandtschaft von Bürgern vor Albuquerque und bot gegen Sicherheit des Lebens und Eigenthums die Unterwerfung an. Dieselbe wurde angenommen, doch wurde das vorhandene Kriegsmaterial als Beute erklärt, Albuquerque zog mit seinen Truppen in die Stadt und nahm den Palast des Statthalters in Besitz. Die eroberte Citadelle wurde verstärkt, und die Flotte ging im Hafen vor Anker. Die Schiffe wurden zum Theil sogar abgetakelt, damit während der Regenzeit das Tauwerk nicht zu sehr litte; denn Albuquerque gedachte längere Zeit in Goa zuzubringen. Inzwischen aber sammelte der Fürst des Landes ein größeres Heer und rückte zum Entsatz heran. Die Portugiesen konnten die unbefestigte Stadt nicht behaupten, und zogen sich auf die Schiffe zurück; aber gedeckt durch die Kanonen der Citadelle blieb die Flotte noch im Hafen liegen.
  • 62. Gegen Ende Mai trafen die Indier Vorkehrungen, dem Feinde den Rückzug abzuschneiden, sie versenkten Schiffe in dem unteren Theile des Canals, der zur See führte, und ließen brennende Flöße den Fluß hinabtreiben, um die portugiesischen Fahrzeuge in Brand zu setzen. Bei dieser drohender werdenden Gefahr mußte sich Albuquerque entschließen, vorläufig das Errungene wieder aufzugeben. Aber auch der Rückzug war mit bedeutenden Schwierigkeiten verknüpft. Einzeln mußten seine Schiffe zwischen den versenkten Fahrzeugen hindurch geführt werden und waren dabei unausgesetzt dem Feuer der Feinde preisgegeben, welche an beiden Seiten Schanzen aufgeworfen hatten. Diese mußten also erst erstürmt werden, um das Feuer der Gegner zum Schweigen zu bringen. Und selbst als dieses gelungen war, hemmte noch das seichte Wasser über der Barre das Auslaufen der Flotte in die See eine längere Zeit. Von allen Hilfsmitteln des Landes abgeschnitten, trat Mangel an Lebensmitteln und Wasser ein, der Mann bekam täglich nur noch vier Unzen Zwieback, und auf einigen Schiffen sah man sich sogar gezwungen, Jagd auf Ratten zu machen. Jeder Tropfen Wasser mußte mit Blut erkauft werden. Antonio de Noronha wurde durch einen Pfeilschuß verwundet und starb am dritten Tage, ein herber Verlust für Albuquerque, welcher seinen heldenmüthigen Verwandten sehr hoch schätzte. Zwar verrichteten noch manche Wunder der Tapferkeit und gewannen dadurch die Bewunderung ihrer Feinde; aber bei vielen griff Mißmuth und Verzagtheit dergestalt um sich, daß sie in ihrer Verzweiflung und von Durst und Hunger gequält, desertirten. Albuquerque bewies auch in dieser Noth seine Seelenstärke, feuerte seine Schaar durch Trostesworte immer von neuem an und theilte mit ihnen alle Entbehrungen und Gefahren. Erst im August gelang es ihm, über die Barre hinwegzukommen und die See zu gewinnen. Es war die zweite Niederlage, die er erlitten; aber sein Muth war nicht gebrochen und seine Absichten auf Goa behielt er im Auge. Vorläufig allerdings mußte er seinen Truppen Ruhe gönnen und wandte sich daher mit seiner Flotte südwärts zu dem befreundeten Hafen nach Kananor. Auf dem Wege dahin stießen vier Schiffe des Diogo Mendes de Vascogoncellos zu ihm, die von Portugal aus den Auftrag erhalten hatten, einen Streifzug nach
  • 63. dem berühmten Markte von Malaka zu unternehmen, weil man damals im Mutterlande noch nicht erfahren hatte, daß, wie wir später sehen werden, Lopez de Sequeira bereits jener Handelsstadt einen Besuch abgestattet hatte. In Kananor stieß dann noch ein zweites Geschwader zu ihm, welches unter der Führung des Capitän Gonçalo de Sequeira mit sieben Handelsschiffen und frischen Truppen im März von Lissabon ausgelaufen, aber ein Schiff an der afrikanischen Küste verloren hatte. Dieser Zuwachs an Macht bestärkte den Generalcapitän, einen neuen Angriff auf Goa zu machen. Vascogoncellos erklärte sich bereit, an diesem Zuge theilzunehmen, da der ihm gewordene Auftrag bereits erledigt sei. Gonçalo de Sequeira dagegen glaubte die Theilnahme ablehnen zu müssen, weil einerseits die meisten Schiffe Privatrhedern gehörten, welche nur, um Handel zu treiben, gekommen wären, und anderseits ihre nächste Hilfe dem Fürsten von Kotschin gehöre, welcher von einem Nebenbuhler, den der Samudrin mit Truppen unterstützte, hart bedrängt werde. Um diesen zweiten Grund sofort zu erledigen, ging Albuquerque mit einigen Schiffen und Mannschaften nach Kotschin und stellte die Ruhe und gesetzmäßige Regierung in kurzer Frist wieder her. Dann berief er in dieselbe Stadt einen Kriegsrath sämmtlicher Hauptleute, um sie für seinen Plan zu gewinnen. Dieser Rath trat am 12. October 1510 zusammen. Der Generalcapitän legte der Versammlung die Frage vor, ob sie nicht seinem Plane zustimmen wolle, während die Handelsschiffe in Kotschin ihre Gewürzfrucht einnähmen, alle verfügbare Mannschaft mit seinen Truppen zu vereinigen, um Goa von neuem zu erobern. Diese Berathung ist in der späteren Zeit von außerordentlichen Folgen gewesen. Hier war es, wo F e r n ã o d e M a g a l h ã e s sich entschieden für die Ansicht Sequeira’s aussprach und Albuquerque dadurch auf das empfindlichste verletzte: V o r dem 8. November werde man bei den augenblicklich herrschenden Gegenwinden schwerlich mit der Flotte vor Goa erscheinen können (— Albuquerque kam in der That erst am 24. November dahin —); dann
  • 64. werde aber die Rückfahrt der Handelsschiffe dermaßen verzögert, daß man entweder der am Kriegszuge betheiligten Mannschaft später keine Zeit lassen könne, ihre eigenen Angelegenheiten zu betreiben, um sich zur beschleunigten Abreise einzurichten, oder es werde der günstige Monsun verpaßt. Albuquerque erklärte dagegen aufs bestimmteste, er werde den nächsten Tag aufbrechen, er werde auch niemanden gegen seinen Wunsch zwingen mitzugehen, aber er wünsche deshalb diesen Zug so bald als möglich zu unternehmen, um mit der demnächst abzufertigenden Handelsflotte seinem Könige eine erfreuliche Botschaft aus Indien übersenden zu können. So blieben die A n s i c h t e n getheilt und der Generalcapitän gewann nur einen Theil der Stimmen für sich. Der Widerspruch Magalhães legte den Grund zu dem ungünstigen Urtheile, welches Albuquerque in einem Berichte an den König über jenen fällte, und welches wohl die Ursache war — denn wir kennen keine andere — daß Manuel späterhin, als Magalhães um eine bescheidene Erhöhung seiner wohlverdienten Pension nachsuchte, die Gewährung dieser Bitte verweigerte, wodurch der Bittsteller sich so sehr verletzt und zurückgesetzt fühlte, daß er seinem Vaterlande den Rücken kehrte und auf spanischen Schiffen seine berühmte, ja die berühmteste aller Weltreisen unternahm. Magalhães scheint bald nach dem Conflicte mit Albuquerque Indien verlassen zu haben, denn hier sah er von da an sich aller Gelegenheit beraubt, Aufzeichnung und Ruhm zu gewinnen. Die portugiesische Flotte, 23 Segel stark, erschien mit 1600 Mann Soldaten am 20. November vor Goa. Gaspar de Paiva hatte, mit drei Schiffen vorausgesandt, schon einige Zeit vor dem Hafen gekreuzt und kein Schiff weder hinein, noch heraus gelassen. In der Stadt war man auf einen heißen Kampf gefaßt. Ohne Zeitverlust ging Albuquerque zum Angriff über, schon am 25. November wurde die Citadelle erstürmt und die Insel besetzt; aber gewarnt durch die schlimme Erfahrung von Kalikut duldete er nicht, daß die Soldaten sich zerstreuten. Dann wurde auch die Stadt selbst von zwei Seiten
  • 65. angegriffen und erobert. Viele Einwohner verließen die Stadt, aber bei ihrer hastigen Flucht sollen in den seichten Durchgängen der Canäle mehrere Tausende umgekommen sein. Alles was mohammedanisch war, wurde in dem eroberten Platze ohne Gnade niedergemacht: Männer, Weiber und Kinder. Eine Moschee, mit Gefangenen angefüllt, wurde den Flammen übergeben, so daß alle in dem Gotteshause Befindlichen ihren Tod fanden. Dann ließ Albuquerque ein starkes steinernes Kastell erbauen und gab ihm, dem König zu Ehren, den Namen Manuel. Im Vertrauen auf die dadurch gebotene Sicherheit ließen sich bald, neben den befreundeten Indiern, welche nach dem Sturm zurückkehrten, auch Portugiesen dauernd an diesem Platze nieder, welcher von den Siegern zum Mittelpunkte der portugiesischen Macht in Indien erhoben wurde. Der Fall Goa’s machte auf die Fürsten der Nachbarschaft einen bedeutenden Eindruck, weshalb sie sich beeilten, die Freundschaft der neuen Herren zu gewinnen. Der König von Kambaya gab den Neffen des Generalcapitäns Affonso de Noronha, der sich in seiner Gefangenschaft befand, nicht nur ohne Bedingung los, sondern erklärte sich auch bereit, den Bau einer Festung in Diu zu gestatten. Es erschienen Gesandtschaften von Gudjerat, von Kalikut, selbst aus dem Binnenlande von Bisnaga, alle bezeugten ihre Friedensliebe und wünschten bezüglich eines friedlichen Handelsverkehrs in Unterhandlung zu treten. Da indeß der Samudrin den geforderten Bau einer portugiesischen Citadelle nicht zugeben wollte, so zerschlug sich mit diesem Fürsten die Verhandlung. Emir Hussein, welcher damals in Kambaya sich befand, kehrte nach Kairo zurück, da er alle Hoffnung aufgegeben hatte, in Indien noch wieder zum Siege zu gelangen, und der Sultan von Aegypten ließ gleichfalls mit dem weiteren Bau einer Flotte innehalten. So war die Wirkung der Eroberung Goa’s nach allen Seiten eine tiefgehende. Goa hatte nicht blos eine dauernde Besatzung von 400 Mann in der Burg, sondern wurde eine portugiesische Stadt, sie war Eigenthum ihres Königs, und die Fürsten Indiens mußten diesen
  • 66. staatlichen Besitz anerkennen. Und daß die Portugiesen die neuen Verhältnisse in Goa in ähnlicher Weise auffaßten, beweist die Thatsache, daß bald darauf eine Münzstätte in der Stadt errichtet wurde, wo nicht blos neues Geld geprägt, sondern auch alles indische Geld, wenn es allgemein gültig sein sollte im Verkehr, mit einem portugiesischen Stempel versehen wurde. Aber der portugiesische Feldherr war nicht gewillt, von Goa aus die friedliche Entwicklung seiner Macht zu leiten. Seine Blicke schweiften bereits über Vorder-Indien hinaus nach Malaka, welches als bedeutendster Gewürzmarkt Hinter-Indiens galt, und ohne dessen Besitz die Portugiesen nie das Monopol erwarben; denn von Malaka aus gingen die Handelsschiffe direct, mit Umgehung Vorder-Indiens, nach dem rothen Meere. Sollte also Goa gehoben und zum Mittelpunkte des Verkehrs in Vorder-Indien gemacht werden, dann konnte dies nur erreicht werden, wenn Malaka gleichfalls in portugiesischen Besitz übergegangen war. Diogo Lopez de Sequeira war der erste gewesen, der jenen fernen Handelsplatz erreicht hatte. Er war 1508 von Portugal mit vier Schiffen abgegangen, hatte unterwegs Madagascar besucht und langte im Frühjahr 1509 in Kotschin an. Der Vicekönig Almeida gab ihm noch ein fünftes Schiff, auf welchem Francisco Serrão, dessen abenteuerliche Reise nach den Molukken uns später beschäftigen wird, und Fernão de Magelhães dienten. Am 8. September desselben Jahres war Sequeira wieder von Kotschin aufgebrochen, war an Ceylon und den Nikobaren vorüber nach Nordsumatra gesteuert, wo er die Landschaft Pedir besuchte, denn Sumatra lieferte schon damals am meisten Pfeffer, und war endlich glücklich in Malaka angelaufen. Die Mauren gaben sich auch hier sofort alle erdenkliche Mühe, die Ankömmlinge zu verdächtigen, trotzdem wurden die Portugiesen wohlwollend aufgenommen, wenn auch der Sultan Mahmud durch seine Grausamkeit berüchtigt war und nicht blos seinen Bruder, sondern sogar seine Gemahlin hatte hinrichten lassen. Die Chinesen kamen den Portugiesen zuerst in freundlicher Weise entgegen. Es war das erstemal, daß man mit den Söhnen aus dem Reiche der Mitte zusammentraf. Die weiße Hautfarbe dieser Leute
  • 67. aus dem Osten, ihre unbefangene Art, sorglos zu den fremden Schiffen wie zu den asiatischen heranzurudern und den Kleinhandel zu eröffnen, selbst manche ihrer Sitten und ihre Tracht wollte mehr ans Abendland, als an den fernsten Osten gemahnen. Man darf nicht vergessen, daß die Chinesen damals noch keinen Zopf trugen. Damian de Goes (a. a. O. S. 300) fand eine Aehnlichkeit mit vlaamischen oder niederdeutschen Gewohnheiten, und ähnlich äußert sich auch Barros.[107] Man fand bei ihnen nicht den hemmenden Kastengeist, denn sie scheuten sich ja auch nicht, mit den Portugiesen aus e i n e r Schüssel zu essen. So war es natürlich, daß Europäer und Chinesen, beide in der Stadt Fremdlinge, sich einander freundschaftlich näherten, und daß diese ihren neuen Geschäftsfreunden die Warnung zukommen ließen, den Malayen nicht zu sehr zu trauen. Darum ging auch der portugiesische Capitän nicht selbst zur Audienz, sondern entsendete den Jeronimo Texeira, welcher indeß eine gute Aufnahme fand und vom Sultan ein Lagerhaus angewiesen erhielt, um von da aus den Handel mit den einheimischen Kaufleuten zu eröffnen. Die Portugiesen gingen dann ungehindert in der Stadt umher, waren aber leider unbedachtsam genug, sich auch nach der Kriegsflotte des Sultans umzusehen, was die Mohammedaner, und unter ihnen namentlich der abgefeimte Schatzmeister, sofort zu ihrem Vortheile ausbeuteten, um die Fremden als Spione zu verdächtigen. Mit Einverständniß des Sultans wurde ein Plan entworfen, die Portugiesen zu vernichten. Zuerst hoffte man den Anführer und einige der vornehmeren Offiziere bei einem Gastmahl überfallen und ermorden zu können, aber Sequeira lehnte die Einladung ab und entschuldigte sich mit Krankheit. Dann wollte man die portugiesische Mannschaft in der Stadt, an verschiedenen Orten, wohin man sie gelockt, um ihnen Lebensmittel zu verkaufen, einzeln überfallen, inzwischen aber auch eine Anzahl von kleineren Schiffen bereithalten, um das Geschwader der Fremden anzugreifen, wenn es von Mannschaft halb entblößt sei. Glücklicherweise gelang der Verrath nur zum Theil. Die Wache auf den Schiffen machte, als sie die Unruhe in der Stadt gewahrte, rechtzeitig Lärm, sodaß die Mannschaft an Bord augenblicklich zur Vertheidigung bereit war. Aber etwa 30 Portugiesen, die sich am
  • 68. Hafen und in der Stadt befanden, wurden theils getödtet, theils gefangen. Francisco Serrão, welcher sich in der Nähe des Landungsplatzes aufhielt, konnte sich nur mit einigen Matrosen retten, die übrigen mußte man vorläufig ihrem Schicksale überlassen, denn Sequeira fühlte sich keineswegs stark genug, die volkreiche Stadt anzugreifen; er begnügte sich damit, einige feindliche Schiffe in den Grund zu bohren und kehrte dann nach Vorder-Indien zurück. Als das Gerücht von der zweiten Eroberung Goa’s auch bis nach Malaka gedrungen war, ließ der Hafenmeister (Schahbender) den neunzehn noch am Leben befindlichen gefangenen Portugiesen eine bessere Behandlung zutheilwerden; ihre Freiheit erhielten sie aber erst wieder, nachdem Albuquerque die Stadt erobert hatte. An seinen Plan, gegen Malaka zu ziehen, wurde der Generalcapitän bald nach der Besitzergreifung von Goa in unangenehmer Weise erinnert, als der Capitän Mendes de Vascogoncellos, dessen kleines Geschwader ursprünglich nach Malaka bestimmt war, von dem Oberfeldherrn sich Urlaub erbat, um seinen Auftrag auszurichten. Albuquerque zögerte mit der Abfertigung, weil er entweder der Ueberzeugung war, daß ein so kleines Geschwader nicht die genügende Sicherheit auf Erfolg biete, oder weil er selbst erst noch mehr Mittel aufbieten wollte. Vascogoncellos wollte daher heimlich entweichen, ging bei Nacht mit seinen Schiffen über die Barre von Goa in See, wurde aber von einigen nachgesandten Böten eingeholt und sah sich genöthigt, dem strengen Befehl Albuquerque’s, zurückzukehren, Folge zu leisten. Er selbst blieb längere Zeit in Goa in Gefangenschaft, ein Steuermann aber und der Lotse wurden zur Strafe für diese Flucht an der Rae aufgeknüpft. Der Generalcapitän wäre am liebsten selbst nach Malaka sofort aufgebrochen; allein dem stand ein Befehl Don Manuels entgegen, einen Zug nach dem rothen Meere zu unternehmen, um diesen Handelsweg endlich für die Mohammedaner zu schließen. Er lief auch wirklich mit 23 Schiffen aus, sah sich aber durch widrigen Monsun zuerst aufgehalten und dann ganz an die Küste
  • 69. zurückgetrieben, so daß er wieder in Goa einlaufen mußte. Derselbe Monsun aber, welcher die Fahrt nach NW. nicht gestattete, begünstigte eine Expedition nach SO. und so entschloß sich Albuquerque kurzer Hand mit der schlagfertigen Flotte vor Malaka zu ziehen und sie für ihren Verrath an Sequeira zu strafen. Es war noch im Frühjahr 1511, als die Flotte von neunzehn Segeln, mit 800 Portugiesen und 600 indischen Hilfstruppen von Kotschin nach Malaka abging. Den Feldherrn begleiteten Antonio d’Abreu und Francisco Serrão, die späteren Entdecker der Molukken und Fernão Peres d’Andrade, einer der ersten Chinafahrer. Das Gebiet von Malaka war ursprünglich von Siam abhängig gewesen; die in früherer Zeit berühmte Hafenstadt Singapur war aber hinter Malaka zurückgetreten, seitdem sich im 15. Jahrhundert der Islam in diesem Gebiete verbreitet hatte, denn in Malaka herrschte der Glaube Mohammeds vor. Aber die ehemaligen Statthalter hatten sich seit fast 100 Jahren zu selbstständigen Herren aufgeworfen. Durch geschickte Begünstigung und Ausbeutung des Handels zu großem Reichthum gelangt, verwandte Mahmud seine bedeutenden Mittel auf die Gründung einer Kriegsflotte, welche ihm den Besitz des Hafens und die Herrschaft über die See sichern mußte. Nun dehnten sich die Handelsbeziehungen noch weiter aus, denn die Hauptnationen waren in freier Weise durch Berufsbeamte im Handel gedeckt. Diese Schahbender (Hafenmeister) vertraten China, Java, Kambaya und Bengalen. Die Handelsverbindungen reichten bis nach Japan, und der Platz wurde von allen umwohnenden Völkern besucht, nur nicht von den Siamesen, die sich immer noch mit dem Sultan auf Kriegsfuß befanden und ihren frühern Verlust nicht verschmerzen konnten. Das Königreich Malaka erstreckte sich etwa 100 Meilen an der Küste hin, reichte aber nirgends über 10 Meilen weit ins Binnenland. Die Stadt liegt sehr günstig an der Grenze verschiedener Monsune, denn in den chinesischen Gewässern herrschen andere Winde als im bengalischen Meere, daher sich hier ein natürlicher Sammelplatz für Araber, Inder und Chinesen bot. Die Häuser des Handelsplatzes dehnten sich eine Meile am Wasser hin, — es ist der
  • 70. Canal, welcher die hinter-indische Halbinsel von Sumatra scheidet. Ein Fluß trennte die Häusermenge in zwei Theile, aber eine Brücke verband wiederum beide Hälften. Albuquerque, welcher denselben Weg eingeschlagen hatte wie Sequeira, langte am 1. Juli vor Malaka an, bereits in Pedir auf Sumatra waren acht Portugiesen, die noch in Malaka gefangen gewesen waren und die Flucht ergriffen hatten, zu ihm aufs Schiff gekommen. Von ihnen erfuhr er auch, daß der Hauptanstifter des Verrathes, der javanische Hafenmeister, eine Intrigue gegen den Fürsten angesponnen und seine Verschwörung mit dem Leben bezahlt hatte; er erfuhr ferner, daß Sultan Mahmud 8000 Geschütze besitze, um die lange, dem Meere zugekehrte Seite kräftig vertheidigen zu können, daß er 30,000 Mann Soldaten und selbst Kriegselephanten zu seiner Verfügung habe. Albuquerque ließ sich durch die großen Zahlen nicht schrecken, sondern forderte ohne Umschweife die Auslieferung der noch zurückbehaltenen Gefangenen. Eine sofortige Erledigung würde im Orient als Feigheit angesehen sein; der Sultan weigerte sich also, ohne weiteres darauf einzugehen. Als Antwort darauf ließ der portugiesische Admiral die Häuser am Strande und die Schiffe im Hafen in Brand stecken. Dann gab man die Gefangenen frei und unter ihnen auch den Handelsfactor Ruy d’Araujo, einen Freund Albuquerque’s. Man war in der Stadt zu einem friedlichen Abkommen geneigt, aber die allzuhohen Forderungen der Portugiesen trieben zum Widerstande. Albuquerque verlangte nicht blos Schadenersatz für Sequeira, sondern auch noch 300,000 Cruzados Kriegskosten und überdies die Einwilligung in den Bau eines Kastelles. Im Rathe des Fürsten von Malaka, des alten Mohammed, waren, als diese Forderungen bekannt wurden, die Meinungen getheilt. Diejenigen, welche besonders den Handel nicht geschädigt sehen wollten, empfahlen Frieden und Geldzahlung, die andern, welche fürchteten, durch Zugeständnisse das Ansehen des Fürsten zu erniedrigen, forderten bewaffneten Widerstand. Mahmud überließ die Leitung seinem Sohne, und dieser hoffte, gestützt auf eine Heeresmacht von 30,000 Mann, auf das zahlreiche Geschütz und seine Kriegselephanten, den Angriff abschlagen zu können. Aber auf
  • 71. die fremden Kaufleute in der Stadt war kein Verlaß, selbst der javanischen Truppen war man nicht ganz sicher. Es war vorauszusehen, daß der feindliche Admiral, sobald er die Lage der Stadt und ihre Gruppirung richtig erkannt habe, seine Angriffe auf den gefährlichsten Punkt, auf die Brücke richten werde, welche die beiden Stadttheile mit einander verbindet. Denn wer sich der Brücke bemeisterte, war leicht auch Herr in der Stadt. Diese Verbindungsbrücke wurde darum verschanzt und stark mit Kanonen besetzt; aber trotzdem richtete, nach dem Rathe des Ruy d’Araujo, welcher bei seinem längeren unfreiwilligen Aufenthalt die Wichtigkeit dieses Punktes erkannt hatte, Albuquerque grade hieher seine ersten Angriffe. In der Morgendämmerung des St. Jacobstages, 25. Juli, gingen die Portugiesen in zwei Abtheilungen gegen die Stadt vor. Albuquerque mit seiner Schaar stieg in der Nähe der Brücke ans Land, João de Lima mit der zweiten Truppe weiter östlich bei einer steinernen Moschee, welche nicht fern vom fürstlichen Palaste lag. Wenn ihm der Angriff gelänge, sollte er sich auch gegen die Brücke wenden. An beiden Orten ward mit großer Hartnäckigkeit gekämpft. Die Malayen bewiesen sich tapfer, schossen vergiftete Pfeile und brauchten im Nahkampf den Kries. Sie fochten in einzelnen Haufen unter Anführung eines Hauptmannes. Albuquerque stürmte die Brücke und trieb die Malayen mit gefällten Lanzen nach der Vorstadt zu. João de Lima hatte einen schweren Stand und konnte nicht so rasch vordringen, er sah sich sogar genöthigt, persönlich am Kampfe gegen die Kriegselephanten theilzunehmen, welche dann auch, durch Lanzenstiche verwundet, auf die eigenen Truppen zurückgetrieben wurden. Dann erst erreichte er die Brücke und vereinigte sich mit dem Oberfeldherrn. Von den Dächern der nächsten Häuser wurde aber der Kampf noch fortgesetzt, bis man die umliegenden Gebäude in Brand gesteckt hatte und so die Feinde vertrieb. Allein von der Waffenarbeit erschöpft und fortwährend, bei dem Versuch, die Brücke durch Vertheidigungswerke zu sichern, durch erneute Angriffe der Malayen beunruhigt, sah Albuquerque bald die Unmöglichkeit, diesen wichtigen Platz auf die Dauer zu behaupten. Er gab also den Befehl zum Rückzug und zog sich auf die Flotte zurück. Einige seiner Hauptleute meinten nun zwar,
  • 72. nachdem der Sultan für die erste Verrätherei genügend gestraft sei, solle man mit günstigen Fahrwinden nach Vorder-Indien zurückkehren, denn an eine dauernde Besetzung dieses entfernten Platzes sei doch wohl nicht zu denken; allein sie wurden von der Mehrzahl überstimmt, welche sich für eine Fortsetzung des Kampfes entschied. Während der Vorbereitungen zum zweiten Angriffe hatte Mahmud allerorten neue Verschanzungen aufwerfen und mit Kanonen besetzen lassen, in den Straßen waren Minen und Fußangeln gelegt, um die Feinde bei ihrem Einbruche in die Stadt aufzuhalten oder zu vernichten. Am 10. August griff Albuquerque die Brücke zum zweitenmale an und obwohl man dieselbe hartnäckig vertheidigte, wurde sie doch endlich erobert und die malayischen Truppen gegen die steinerne Moschee hin vertrieben, wo sich in Gegenwart des Sultans das letzte verzweifelte Handgemenge entspann. Das Quartier der Kaufleute, darunter zuerst die Peguaner, begab sich alsbald unter den Schutz des Eroberers, aber die östliche, höher gelegene Stadt wurde nur langsam von den Malayen geräumt. Neun Tage dauerte der kleine Kampf in den Straßen noch fort, bis diese endlich von den eingeborenen Truppen aufgegeben wurden. Den Mauren wurde kein Pardon gegeben, denn die Mohammedaner waren auch hier die erbittertsten Gegner gewesen. Als Lohn für ihre Arbeit gestattete Albuquerque seinen Leuten, die Stadt drei Tage lang zu plündern. Dreitausend Kanonen fielen dem Sieger in die Hände. Zum Bau einer steinernen Burg wurden die Steine der im Kampf theilweise zerstörten Moschee verwendet, und weiteres Baumaterial aus den in der Nähe gelegenen alten Fürstengräbern genommen. In der Burg erhob sich ein fünf Stockwerke hoher, mit Blei gedeckter Thurm. Albuquerque gab ihr den Namen Famosa. Auch eine Kirche wurde errichtet und das Dach dazu von einem königlichen Grabmal genommen. Um den Handel wieder zu beleben und das Vertrauen in die neuen Verhältnisse zu wecken, wurden eingeborene Schahbender (Hafenmeister) ernannt, welche die handeltreibenden Nationen zu vertreten hatten. Um den Marktverkehr zu ordnen, ließ Albuquerque
  • 73. goldene und silberne Münzen prägen, denn unter den früheren Herrschern hatte es nur zinnerne Münzen gegeben. Die großen Silbermünzen hießen Malaquezes, die Goldmünzen, zu 1000 Realen, Catholicos. Durch diese zweckmäßigen Einrichtungen wurde der Handel bald wieder gehoben, und fremde Handelsschiffe liefen wieder in den Hafen ein. Mit den großen Staaten Ostasiens suchte Albuquerque in friedliche, freundschaftliche Beziehungen zu treten. Durch die Vertreibung des mohammedanischen Herrschers war er nur an die Stelle eines fremden Eindringlings getreten, welcher sich die Freundschaft der fürstlichen Nachbaren nicht erworben hatte; er hoffte also mit Recht, nicht als Feind der eingeborenen Dynastien betrachtet zu werden. Nach allen Seiten wurden Botschafter abgeordnet. Auf einer chinesischen Dschunke, welche nach Siam ging, segelte Duarte Fernandez, welcher mit Ruy Araujo gefangen gewesen war und in Malaka malayisch gelernt hatte, mit nach Siam. Er war der erste Portugiese, welcher diesen mächtigen hinter- indischen Staat betrat. Er sollte dem Könige von Siam die Eroberung von Malaka melden und zugleich die officielle Erklärung abgeben, daß die Kaufleute des Landes sich des besonderen Schutzes der Portugiesen erfreuen sollten und in Malaka’s Hafen willkommen sein würden. Fernandez wurde am siamesischen Fürstenhofe zu Ajuthia[108] wohlwollend aufgenommen, man zeigte ihm unter anderen Merkwürdigkeiten auch einen weißen Elephanten. Dann wurde er mit einem siamesischen Gesandten wieder zurückgeschickt, welcher außer Briefen an den König Manuel als Geschenke eine Krone, ein Schwert von Gold und einen kostbaren Rubinring überreichen sollte. Zur Erwiderung gingen mit demselben Gesandten reiche Geschenke wieder an den König von Siam zurück. Die Ueberbringer derselben, Antonio de Miranda d’Azevedo und Duarte Coelho, reisten zu Lande über Tenasserim nach Siam. Eine andere Gesandtschaft ging unter Ruy da Cunha nach Pegu, um auch mit diesem Reiche einen Vertrag zu schließen. Malayische Fürsten von Sumatra und Java beeilten sich ihre freundschaftliche Gesinnung für die
  • 74. Portugiesen ebenfalls durch Geschenke zu bethätigen. Nur mit Arakan, dessen Hafenstadt von João da Silveira angegriffen war, und mit dem Königreiche Atschin in Nord-Sumatra blieb man auf feindlichem Fuße. Das letztere Reich, in nächster Nachbarschaft von Malaka gelegen, unterstützte in der Folgezeit mehrfach die immer wiederholten Angriffe der vertriebenen Mauren auf die Stadt und suchte Jahrzehnte lang den Handel zu beeinträchtigen. Da die Chinesen schon bei dem ersten Besuche Sequeira’s in Malaka sich durchaus freundlichgesinnt bewiesen, so suchte Albuquerque auch mit China freundschaftliche Beziehungen anzuknüpfen. Doch unterblieb die Absendung einer Gesandtschaft noch in den nächsten Jahren. Dagegen ist gewiß, daß bereits 1515 das Reich der Mitte von portugiesischen Handelsschiffen aufgesucht wurde, welche zwar ihre Waaren absetzen durften, aber für ihre Mannschaft nicht die Erlaubniß erhielten, das Land zu betreten. Der Eindruck, den die Kunde von der Eroberung Malaka’s in Europa machte, war ein außerordentlicher. Derselbe wurde noch gesteigert durch eine pomphafte Gesandtschaft, welche König Manuel 1513 unter Tristão da Cunha mit großem Gefolge an den Papst Leo X. entsendete. Außer reichen mit Gold und Edelsteinen geschmückten kirchlichen Ornaten und schweren goldenen Gefäßen wurde bei dem prächtigen Einzuge der Gesandtschaft in Rom, am 12. März 1514, dem erstaunten Volke auch die gewaltige Thierwelt Indiens in Gestalt eines riesigen Elephanten, den man seit dem Alterthum in Italien nicht mehr gesehen hatte, eines Jagdleoparden, der auf einem reich aufgezäumten persischen Rosse saß — es war ein Geschenk des Königs von Ormuz — vorgeführt. Ein Herold mit den portugiesischen Abzeichen schritt in dem festlichen Zuge, der eine Huldigung des Orients vor dem Haupte der Christenheit vorstellen sollte, dem Gesandten voraus. Die Menschenmenge, welche um dieses Schauspiel zu sehen, herbeigeströmt war, hatte Kopf an Kopf alle Straßen dermaßen besetzt, daß der Zug kaum hindurchdringen konnte.
  • 75. Als derselbe endlich die Engelsburg erreicht, wurde mit allen Kanonen geschossen, daß der Donner der Geschütze und dichter Pulverdampf weithin über die Stadt rollten. Dann erschien der Papst an einem Fenster und nahm den Zug in Augenschein. Der riesige Elephant mußte vor Seiner Heiligkeit dreimal die Knie beugen, zu nicht geringer Verwunderung der Zuschauer.[109] Am folgenden Tage wurden die Geschenke in feierlicher Audienz überreicht durch den portugiesischen Abgesandten Diogo Pacheco, welcher bei dieser Gelegenheit eine glänzende Rede über die Waffenthaten seiner Landsleute in Indien hielt und dabei einen Brief seines Königs überreichte, in welchem gleichfalls die Siege Albuquerque’s verherrlicht waren. Nach der deutschen Uebersetzung (Die New Welt der Landschafften u. s. w. Straßburg 1534. Fol. 57) lautet der Anfang dieses Briefes folgendermaßen: Ein sendbrieff des mechtigsten vnd vnuberwintlichsten Emanuels des Königs jnn Portugal, vnd Algarbien von den sygen, die er gehabt hat jnn India vnd Malacha, zu dem Heyligsten jnn Gott vatter, vnd vnserm Herrn, Herrn Leoni dem zehenden des namens Babst zu Rom. „Wie vast wir vns mit Gott dem Herrn vnd dir frewen sollen, Allerheyligster vatter das erscheynet aus der bottschaft, die vnser Indische schiffrüstung bracht hat. Dweyl vnder dir Römischem Bischoff, und presidenten der Römischen vnd Christlichen Kirchen so wunderbarliche Ding, zu lob vnd eher dem Allmechtigen nach wunsch ergangen seind, das man dir billich zum lob und eher rechnet. Darumb hat vns fur billich angesehen, was in India sich verloffen hat, mit der Hilff Gots, vnd vnsern waffen zu deiner Heyligkeyt als zu eym Haupt der gmeynen Christenheyt vnd richtschyt aller Christlichen Religion kurtz vnd summarien weys zubeschreyben, das alle Ding nach jhrem werd geschetzt werden, vnd Gott dem Herren darumb gedanckt. Auch dz wir hoffen mögen tägliche merung deines lobs sambt zunemung des Christlichen glaubens vnd leren.“
  • 76. Es wurden also auch die indischen Siege als Glaubenssiege aufgefaßt; aber der Schauplatz dieser Kreuzzüge lag viel weiter im Osten, „am güldenen Chersoneso, in den auswendigsten Morgenländern“, wo durch die portugiesischen Waffen auch das Christenthum verbreitet werden sollte. Albuquerque’s Verdienst wurde mit höchster Anerkennung gepriesen. Der Generalcapitän Indiens stand damals auf der Höhe seines Ruhmes. In Asien und Afrika erscholl sein Name mit Schrecken, in Europa mit Bewunderung. Noch von Malaka aus wurden drei Schiffe am Schluß des Jahres 1511 abgesendet, um das letzte Ziel der Portugiesen, die G e w ü r z i n s e l n o d e r M o l u k k e n a u f z u s u c h e n. Das kleine Geschwader stand unter der Führung des A n t o n i o d ’ A b r e u. Derselbe hatte sich beim zweiten Sturm auf Malaka ausgezeichnet, war dabei durch einen Schuß in die Backe, welcher ihm mehrere Zähne und einen Theil der Zunge nahm, verwundet, hatte aber trotzdem nach Anlegung eines Verbandes sich am Kampfe wieder betheiligt. Wie diese erste Kundschaft nach den Molukken verlief, werden wir später im Zusammenhange mit den folgenden Vorfällen auf den Gewürzinseln zu schildern haben. Die Angelegenheiten zu Malaka ordnete Albuquerque der Art, daß er Ruy d’Araujo zum Richter und Factor (alcaide mór e feitor), Ruy de Brito Patalim zum Commandanten der Festung einsetzte. Die Besatzung belief sich auf 300 Mann, ebenso stark war die Mannschaft auf der dort stationirten Flotte von zehn Segeln, welche unter dem Befehle des Fernão Peres d’Andrade zurückblieb. Diese beträchtliche Macht war erforderlich, um Malaka gegen Angriffe von der Land- und Seeseite vertheidigen zu können. Und solche Angriffe waren um so mehr zu erwarten, als die Macht des früheren Herrschers keineswegs gebrochen war; denn Mahmud hatte sich auf Bintang, südöstlich von der alten Residenz Singapur, und sein Sohn Alaeddin in Dschohor festgesetzt, so daß sie von da aus die Straße nach den Gewürzinseln und nach China nicht nur beherrschten, sondern die Portugiesen in Malaka beständig beunruhigen konnten.
  • 77. Im Januar 1512 ging Albuquerque mit drei Schiffen nach Indien zurück. Auch nahm er eine Anzahl (gegen 60) javanischer Zimmerleute sammt ihren Familien mit, welche ihm beim Schiffbau dienlich sein sollten. An der gefährlichen Küste von Sumatra ging Albuquerque’s Schiff, Flor de la mar, auf einer Sandbank zu Grunde. Er selbst verlor alle Beute und Siegeszeichen in diesem Schiffbruche sammt den Manuscripten, in denen er seine Thaten aufgezeichnet hatte. Die Mannschaft rettete sich zwar auf das folgende portugiesische Schiff, aber die malayischen Zimmerleute benutzten die Gelegenheit zu einer Meuterei, bemächtigten sich des Fahrzeuges, auf dem sie segelten, mit Gewalt und gingen an der Küste von Sumatra ans Land. Albuquerque selbst erreichte in den ersten Tagen des Februar den Hafen von Kotschin. In Goa waren unterdessen, während der Abwesenheit des Oberbefehlshabers, die Portugiesen belagert worden und arg bedrängt. Die verhältnißmäßig kleine Besatzung von 450 Portugiesen und 1250 indischen Hilfstruppen wurde fortwährend beunruhigt und durch kleine Gefechte ermüdet. Sie verlor sogar zwei ihrer besten Hauptleute und sah sich genöthigt, den noch gefangen gehaltenen Diogo Mendes de Vascogoncellos seiner Bande zu entledigen und an die Spitze zu stellen. Die Feinde hatten der Stadt gegenüber eine starke Burg in Benestarim errichtet und drohten von da aus, die Fremdlinge zu vertreiben. Zum Glück kamen im Sommer 1512 nacheinander mehrere Schiffe mit Mannschaft und Lebensmitteln zu Hilfe, und als im August sogar eine größere Flotte von dreizehn Schiffen mit 1800 Soldaten einlief, gewann man allen Muth wieder und ging selbst zum Angriff über. Albuquerque durfte es daher wagen, seine Ankunft zu verzögern, um vorher die Handelsflotte nach Europa abzufertigen, und ging erst am 16. September mit sechzehn Segeln nach Goa. Sein Erscheinen änderte die Lage vollständig. Aus den bisher Bedrängten wurden wieder Bedränger und siegesgewisse Angreifer. Benestarim wurde erobert. Den portugiesischen Ueberläufern in der Festung hatte Albuquerque das Leben gesichert, aber er ließ ihnen zur Strafe, anderen zur Warnung, Ohren und Nase abschneiden, die
  • 78. rechte Hand, sowie den linken Daumen abhauen und schickte die Verstümmelten nach Portugal zurück. Benestarim wurde noch stärker befestigt und Goa bei dem folgenden Friedensschlusse an Portugal abgetreten. Der verhältnißmäßig leichte Sieg ist zum Theil auch der steten Eifersucht der dekhanischen Fürsten untereinander zuzuschreiben, die einerseits nie gemeinschaftliche Sache gegen die Abendländer machten, andererseits sich im Geheimen um die Freundschaft der Portugiesen bewarben. Dann wurde durch eine an der Küste kreuzende Flotte der Hafen von Kalikut gesperrt und dadurch der Fürst auch zur Nachgiebigkeit gezwungen. Dagegen begann Goa als Handelsplatz aufzublühen. Albuquerque hatte dafür gesorgt, daß nur nach Goa die Pferde aus Persien eingeführt werden durften. Die einheimischen Kriege wurden damals in Indien aber hauptsächlich durch Reiterei entschieden. Die indischen Fürsten waren also dadurch, daß Goa allein der Einfuhrhafen für Pferde wurde, auf den guten Willen und die Freundschaft der Portugiesen angewiesen, wenn sie ihre Reiterei verstärken wollten. In Portugal selbst erkannte man die Bedeutung Goa’s noch nicht, oder wurde durch falsche Berichte, die möglicherweise absichtlich von den Gegnern Albuquerque’s verbreitet wurden, über die wahre Sachlage getäuscht. Nur so erklärt es sich, daß Manuel in einem Schreiben an den Oberbefehlshaber anordnen konnte, Albuquerque möge mit seinen Hauptleuten wohl überlegen, ob Goa behauptet werden solle oder nicht. Goa sei ein ungesunder Ort und seine Behauptung koste unnützes Geld.[110] Man werde dadurch in immer erneute Kriege mit den nächsten Landesherren verwickelt und es werde sehr fraglich sein, ob jemals die Abgaben vom festen Lande eingezogen werden könnten, welche der Generalcapitän als nicht unbeträchtlich bezeichnet hatte. Albuquerque aber legte auf die Wiedereroberung Goa’s das größte Gewicht. Er schrieb dem Könige, daß dieser Sieg in Indien mehr gewirkt habe für die Macht des Königs, als alle Flotten, die seit fünfzehn Jahren dahin abgeschickt worden seien. Der Bund der feindlichen Fürsten sei dadurch gesprengt. Die Räthe des Königs wüßten die indischen Angelegenheiten nicht richtig zu beurtheilen. Ohne feste Stütze auf
  • 79. dem Lande sei in Indien die portugiesische Macht ohne Dauer. Alle Citadellen in Kotschin, Kananor und anderen Orten hielten in Werth und Bedeutung keinen Vergleich mit Goa aus. Er wisse wohl, daß er in Portugal Feinde habe; aber der König möge nicht auf sie hören; denn wenn Goa wieder aufgegeben würde, dürfte auch die portugiesische Herrschaft in Indien ihrem Ende nahe sein. Er verdiene mehr Dank vom Könige dafür, daß er Goa gegen Portugiesen vertheidige, als dafür, daß er es zweimal den Feinden abgenommen.[111] Osorio stellt bei dieser Gelegenheit folgenden interessanten Vergleich zwischen der Politik Almeida’s und Albuquerque’s an:[112] das Ziel beider Feldherrn ging auf die Verherrlichung und den Ruhm ihres Königs und der portugiesischen Waffen, sowie auf die Verbreitung des Christenthums in Indien; aber sie schlugen verschiedene Wege ein. Almeida wollte sich mit einem Stützpunkt am Lande begnügen und dagegen mit stets vereinigten Flotten die See beherrschen. Seine Truppen wollte er nicht in einzelnen Besatzungen zersplittern, welche von großen feindlichen Mächten leicht überwältigt werden könnten. Albuquerque aber strebte vor allem danach, Herr des Landes zu werden, in der festen Ueberzeugung, daß er dann auch über die See gebiete. Sein Blick ging dabei über das Nächstliegende hinaus. Er wollte nicht blos dafür sorgen, für die Gegenwart alljährlich kostbare Gewürzfrachten heimzusenden, er wollte diesen Handel auch für die Zukunft sichern. Dazu brauchte er eine imponirende Stellung auf dem Lande und damit verbunden eine vollkommene Beherrschung der wichtigsten Handelsplätze. Eine große Flotte, meinte er, könne in einem Sturme untergehen, eine feste Stellung auf indischem Boden sei sicherer. Ein solcher Platz sei aber nicht sicher, wenn er blos an sich fest sei, sondern erst dann, wenn man demselben auf verschiedenen Wegen Hilfe bringen könne. Solche Stützpunkte aber verminderten nicht, sondern stärkten auch die Machtstellung auf der See. Wie richtig Albuquerque’s Urtheil in Bezug auf Goa war, erwies sich in der Folgezeit, als Soliman von Aegypten Diu angriff und durch eine von Goa kommende Flotte zum Rückzug genöthigt wurde;
  • 80. 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! ebookultra.com