Java the UML way integrating object oriented design and programming Else Lervik - Download the full set of chapters carefully compiled
Java the UML way integrating object oriented design and programming Else Lervik - Download the full set of chapters carefully compiled
https://ebookultra.com/download/object-oriented-design-with-uml-and-
java-1st-edition-kenneth-barclay/
https://ebookultra.com/download/object-oriented-software-engineering-
using-uml-patterns-and-java-2nd-edition-bernd-bruegge/
https://ebookultra.com/download/applying-uml-and-patterns-an-
introduction-to-object-oriented-programming-2ed-edition-larmen/
https://ebookultra.com/download/scientific-software-design-the-object-
oriented-way-1st-edition-damian-rouson/
Java Methods Object Oriented Programming and Data
Structures Third AP 3rd AP Edition Maria Litvin
https://ebookultra.com/download/java-methods-object-oriented-
programming-and-data-structures-third-ap-3rd-ap-edition-maria-litvin/
https://ebookultra.com/download/beginning-c-object-oriented-
programming-2nd-edition-dan-clark/
https://ebookultra.com/download/object-oriented-programming-in-c-4th-
edition-e-balagurusamy/
https://ebookultra.com/download/object-oriented-software-development-
using-java-principles-patterns-and-frameworks-2nd-edition-xiaoping-
jia/
Java the UML way integrating object oriented design and
programming Else Lervik Digital Instant Download
Author(s): Else Lervik, Vegard B. Havdal
ISBN(s): 9780470854884, 047085488X
Edition: English language ed
File Details: PDF, 58.13 MB
Year: 2002
Language: english
This page intentionally left blank
Java the UML Way
Integrating Object-Oriented Design and Programming
All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by
any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except under the terms of the Copyright,
Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court
Road, London, UK W1P OLP, without the permission in writing of the Publisher with the exception of any material supplied
specifically for the purpose of being entered and executed on a computer system for exclusive use by the purchaser of the
publication.
Neither the authors nor John Wiley & Sons, Ltd accept any responsibility or liability for loss or damage occasioned to any person
or property through using the material, instructions, methods or ideas contained herein, or acting or refraining from acting as a
result of such use. The authors and publisher expressly disclaim all implied warranties, including merchantability or fitness for
any particular purpose. There will be no duty on the authors or publisher to correct any errors or defects in the software.
Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley
& Sons, Ltd is aware of a claim, the product names appear in capital or all capital letters. Readers, however, should contact the
appropriate companies for more complete information regarding trademarks and registration.
A catalogue record for this book is available from the British Library
1 Introduction 1
1.1 Preliminaries for Reading This Book 2
1.2 Contemplating a Computer 3
1.3 Java Applications and Java Applets 5
1.4 JavaScript and JSP 6
1.5 How This Book is Structured 7
1.6 A Small Example Program 9
1.7 Examples of Applets 15
1.8 New Concepts in This Chapter 17
1.9 Review Problems 19
1.10 Programming Problems 20
2 Variables, Data Types, and Expressions 21
2.1 Example 22
2.2 Data and Variables 22
2.3 Algorithms, Programming Errors, and Test Data 26
2.4 Statements, Blocks, and Names 28
2.5 Variables and Constants 30
2.6 Data Types 34
2.7 Assignments and Arithmetical Expressions 40
2.8 Type Conversion 43
2.9 Calculations for Our Renovation Project 45
2.10 New Concepts in This Chapter 47
2.11 Review Problems 49
2.12 Programming Problems 49
3 Using Ready-Made Classes 51
3.1 Objects as Models of Reality 52
3.2 Using Ready-Made Classes 55
3.3 The Random Class 60
3.4 The String Class 63
3.5 Organizing Classes in Packages 70
3.6 Class Methods and Class Constants in the Java Library 71
3.7 Reading Data from the User 73
3.8 New Concepts in This Chapter 77
3.9 Review Problems 79
3.10 Programming Problems 79
4 Constructing Your Own Classes 81
4.1 Creating Classes 82
4.2 Programming a Class 85
4.3 Access Modifiers - Private and Public 91
Contents
16 Threads 499
16.1 Threads in Processes 500
16.2 Dividing Time Between Threads 502
16.3 Example of Threads in Use 503
16.4 Thread States 507
16.5 Communication Between Threads 508
16.6 Locks and Synchronization 510
16.7 More Control: wait(), notify(), and notifyAll() 515
16.8 Peeking at the Threads with JDB 519
16.9 New Concepts in This Chapter 521
16.10 Review Problems 522
16.11 Programming Problem 522
Appendices
A Using Java SDK and WinEdit 699
A.1 SDK 699
A.2 Running Applets 703
A.3 WinEdit 703
B Keywords 705
C Number Systems 707
D The Unicode Character Set 711
E HTML and Applets 713
F Exceptions to the Code Standard 717
References 719
Index 721
This textbook was designed for higher education in technological fields where Java
and object-orientation form the basis of programming education. This book covers
both basic and more advanced programming.
The book assumes a general familiarity with computers, operating systems, and
the most common tools (such as, for example, word processors and browsers).
Readers should be familiar with concepts like "file" and "directory" and know the
difference between internal memory (RAM) and storage (for example, the hard
disk).
A foundation in object-orientation
When using Java as an educational language, it makes sense for readers to deal with
object-oriented ways of thinking as soon as possible. To a large extent, modern
programming consists of using ready-made components and classes. It's possible
to make a Java program that draws geometric figures, displays images, and plays
sound files without using anything more complicated than sequential control
structure. We believe that graphics and graphical user interfaces will motivate
further study into both object-orientation and programming in general, more so
than difficult control structures and textual user interfaces.
Readers will be introduced to the Java API for the first time in chapter 3. We'll
introduce the standard JOptionPane class which makes it possible to create
programs with primitive graphical user interfaces. We'll also use the Random and
String classes. This will teach readers to use ready-made classes and at the same
time provide a general introduction to object-oriented ways of thinking.
Once readers have used ready-made classes, we believe they will want to find out
what these classes look like inside. We devote quite a bit of space to creating our
own classes, a broad and comprehensive topic. In chapter 4, the readers will get to
create their own applets with simple geometrical figures where they can control the
shape, colors, and fonts themselves.
With this as a foundation, more classes follow to demonstrate the need for
selection and loop control structures.
Preface
Software
The software necessary for writing Java programs can be downloaded free from the
Internet. This book builds on the Java 2 SDK. The SDK is available on Sun's Web
pages (http://java.sun.com/). This book explains how the package is used. In
addition, you'll need a good editor. Alternatively, you can use an integrated
development environment, for example JBuilder Foundation, which you can get
from Borland's pages on the Internet (http://www.borland.com/jbuilder/).
To develop dynamic Web pages with JavaServer Pages (chapter 21), the reader
needs a web server. The book gives instructions on installation and use of a free
web server, LiteWebServer from http://www.gefionsoftware.com/.
Teaching aids
The book includes several teaching aids: every chapter starts with the chapter's
learning goals and ends with a list of the new concepts introduced, review
problems, and more involved programming problems. In addition, most
subchapters end with shorter problems, where the reader is encouraged to actively
work with the material that was just covered.
The book's Internet page (see above) includes a set of overheads that go with
each chapter. The overheads are based primarily on the book, but also contain
some examples and figures not found in the book.
Preface
Intermediate topics
This part of the book will prepare readers to make comprehensive programs with
graphical user interfaces. This requires extensive use of the Java API and a thorough
understanding of the concepts in an object-oriented system (such as associations
and generalizations, for example).
Arrays of reference types are essentially different in their structure and behavior
from arrays of primitive data types. Therefore, we've chosen to treat these in a
separate chapter along with the ArrayList class, which is a class that hides
reference arrays with dynamic lengths. For many practical purposes, this class is
better suited than an ordinary array of reference type. Chapter 10 also covers classes
with prepared sort-and-search methods including classes that make it possible to
take a country's character sets into consideration.
Chapter 10 introduces further relationships between objects in the form of
associations. We emphasize a demonstration of the transition from class diagram
to program code.
Chapter 11 deals with communication between programs and data files. The
chapter covers both text and binary transfers as well as direct access to a file.
Serialization is a simple, but very useful technique that we'll cover here.
Chapter 12 deals with some of the more important topics in object-orientation,
namely inheritance and polymorphism. Modeling is important here. Readers will
learn the difference between association and generalization. It's important to
thoroughly understand the conceptual apparatus to program inheritance correctly.
With a solid foundation in object-oriented programming, readers should now
be in a position to understand the event model used to program graphical user
interfaces in Java. Chapters 13–15 cover this topic. The most common graphical
components are covered and emphasis is placed on distinguishing the classes that
describe the problem to be solved from the classes that describe the user interface.
Readers will create both applets and applications.
comments. Engineer Simon Thoresen wrote answers for well over 30 programming
problems. The solutions for many of the most complicated problems present
material that supplements the contents of the book.
We would especially like to thank the three lecturers who dared to believe that
this would become instructional material that they could use during the 1999/2000
school year: Assistent Professor Bjorn Klefstad, Associate Professor Jan H. Nilsen,
and Lecturer Grethe Sandstrak. Along with approximately 100 students, they
worked with preliminary and unfinished course materials—their experiences were
very helpful to us.
The chapter on JavaServer Pages is not a part of the Norwegian edition, and
Assistant Professor Tomas Holt has contributed to this chapter with tips and
comments in an indispensable way.
Translator Tara F. Chace did an excellent job in translating all the text from
Norwegian into English during a very short period. Thanks to her!
Else Lervik
and
Vegard B. Havdal
reduction
• Compile and run a small program you have entered into the computer
The sun was probably shining in San Francisco on the 23rd of May 1995, when the
head of research at Sun Microsystems, John Gage, and perhaps the Internet1
world's biggest celebrity, Netscape founder Marc Andreessen, officially presented
the programming language Java and associated technology.
It was no wonder that Gage was one of the two men on the stage, as the language
in question first saw the light of day during a research project at Sun named Green.
Andreessen had been part of the small group of students who made the first
graphical browser for the WWW (Web), Mosaic. This program, and its successor
Netscape, had revolutionized the computing world during the early 1990s. The
new cooperation between Netscape and Sun would let small programs written in
Java make Web pages interactive and more alive. These plans received a lot of
attention, and there were plenty of ideas about programming toasters over the
Web, and more.
Even today, Java is strongly associated with the Internet, and many people think
the language is exclusively for use on the Web. This is absolutely wrong. Java is a
complete programming language, with its own distinctive features, and more and
less typical fields of use.
1. If these words are new to you, there is a glossary of terms in section 1.8 of this chapter.
1 Introduction
Java is a young programming language. Six or seven years is not long. As a result,
computing professionals or students need to keep up with the continuing
evolution of Java and its associated programs. Writing computer programs in a
language that's undergoing constant refinement may seem like an impossible task,
but in the case of Java, it is not. This is thanks to the language's design and
philosophy. In this book, we hope to give you a basis for understanding this.
2. Keep in mind that Windows Explorer is often configured to hide the suffix of registered file types,
displaying a graphical icon instead. You can check this by looking at View, Options: Hide extensions
for known file types. We recommend not hiding the file extensions, to give you better control and
avoid confusion when several files have the same prefix.
1.2 Contemplating a Computer
we will start working with Java through a console window, you will have to learn
basic textual navigation. We will try to make this easy as we go along. If you need
to read more about this, do a Web search for "MS-DOS commands" or an
equivalent phrase. Or look at the book's Web pages on http://www.tisip.no/Java-
ThellmlWay/, where we have links to some primers.
When it comes to the physical construction of the computer, we have already
mentioned that there is usually a hard disk inside where files are arranged in
directories. Furthermore, it is good to know that there is a central "brain" called the
microprocessor and that the computer has internal memory that is often called RAM,
Random Access Memory. Another name for the microprocessor is CPU, Central
Processing Unit. It would be hard to avoid these terms in a book on programming.
The hard disk is an example of secondary memory. Even if we turn the computer
off, our data and programs will still be intact on the hard disk. All the contents of
the aforementioned internal memory disappear when the power is turned off. The
internal memory is used by the microprocessor to store the running programs, and
their data.
We have published additional information and numbered examples on the
Web. Hence we are assuming that the reader is familiar with using the Internet, at
least browsing a page on the Web and changing the basic configuration of the Web
browser. Try to go to http://www. tisip. no/JavaTheUmlWay/ and see if you can find
your way around.
Can stones speak? Can rocks make their voice to be heard? The
Lord said of His people on His entrance into Jerusalem, “If these
should hold their peace the stones would immediately cry out.” And
this is very much what those very stones are now doing; for the
stones of Palestine are beginning to speak with a voice so clear and
decisive that it seems a perfect marvel that any thinking man should
be able to resist their evidence. Now therefore, if God permit, we
will study their testimony; we will put the rocks into the witness-box,
and endeavour calmly to learn from them what they teach us of the
truth of God. There are three subjects on which their evidence is
conclusive—the geographical accuracy, the historical truth, and the
prophetic inspiration of the Scriptures. Let us examine them on all
three points, and may that divine Spirit who inspired the word of His
own great grace bring it home to our understandings and our
hearts!
It was one of the principles of the ancient Jewish law, that “in the
mouth of two or three witnesses shall every word be established.” I
have already exceeded that requirement in having brought before
you no less than five “witnesses” to establish the truth and
inspiration of the Scriptures; but I propose, if God permit, to
conclude my series with two more:
They shall be very simple witnesses, and to the eye of man quite
insignificant. They shall not have in themselves any apparent power
of testimony; but yet I believe they are intended to speak in words
of irresistible argument to all thinking men, and I trust will carry
home to the hearts of those who are not “willingly ignorant” the
most conclusive evidence of the truth of God. I refer to the two
Sacraments of the Lord’s appointment—Baptism and the Lord’s
Supper. In 1 John v. there appears to be a distinct reference to the
Jewish rule, and there are three witnesses mentioned as bearing
testimony upon earth—“the Spirit, and the water, and the blood.”
The passage is not an easy one, and it behoves us to speak with
caution. But I cannot help believing that by “the Spirit” is meant the
testimony of the Holy Ghost in His inspired Word; and by “the water
and the blood,” the two Sacraments, Baptism and the Lord’s Supper.
It is to the testimony of these two latter witnesses that I now
propose to refer; but we must remember there is nothing in either of
them of a conspicuous or ostentatious character. In neither one nor
the other is there anything like a material monument, nor anything
to attract the attention of “the world;” there is no erection of granite
or marble, nor any inscription like those on the stones from Nineveh;
but they are both simple acts of the simplest possible character. A
little water is all that is visible in the one, and a little bread and wine
in the other; and yet, though so simple, so insignificant, and so
absolutely without any visible monument, for the last eighteen
hundred years they have been bearing their testimony as
“witnesses” for Christ. Let us then conclude our series by the
examination of their evidence, and let us consider two points: (1)
Their present position; and (2) When and how did they acquire it?
May God so bless our study by the Holy Ghost as to bring home
conviction to all our hearts and understandings.
(1.) Their present position.
In order to realise this we must not confine our thoughts to our own
personal enjoyment of our own sacred privileges. We may come to
the Lord’s table as individuals, and find in the sacred feast such “a
strengthening and refreshing of our souls” as may be to us the most
conclusive and satisfactory evidence of the certain reality of the
grace of God; but our personal experience would be no evidence to
others, and our own enjoyment would not be regarded by the
sceptic as a proof; it would be evidence to ourselves, but not to him,
nor to the world at large. We must therefore take a wider range,
and consider only such evidence as lies within the cognizance of all
observing men. For this reason I have selected their position in the
Church of Christ at this present time. I am not about to ask you to
consider past history, but present facts; facts that may be tested by
every one, facts belonging to this enlightened nineteenth century;
and what I ask you to do is quietly and patiently to investigate facts.
Taking then our standpoint in this year of our Lord, 1883, we find
that the Church of Christ has been extending for just 1850 years,
and that throughout that time it has been spread by countless
agents, and in countless manners, in every direction throughout the
world. Starting as it did from Palestine, it has now taken root on
every continent, and it has borne the sacred Name of our blessed
Saviour into every quarter of the globe.
But while there has been this world-wide spread of Christianity, and
while there is at this present time this widely-extended
acknowledgment of the Name of the Lord Jesus, it is at the same
time perfectly obvious that there are within the Church of the
baptized immense diversities both of creed and practice. There are
different Churches standing aloof from each other. There is the
Church of Rome in conflict with what is called the Greek Church on
the one hand, and with us Protestants on the other. What is
commonly called the Greek Church consists again of many branches,
or is rather an aggregate of many independent Churches not united
under any one head. There is the original Greek Church, the
Russian, the Syrian, the Coptic, and the Abyssinian. So in the
Church of Rome there are various orders, besides the great division
between the secular and regular clergy; while we all know, to our
heartfelt sorrow, how those who are united in their love for the great
Scriptural principles of Protestant truth are still divided into various
denominations. Thus, looking at the Church of Christ as a whole, we
find it spread into so many places that it encircles the world; and
broken up into so many sections that it is hard to trace what we may
term any visible corporate union. There is separation as to place,
and divergence as to Church organisation.
But now we come to the wonderful and indisputable fact that,
notwithstanding all this separation and all this divergence in all
countries and many systems, wherever we find the name of Christ
there we find His own two Sacraments; and wherever we meet with
Christianity there we are sure to meet with Baptism and the Holy
Communion, God’s two witnesses to His inspired truth.
This is sufficiently wonderful if you think merely of the geographical
extension of the Church. The visible Church is spread amongst
different nations, in different climates, and with different habits;
some of which are leading the way in civilization and science, while
some are sunk in barbarism; some leading the thoughts of the
world, and some apparently never thinking at all; some absorbed in
trade, and some so completely without trade that they have not
even a currency. In some there are old churches that have existed
for centuries, and in some churches of modern formation recently
called into being through colonization and missions; and yet, though
the two Sacraments are so perfectly simple that there is nothing in
themselves to spread or perpetuate themselves, wherever you go
you find them. Place and space have made no difference. Go to
Europe, Asia, Africa, or America, it makes no difference; wherever
you go there you find God’s two Sacraments essentially bound up
with the Christianity of the people.
But what is more wonderful still, the divergences in the faith have
not destroyed them. There are different Churches most earnestly
opposed to each other, as the Church of England to that of Rome,
and the Church of Rome to that of Constantinople; but all have the
two Sacraments. So at home there are various denominations, sadly
disunited, and in some cases, I fear I must say, opposed; but yet
amidst them all there remains this remarkable fact, that, with one or
two perfectly insignificant exceptions, they all observe these same
two Sacraments. And what makes this more remarkable still is the
fact that throughout Christendom there are immense diversities of
opinion on the particular subject of these Sacraments; and there is
scarcely any subject around which controversy has raged more
fiercely. Both Baptism and the Lord’s Supper have been the subject
of sharp contention; and they have both been misinterpreted,
misrepresented, and misused. Desperate heresies have been
attached to them both, and they have become the battle-field for
most determined theological conflict; but, notwithstanding all this
confusion of tongues, the great fact still remains, that after eighteen
centuries of conflict, here they are still. Controversy has not
destroyed them; perversion has not put an end to them; separation
has not divided them; but in the midst of all disturbing forces they
remain. Wherever you find Christianity, there you find them. In all
parts of the world, and in all Churches on the face of the earth, they
are inseparably connected with the confession of Christ; and, as a
matter of fact, there is not a Church in Christendom which in some
mode or other does not observe them both.
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.
ebookultra.com