Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera download
Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera download
https://textbookfull.com/product/polymorphism-in-java-methods-
and-polymorphic-algorithms-applied-to-computer-games-1st-edition-
privitera/
https://textbookfull.com/product/applied-evolutionary-algorithms-
in-java-ghanea-hercock-robert/
https://textbookfull.com/product/research-methods-for-education-
gregory-j-privitera/
https://textbookfull.com/product/analysis-for-computer-
scientists-foundations-methods-and-algorithms-michael-
oberguggenberger/
https://textbookfull.com/product/analysis-for-computer-
scientists-foundations-methods-and-algorithms-second-edition-
oberguggenberger/
Numerical Algorithms Methods for Computer Vision
Machine Learning and Graphics 1st Edition Justin
Solomon
https://textbookfull.com/product/numerical-algorithms-methods-
for-computer-vision-machine-learning-and-graphics-1st-edition-
justin-solomon/
https://textbookfull.com/product/learning-java-through-games-1st-
edition-stanchev-lubomir/
https://textbookfull.com/product/research-methods-for-the-
behavioral-sciences-2nd-edition-gregory-j-privitera/
https://textbookfull.com/product/classic-computer-science-
problems-in-java-1st-edition-david-kopec/
https://textbookfull.com/product/genetic-algorithms-in-java-
basics-jacobson-lee-kanber-burak/
POLYMORPHISM IN
JAVA
POLYMORPHISM IN
JAVA
Methods and polymorphic algorithms
applied to computer games
Advanced level
Book information:
Title: Polymorphism in Java
Edition: 1st edition 2018
Author: Carlos Alberto Privitera
ISBN-13: 978-1725953420
ISBN-10: 1725953420
Date of the first edition: spring 2018
To my children
Foreword
This book stands out for teaching programming based on polymorphism. Abundant examples in
Java code and illustrative graphics of the main ideas related to the topic: Polymorphism in Java.
The book "Polymorphism in Java" aims to give a modern and updated vision when learning Java
and in the particular subject of polymorphic algorithms. Students, teachers and developers will be
able to find a sequence of design patterns that create and use polymorphic algorithms, these
design patterns can be applied to solving problems of computer systems and everyday life.
A professional in the Java language can benefit from the book "Polymorphism in Java" by finding
an innovative way to solve problems with polymorphic algorithms. The design patterns, analyzed
in this work, are based on the inheritance between classes. Currently the difficulties of the Java
language have been overcome to a large extent and it is easy to understand and apply.
The book aims to teach fundamental concepts of object-oriented programming with Java SE, in a
clear and practical way, significantly reducing the learning curve. In the process you will learn to
program computers and use the Java SE language.
Goals:
The present work aims that readers get strong knowledge in computer programming with the
Java SE language.
Get the reader to acquire practical skills by using advanced Java SE concepts.
Have the reader write computer programs based on object-oriented programming with the
Java SE language.
Level of the book: it is of advanced level. It requires knowledge of the basic details of the Java SE
language.
Content
Chapter I .......................................................................................................................................................... 13
Introduction ................................................................................................................................................. 13
Proposal for a basic architecture .............................................................................................................. 13
Design pattern based on inheritance ............................................................................................................ 14
Layered architecture to use a design pattern ............................................................................................... 15
Description of the design pattern based on the inheritance ......................................................................... 16
Types of relations between classes........................................................................................................... 16
Java has a keyword to declare each relationship ...................................................................................... 16
Criteria for building groups of configurations of patterns of architectures by layers ..................................... 16
What are abstract methods? .................................................................................................................... 16
What are abstract classes? ....................................................................................................................... 16
What is an interface? ............................................................................................................................... 16
There are two ways to declare abstract methods: .................................................................................... 17
How to overwrite methods that are abstract? .......................................................................................... 17
Criteria for assembling the different configurations of a design pattern ................................................... 17
What is a reference in Java? ..................................................................................................................... 17
What is an object in Java? ........................................................................................................................ 17
Structure of the book ................................................................................................................................... 18
Graphical representation of the groups of configurations of a design pattern .......................................... 18
Group number one of configurations ........................................................................................................... 19
Structure of the design pattern ................................................................................................................ 19
Configuration 1.1 - Create the object reference using the super class and the creation of the objects using
the subclasses. .................................................................................................................................... 20
Java UML diagram for 1.1 configuration – Variant 1: A reference, an object in memory ........................... 24
Source code for 1.1 Configuration – Variant 1....................................................................................... 25
Explanation of the most relevant lines of code in the 1.1 Configuration – Variant 1 .............................. 27
Java UML diagram for configuration 1.1 - variant 2: Many references, an object in memory by reference 34
Source code for configuration 1.1 - variant 2 ........................................................................................ 35
Explanation of the most relevant lines of code in configuration 1.1 - variant 2 ...................................... 36
Configuration 1.2 - References of objects and objects are created using the subclasses ........................... 38
Utility of configuration 1.2 .................................................................................................................... 39
Java UML diagram for configuration 1.2 ................................................................................................... 41
Código fuente para la configuración 1.2 ............................................................................................... 42
Explanation of the most relevant lines of code in configuration 1.2 ...................................................... 45
Group number two of configurations ........................................................................................................... 55
What happens if subclasses are declared with the abstract class modifier? .............................................. 55
Diagram of Java classes in UML - Configuration 2, possibility 1 (Inherit a pattern) .................................... 58
Source code of configuration 2, possibility 1 (Inherit a pattern) ............................................................ 59
End of chapter I - "How to use abstract classes in class inheritance" ................................................................ 62
Chapter II ......................................................................................................................................................... 65
How to use the classes that are of type Interface in the inheritance relation between classes? .................... 65
Group number three of configurations......................................................................................................... 65
What is an interface? ............................................................................................................................... 65
Example of an interface declaration: ........................................................................................................ 66
Configuration 3.1 - Creating the references of objects using the superclass and the creation of the objects
using the subclasses. ........................................................................................................................... 67
Characteristics of the configuration 3.1 - variant 1: a reference and many objects ................................ 67
Java class diagram in UML for configuration 3.1 - variant 1: a reference and many objects ....................... 68
Source code for configuration 3.1 - variant 1 ........................................................................................ 69
Explanation of the most relevant lines of code, pertaining to configuration 3.1 - variant 1 ................... 72
UML diagram in Java for configuration 3.1 - variant 2: many references and one object by reference ...... 79
Characteristics of the configuration 3.1 - variant 2: many references and one object by reference ....... 80
Source code for configuration 3.1 - variant 2 ........................................................................................ 80
Configuration 3.2 - Create references to objects and objects using subclasses.......................................... 82
Configuration utility 3.2 ........................................................................................................................... 82
How to implement the algorithms that are static? ................................................................................... 82
How to implement algorithms that are dynamic? ..................................................................................... 82
What is the static assignment of the reference? ....................................................................................... 82
What is the dynamic assignment of the reference? .................................................................................. 83
Class diagram in Java for configuration 3.2 - variant 1 .............................................................................. 84
Class diagram in Java for configuration 3.2 - variant 2 .............................................................................. 89
Source code for configuration 3.2 - variant 2 ........................................................................................ 90
Chapter III ........................................................................................................................................................ 93
Polymorphic algorithms that are mutable .................................................................................................... 93
What are mutable polymorphic algorithms? ................................................................................................ 93
What are mutable methods? ....................................................................................................................... 93
Class diagram for polymorphic algorithms that are mutable. Combination 1 - variant 1............................ 95
Source code that implements mutable polymorphic algorithms. Combination 1 - variant 1 ...................... 96
Class diagram in UML for mutable polymorphic algorithms. Combination 2 - variant 1 ........................... 100
Source code that implements mutable polymorphic algorithms. Combination 2, variant 1 ..................... 101
Chapter IV ..................................................................................................................................................... 105
Programming a computer game ................................................................................................................. 105
Polymorphic code of the game ............................................................................................................... 105
View of the computer game: Fly to the end................................................................................................ 106
Class diagram in Java for the Game: Fly to the end ..................................................................................... 107
Structure of folders and packages for the source code in Java .................................................................... 110
Source code in Java for the game view module .......................................................................................... 111
Source code for the classes that implement the client module ................................................................... 114
Source code for classes that implement the specialized behavior provider................................................. 118
Farewell words .............................................................................................................................................. 130
POLYMORPHISM IN JAVA
Chapter I
Introduction
In the construction of a software product, different structures are defined that determine the
architecture of the software that will be built. The basic structures in Java are the classes and the
relationships between the classes. Many times, a structure forms a recurring pattern in the
construction of a software product. A programmer attentive to identifying structures and patterns
can define an appropriate architecture to solve problems or build software. A proper architecture
is as important as the development process in software engineering.
A layer structure can determine an appropriate architecture to define specific functions that are
placed as strata; each layer can be replaced by a new layer without affecting the others. A precise
and unique communications interface must be defined between the layers.
Layer 3 - Polymorphism
Layer 3 is the layer where polymorphic methods and polymorphic algorithms are written. Layer 4
separates the implementation of the polymorphic algorithms from the implementation of the
solution of the problem; the polymorphic algorithms express different ways of using a solution of
a problem.
Página 13 de 130
POLYMORPHISM IN JAVA
Design pattern based on inheritance
Link
Superclass
Subclasses
Abstract methods
Interface
The image shows a generic representation of a design pattern based on the inheritance between
classes. Certain restrictions will configure different design patterns more suitable to be
implemented in Java.
Página 14 de 130
POLYMORPHISM IN JAVA
Layered architecture to use a design pattern
The following image shows an architecture made by layers. Each layer has a certain function to
implement, use and show the solution of a problem.
Link
Static Dynamic
polymorphic polymorphic
methods methods Superclass
Static Dynamic
polymorphic polymorphic Subclasses
algorithms algorithms
• Abstract methods
• Interface
Página 15 de 130
POLYMORPHISM IN JAVA
Description of the design pattern based on the inheritance
The configurations can be divided into three groups, the criteria used to assemble the different
groups of configurations is the declaration of abstract methods and the implementation of abstract
methods by superclasses or subclasses.
What is an interface?
The interface is a totally abstract class; it does not have Java code in its body. The interface declares
prototypes of abstract methods that will be inherited by other classes. Classes that inherit an
interface should overwrite the abstract methods and implement the missing code.
Página 16 de 130
POLYMORPHISM IN JAVA
Programmers usually link the declaration of the reference and the creation of the object in a line of
code. The following line of code is a declaration of a reference to an object and the creation of an
object instance: Rectangulo rectangulo = new Rectangulo(3, 4);
Página 17 de 130
POLYMORPHISM IN JAVA
Structure of the book
Design pattern
Mutable
Polymorphism Polymorphism
polymorphism
Group properties
Create references Create objects
Superclass
Subclass
Interface
Página 18 de 130
POLYMORPHISM IN JAVA
Group number one of configurations
In group number one, there are configurations where the superclass is declared abstract, within this
group there are two configurations. Configuration number one declares the object reference using
the name of the superclass and the creation of the objects using the constructors of the subclasses.
The second configuration creates the reference of objects and objects using the subclasses.
This group has the fundamental characteristic that it prevents to create an object using the
constructor of the superclass. When declaring the superclass as abstract, it is not possible in Java
to create an object of an abstract class. In this group all the objects that can be created must be
created using the constructors of the subclasses.
Group properties
Create references Create objects
Superclass (abstract) Yes Not allowed
Subclass Yes Yes
In group one there are two very interesting configurations that form an adequate architecture to use
the inheritance pattern between classes.
Each configuration of the group includes an additional restriction that forces to make a correct use of
the design pattern.
The design pattern must declare an interface of public methods that can be invoked by the classes
that want to access the pattern. The design pattern is a provider of behaviors.
The design pattern has to be encapsulated in a package and allow or restrict one of the following
four functions, depending on the problem you wish to solve.
In this book we will make a detailed study of the first two functions: 1) declare references of the
subclasses or the superclass, 2) declare objects of the subclasses or the superclass.
The possibilities of extension and changes in the design pattern will be left out of the study, in this
book. A detailed study will be made on the use of the design pattern by other classes. The classes
that will use the design pattern are called "clients."
Classes that are clients of the design pattern may implement polymorphic methods and algorithms.
Página 19 de 130
POLYMORPHISM IN JAVA
Configuration 1.1 - Create the object reference using the super class and the creation of the
objects using the subclasses.
In the configuration 1.1 a new restriction is added, in the new restriction it is not advisable to create
references of the subclasses. In this configuration there are two restrictions: it is not feasible to
create objects of the superclass and it is not recommended to create references of the subclasses.
If there is a reference there may be a specialized object in memory. The only reference works like a
pointer that goes through the objects one by one. To access a new object you have to destroy the
current object and build a new object.
Página 20 de 130
POLYMORPHISM IN JAVA
If you have an object reference that points dynamically to different objects, it can happen that the
use of memory is reduced but the work of the garbage collector Java is very arduous; On the
other hand, when many references to objects are created, the use of memory is more likely to
increase and the work of the garbage collector decreases.
Dynamic assignment of new objects to a single reference causes objects not referenced in memory
to be cleaned by the Java garbage collector.
If the problem to be solved needs to create references to the subclasses, it would be appropriate to
use the 1.2 configuration or another configuration of another group.
The dynamic assignment of the reference to a new object allows the application of the dynamic
polymorphism mechanism, using the unique reference, unique messages can be sent to different
specialized objects.
To apply or use the mechanism of the dynamic polymorphism, it is necessary to send messages to
the objects through the methods interface. Each object must implement the same methods
interface.
The messages are sent to the methods implemented in the objects, if all the objects implement the
same methods interface then it is feasible to send the same message to each object. Each object
will implement a different algorithm and behave differently even if the message sent is the same.
The programmers, are very creative, write algorithms based on objects that send messages.
Algorithms based on sending messages are called polymorphic algorithms. Do not confuse
message-based polymorphic algorithms with specialized algorithms that are implemented in the
objects that receive the messages. Polymorphic algorithms are programmed in clients that use the
class inheritance pattern; the specialized algorithms are programmed in the subclasses or
superclasses of the pattern.
Objects that receive messages from another object implement behavioral algorithms and algorithms
that send messages to another object are called polymorphic algorithms.
From the point of view of the classes we can say that there are classes, clients, that send messages
and classes, servants or suppliers, that respond to messages. The client classes implement
polymorphic algorithms and the supplying classes implement behavioral or specialized
algorithms.
Java classes have three mechanisms to implement interfaces of data access methods or algorithms
that they implement.
1. Inherit an interface: the Java keyword "implements" is used.
2. Declare abstract methods: the Java keyword "abstract" is used.
3. Declare public methods of access to private or encapsulated data.
Página 21 de 130
POLYMORPHISM IN JAVA
Layered Application Organization
Scheme that shows the relationship between: the algorithms that are polymorphic and the algorithms
that have a specialized behavior.
Supplier pattern
Implements behavioral
Client
algorithms
Implements
polymorphic Superclass
algorithms
Interface of abstract
methods
It is advisable to organize the system into at least two layers, one layer for classes that are clients
and another layer for classes that are suppliers.
The same reasoning can be used if the application was designed with three or more layers. The
packets may contain other packets so one layer may contain other layers or sublayers. In Java, a
package is a folder created by the Operating System.
Página 22 de 130
POLYMORPHISM IN JAVA
IDEs, (Integrated Development Environments), are tools that help create applications that will
contain Java code projects. The projects will contain packages and the packages will contain files
with source code written in the Java language.
Página 23 de 130
POLYMORPHISM IN JAVA
Java UML diagram for 1.1 configuration – Variant 1: A reference, an object in memory
Página 24 de 130
POLYMORPHISM IN JAVA
Source code for 1.1 Configuration – Variant 1
package app;
import patron.Figura;
import patron.Rectangulo;
import patron.TrianguloRectangulo;
System.out.println(figura.getClass().getName());
System.out.println(" Altura = " + figura.getAltura());
System.out.println(" Base = " + figura.getBase());
System.out.println(" Área " + figura.area());
System.out.println(" Color " + figura.obtenerColor());
Página 25 de 130
POLYMORPHISM IN JAVA
package patron;
import java.awt.Color;
//Niveles de control de acceso public para clases, una clase pública puede ser
accedida por cualquier clase de cualquier paquete
//Una clase sin modificador puede ser accedida por una clase de su mismo paquete
package patron;
import java.awt.Color;
@Override
public Integer area() {
return this.getAltura() * this.getBase();
}
Página 26 de 130
POLYMORPHISM IN JAVA
@Override
public Color obtenerColor() {
// TODO Implement this method
return color;
}
}
package patron;
import java.awt.Color;
@Override
public Integer area() {
return (this.getAltura() * this.getBase()) / 2;
}
@Override
public Color obtenerColor() {
// TODO Implement this method
return color;
}
Explanation of the most relevant lines of code in the 1.1 Configuration – Variant 1
This line of code indicates that the class Main{} belongs to the package called app, the package
called app will contain the classes of the layer named client.
package app;
Importing the classes from the package called patron. The package named patron will contain
the classes of the layer named proveedor. Unfortunately, the 1.1 configuration must have
access to all classes in the proveedor layer.
import patron.Figura;
import patron.Rectangulo;
import patron.TrianguloRectangulo;
Declaration of the Main{} class, the class named Main{} must be public. The JVM must find the
Main{} class to create a memory instance.
Página 27 de 130
POLYMORPHISM IN JAVA
Declaration of the constructor method called Main(), the Main() method must be public and
homonymous to the Main{} class. The JVM will search and execute the Main() method at the
time of creating an instance of the Main{} class.
Declaration of the constructor method, with the name of Main(). The Main() method must be
public and homonym to the Main{} class. The JVM will search and execute the Main() method
at the time of creating an instance of the Main{} class.
public Main() {
super(); //invoca el constructor de la superclase Object
}
Declaration of the reference to objects with the name of: unaFigura. The unaFigura reference is
of type Figure{}. The unaFigura reference is not pointing to an object instance.
Statement of the main() method, the main() method will be searched and executed by the JVM at
the time of instantiating the Main{} class.
Main main = new Main(); //el objeto main tiene información relevante a
la clase Main{}
This statement will point to the reference named unaFigura to the new object created by the
constructor named Rectangulo().
The following line of code will execute the Polymorphic method called polimorfismo() with the
parameter of type Figura{} and the argument of the type Rectangulo{}.
A method is polymorphic when the JVM must decide which method to execute depending on the
type of parameter and the argument type. The JDK cannot predict at design time which method to
run because it does not know the argument type of the parameter.
polimorfismo(unaFigura);
The reference, called unaFigura, is pointed to a new object created by the constructor named
TrianguloRectangulo(). The rectangle object does not have a valid reference and must be
cleaned by the garbage collector. A reference is polymorphic if it is feasible to change the
referenced object type.
Página 28 de 130
POLYMORPHISM IN JAVA
unaFigura = new TrianguloRectangulo(6, 8);
The following line of code executes the polymorphic method called polimorfismo(), the method
has the parameter of type Figura{} and the argument of the parameter of type
TrianguloRectángulo{}.
polimorfismo(unaFigura);
The following code declares the dynamic polymorphic method called polimorfismo(), the
dynamic polymorphic methods are characterized by having the parameters of a type and the
arguments can be of another type. The parameter is of type Figure{} and the arguments can be
of the type Rectangulo{} and TrianguloRectangulo{}. The dynamic polymorphic
methods have polymorphic algorithms; the polymorphic algorithms are characterized by having
different behaviors depending on the argument assigned to the parameter. Dynamic polymorphic
methods send messages and are received by the classes that are providers of the different
behaviors. The classes that are clients implement polymorphic algorithms and the classes that are
providers implement specialized behavior algorithms. The main feature of dynamic polymorphic
algorithms is that they change their behavior depending on the argument assigned to the
parameter.
Summary of Concepts:
• A method is polymorphic if it is overloaded in its parameters or arguments or both.
• An algorithm is polymorphic if it always sends the same message to classes that are
providers of behaviors. The class, client, Main{} sends messages getAltura(),
getBase(), area() y getColor() to classes that are providers of such behaviors.
• Classes that are customers implement polymorphic methods and algorithms, polymorphic
methods, and polymorphic algorithms send messages to classes that are providers of
specialized behaviors.
Página 29 de 130
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of Miracle Gold:
A Novel (Vol. 1 of 3)
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: English
MIRACLE GOLD.
MIRACLE GOLD.
A Novel.
BY
RICHARD DOWLING,
AUTHOR OF
IN THREE VOLUMES.
VOL. I.
LONDON:
WARD AND DOWNEY,
12, YORK STREET, COVENT
GARDEN, W.C.
1888.
[All rights reserved.]
PRINTED BY
KELLY AND CO., GATE STREET, LINCOLN'S INN FIELDS,
AND KINGSTON-ON-THAMES.
CONTENTS.
CHAP.
I.-- Too Late.
II.-- Voices of the Unseen.
III.-- An Offer of Marriage.
IV.-- On The Wing.
V.-- Mr. Leigh's Deputy.
VI.-- Oscar Leigh's Cave of Magic.
VII.-- The Negro Juggler.
VIII.-- The Juggler's Last Feat.
IX.-- "Only a Woman."
Leigh Promises One Visit and Pays
X.--
Another.
XI.-- Stranger than Miracle Gold.
XII.-- An Omen.
XIII.-- In Curzon Street.
MIRACLE GOLD.
MIRACLE GOLD.
CHAPTER I
TOO LATE.
"The 8.45 for London, miss? Just gone. Gone two or three
minutes. It's the last train up to town this evening, miss. First in the
morning at 6.15, miss."
"Gone!" cried the girl in despair. She reached out her hand and
caught one of the wooden pillars supporting the roof of the little
station at Millway, near the south-east coast of England.
"Yes, miss, gone," said the porter. He was inclined to be very civil
and communicative, for the last train for London had left, the
enquirer seemed in great distress, and she was young and beautiful.
"Any luggage, miss? If you have you can leave it in the cloak-room
till the first train to-morrow. The first train leaves here at a quarter
past six."
She did not speak. She looked up and down the platform, with
dazed, bewildered eyes. Her lips were drawn back and slightly
parted. She still kept her hand on the wooden pillar. She seemed
more afraid of becoming weak than in a state of present weakness.
The porter, who was young and good-looking, and a very great
admirer of female charms, thought the girl was growing faint. He
said: "If you like, miss, you can sit down in the waiting-room and
rest there."
She turned her eyes upon him without appearing to see him, and
shook her head in mechanical refusal of his suggestion. She had no
fear of fainting. For a moment her mental powers were prostrated,
but her physical force was in no danger of giving way. With a start
and a shiver, she recovered enough presence of mind to realize her
position on the platform, and the appearance she must be making in
the eyes of the polite and well-disposed railway porter.
"No. Oh, no!" she cried, starting back from him in alarm. Then
seeing the man retire a pace with a look of surprise and
disappointment, she added hastily, "I do not want a cab, thank you.
It is most unfortunate that I missed the train. Is it raining still?"
From where she stood she could have seen the rain falling on the
metals and ballast of the line; she was absolutely looking through
the rain as she asked the question, but she was in that half-
awakened condition when one asks questions and hears answers
without interest in the one or attention to the other. She knew heavy
summer rain was falling and had been falling for more than an hour;
she knew that she had walked two miles through the rain with only a
light summer cloak and small umbrella to protect her from it, and
she knew that she could not use a cab or fly for two reasons; first,
she could not spare the money; second, she durst not drive back, if
back she must go, for she must return unperceived. When she
thought of getting back, and the reason for concealment, an
expression of disgust came over her face, and she shuddered as one
shudders at a loathsome sight unexpectedly encountered.
It was almost dark now. Nine o'clock had struck. The straight
warm rain was falling through the dusky, windless air. It was an
evening towards the end of June--the last Wednesday of that month.
There was not a sound but the dull muffling beat of the rain upon
the roof. Not a soul visible but the girl and porter.
She took her hand away from the wooden pillar, and gathered her
cloak round her, in preparation for going.
"Can I do anything for you, miss? Have you far to walk?" asked
the man. Offering service was the nearest thing he could do to
rendering service.
She did not answer his question; she asked instead: "Do you think
the rain will stop soon?"
He glanced at the thin line of dull, dark, leaden sky, visible from
where he stood at a low angle between the roofs of the platform.
"No, miss, I don't think it will. It looks as if 'twould rain all night." If
she had been a plain girl of the dumpy order, or his own degree, he
would have tried to make himself agreeable by prophesying pleasant
things. But the high privilege of answering so exquisitely beautiful a
young lady demanded a sacrifice of some kind, and he laid aside his
desire to be considered an agreeable fellow, and said what he
believed to be the truth.
She sighed, moved her shoulders under the cloak to settle it, and
saying "Thank you," in a listless, half-awake way, moved with down
dropped eyes and drooping head, slowly out of the station, raised
her umbrella and, turning sharply to the left, walked through the
little town of Millway and under the huge beeches of a broad,
deserted road leading southward.
The trees above her head were heavy with leaves, the road was
very dim, almost dark, this night of midsummer. The perpendicular
rain fell unseen through the mute warm evening. A thick perfume of
multitudinous roses made the soft air heavy with richness. No sound
reached the young girl but the faint clatter of the rain upon the
viewless leaves overhead, the pit and splash of the huge drops from
the leaves close to her feet, and the wide, even, incessant dull
drumming of the shower upon the trees, looming dimly abroad in
the vapourous azure dusk of the dark.
After walking a while the girl sighed and paused. Although her
pace had not been quick, she felt her breath come short. The mild,
moist, scent-laden air seemed too rich for freshening life and cooling
the blood. She was tired, and would have liked to sit down and rest,
but neither time nor place allowed of pause. She must get on--she
must get back as quickly as possible, or she might be too late, too
late to regain Eltham House and steal unperceived to her room
there. To that hateful Eltham House, under which to-night rested
that odious Oscar Leigh. Oscar Leigh, the grinning, bold, audacious
man.
Edith Grace turned her attention for a moment away from her
thoughts to her physical situation and condition. She listened
intently. She heard the patter of the rain near and the murmur of it
abroad upon grass and trees. But there was some other sound. A
sound nearer still than the patter at her feet, and more loud and
distinct, and emphatic and tumultuous, than the roll of the shower
far away.
For a while she listened, catching her breath in fear, not knowing
what this sound could be. Then she started. It was much nearer
than she thought. It was the heavy, fierce, irregular beating of her
own heart.
At first she was alarmed by the discovery. She had never felt her
heart beat in this way before, except after running when a child.
Upon reflection she recollected that nervous excitement sometimes
brought on such unpleasant symptoms, and that the best way to
overcome the affection was by keeping still and avoiding alarm of
any kind. She would stand and, instead of thinking about the
unpleasantness and risk of going back to Eltham House, fix her mind
upon the events which prompted her flight. She could not hope to
keep her mind free from considering her present position, and the
occurrences leading to it, but it is less distressing to review the
unpleasant past than to contemplate a lowering immediate future.
Owing to the loss of the little money left her by her father, she
had been obliged to try and get something to do, as she could not
consent to encroach on the slender income of her grandmother, Mrs.
Grace, the only relative she had in the world. As she had been so
long with Mrs. Grace, she thought the thing to suit her best would
be a companionship to an elderly or invalid lady. She advertised in
the daily papers, and the most promising-looking reply came from
Mr. Oscar Leigh, of Eltham House, Millway, who wanted a companion
for his infirm mother. Mr. Leigh could not give much salary, but if
advertiser took the situation, she would have a thoroughly
comfortable and highly respectable home. Mr. Leigh could make an
appointment for a meeting in London.
"Me; I know it," broke in the old woman, bursting into tears.
"Yes, madam; but that is not what I was going to say. I was about
to say your granddaughter will have to do without me!" Here he
leered at Edith. "I am much occupied with my mechanical studies in
London, and am seldom at Eltham House. I hope you may be always
able in your heart to do without me." He was standing leaning his
misshapen, crooked body on his misshapen, crooked stick. He did
not move his right hand from his waist, into which it was packed and
driven by the weight of his body upon the handle of the stick. He put
his long, lean, left, dark hand on his right breast, and bowed low by
swinging himself to the right and downward on the crook of his
stick. "Miss Grace will see, oh! so little of me," he added, as he rose
and looked with his bold eyes at Edith and her grandmother.
"Oh!" cried the unhappy, tactless old woman, "I dare say she can
manage that."
"I dare say she can," he said, gazing at Edith with eyes in which
boldness and scorn seemed strangely, abominably blended, or rather
conflicting.
At the time she felt she could cry for joy at the notion of seeing
little of this hideous, deformed, monstrous dwarf.
The bargain was there and then completed, and it had been
arranged that she should go to Eltham House that day week.
This night that was now upon her and around her, this dull, dark,
heavy-perfumed, rain-drowned midsummer night, was the night of
that day week. Only one week lay between the visit of this
hunchback to their place in Grimsby Street, Westminster, and this
day. This morning she had left London and seen Millway for the first
time in her life. She had got there at noon and driven straight to
Eltham House, two miles south of the little coast town. The hire of
the cab had made considerable inroad on the money in her pocket.
The sum was now reduced to only a few pence more than her mere
train fare to London--not allowing even for a cab from Victoria
Terminus to Grimsby Street, Westminster. When she got to Victoria
she should have to walk home. Oh! walking home through the
familiar streets thronged with everyday folk, would be so delightful
compared with this bleak, solitary Eltham House, this hideous,
insolent, monstrous, deformed dwarf.
The girl shuddered and looked around her into the dim, dark
gloom abroad, beyond the trees where the grass and corn lay under
the invisible sky, and where the darkness of the shadow of trees did
not reach.
And yet, when she halted here, she had been on her way back to
Eltham House! There was no alternative. She had nowhere else to
go. For lack of courage and money she could not venture upon an
hotel. She had never been from home alone before, and she felt as
if she were in a new planet. She was not desperate, but she was
awkward, timid, afraid.
Wet and lonely as the night was, she would have preferred
walking about till morning rather than return to that house, if going
back involved again meeting that horrible man. All the time she was
in the house he had forced his odious, insolent attentions upon her.
He had followed her about the passages, and lain in wait for her
with expostulations for her prudery in not allowing him to welcome
her in patriarchal fashion to his house! Patriarchal fashion, indeed!
He had himself said he knew he was not an Adonis, but that he was
not a Methuselah either, and his poor, simple, paralysed mother told
her he was thirty-five years old. She would not take all the money in
the world to stay in a house to which he was free. At eight o'clock
that evening she had pleaded fatigue and retired to her own room
for the night. She then had no thought of immediate flight. When
she found herself alone with the door locked, she thought over the
events of the day and her position, and in the end made up her
mind to escape and return to town at once, that very evening. She
wrote a line to the effect that she was going, and placed it on the
dressing-table by the window.
Her room was on the ground-floor, and the window wide open.
Mrs. Brown, the only servant at the house, slept not in the house but
in the gate lodge. Mrs. Brown had told her the gate was never
locked until eleven o'clock, when she locked it before going to bed in
the lodge. So that if she got back at any hour before eleven, she
could slip in through the gate and get over the low sill of her bed-
room window. She could creep in and change her wet boots and
clothes and sit up in the easy-chair till morning. Then she could steal
away again, walk to the railway station and take the first train for
London.
She felt rested and brave now. She would go on. Heaven grant
she might meet no one on the way!
CHAPTER II.
VOICES OF THE UNSEEN.
Edith Grace gathered her cloak around her and began walking
once more. The road, under the heavy trees, was now blindly dark.
She had taken nothing out of that house but the clothes she wore,
not even her dressing bag. In the first place, she had not cared to
encumber herself; and, in the second place, if she by chance met
Mrs. Brown or Oscar Leigh, she would not appear to be
contemplating flight. She could write for her trunk and bag when she
found herself safely at home once more.
She was new to the world and affairs. She did not know or care
whether her action in leaving Eltham House was legal or not. The
question did not arise in her mind. If she had been told she had
incurred a penalty, she would have said: "All I own on earth is in
that house; but I would forego it all, I would die rather than stay
there." If she were asked why, she would have said: "Because that
odious, insolent man lied when he said I should see little of him. He
was the first person I met. Because he dared--had the intolerable
impudence to try and kiss me. Because, having failed in his attempt,
he pursued me through the house with his hateful attentions. I am
very poor. I am obliged to do something for a living. I am not a cook
or a dairymaid. My father was a gentleman, and my mother was a
lady. We come of an old Derbyshire family. I am a lady, and you can
kill me, but you cannot make me bow my head or shame my blood.
If, when he tried to kiss me in the hall, I had had a weapon, I should
have stabbed him or shot him. If I had a father or a brother he
should be chastised. I know nothing of the law, care nothing for it."
If she had been asked: "Do you think his offence would have
been less if you happened to be a cook or a dairymaid?"
And now, for want of a few shillings, she was returning to the
house from which she had fled in indignation and dread a little while
ago. She could not walk about all night in this unknown country. She
had not the means to secure accommodation at an hotel. She could
not spare money enough even for a cab from the railway station.
She had in her pocket no more than her fare to London, and a few
odd, useless pennies.
Dark and unfamiliar as the road was to Edith Grace, there was no
chance of her losing the way. It was an unbroken line from the little
town of Millway to Eltham House. A few by roads right and left made
no confusion, for they were at right angles. The road itself was not
much frequented by day, and by night was deserted. The heavy rain
of the evening kept all folk who had the choice under cover. From
the time the girl cleared the straggling outskirts of the town until she
gained the high hedge and gateway of her destination she did not
meet or overtake a soul.
With serious trepidation, she pushed the gate open and entered
the grounds. The gate groaned in opening and shutting, and she
was thankful that no dog found a roof in that house.
The tiny gate lodge was dark and silent. From this she judged
Mrs. Brown had not retired for the night. Mrs. Brown had told her
that when Mr. Leigh was not at home, and Mrs. Leigh had no
companion, she slept at the house. But that when there was either
Mr. Leigh or a companion, she always spent the night in her own
little home, the gate lodge. This night Mr. Leigh, his mother, and
Mrs. Brown believed a companion and Mr. Leigh would be in the
house. Well, there would be, but not exactly as it was designed and
believed by them. She had given no word--made no sign that she
was leaving. She had found her bed-room window open, and she
had not shut it. Owing to the warmth of the night, that fact was of
itself not likely to claim attention.
The few people who had ever asked Oscar Leigh why he kept so
large a house for so small a household, were informed by him, that
it was his white elephant. He had had to take it in lieu of a debt, and
he could neither sell nor let it at a figure which would pay him back
his money, or fair interest on it. Besides, he said his mother liked it,
and it suited him to go there occasionally, and forget the arduous,
scientific studies in which most of his days were spent in London.
But very little or nothing of Mr. Oscar Leigh or his affairs was
known in Millway. He had no friends or even acquaintances there,
and spoke to no one in the town, save the few tradespeople who
supplied the household with its modest necessities. Indeed, he came
but seldom to his mother's home; not more than once a month, and
then his arrival brought no additional custom to the shops of the
town, for he generally brought a box or hamper with him full, he told
the driver of the fly he hired, of good things from the Great Town.
The tradespeople of Millway would gladly have taken more of his
money, but they had quite as much of his speech and company as
they desired--more than they desired.
The rain and the soddenness of the gravel were in Edith's favour.
The sound of the rain would blunt the sound of her footsteps, and
the water among the gravel would lessen the grating of the stones.
She emerged from the cover of the trees, and hastened across
the open drive. She gained left-hand corner of the house, and
passed rapidly under the dining-room windows in the left side.
Should she find the sash of her room down? That would be a
distracting discovery. It would mean she should have to pass the
night in the open air. That would be bad enough. It would mean that
her flight had been discovered already. It might mean that Oscar
Leigh was now lying in wait for her somewhere in this impenetrable
darkness behind her back. That would be appalling--unendurable.
Hurry and see.
It was much easier to get out through that window than back
through it. But at last, after a severe struggle, she found herself in
the room. Strange it seemed that she should feel more secure here,
under the roof which covered this man, than outside. Yet it was so.
He might, in the dark, outside, spring upon her unawares. He looked
like a wild beast, like some savage creature that would crouch, and
spring, and seize, and rend. Here she felt comparatively safe. The
door was locked on the inside. She had locked it on coming into the
room hours ago. If she sat down in the old arm-chair she could not
be approached from behind. However, ere sitting down she must get
some dry clothes to put on her, and she must find them and effect
the change without noise or light. It was now past ten o'clock, and
no one in the house must fancy she had not gone to bed, or there
might be knocking at her door to know if she required anything. She
required nothing of that house but a few hours' shelter.
With great caution she searched where she knew her trunk lay
open, found the garments she needed, and replaced her wet
clothing with dry. This took time; she could not guess how long, but
as it was at length accomplished, and she was taking her first few
moments of rest in the easy-chair, she heard the front door shut.
Mrs. Brown had gone back to her lodge, and under the roof of
Eltham House were only Oscar Leigh, his paralysed mother, and
herself.
The banging of the front door made her shudder. The knowledge
that Mrs. Brown had gone away for the night increased the isolation
of the house. There were now only three people within its walls
instead of four, and this circumstance seemed to bring the
loathsome Oscar Leigh closer to her. She resolved to sit still. It was
eleven o'clock. It would be bright daylight in a few hours. As soon as
the sun rose she should, if the rain had ceased, leave the house and
wander about in the bright open daylight until the time to take the
first train for London. It would be dawn at three o'clock. From eleven
to three was only four hours. Four hours did not seem long to wait.
The chair she sat in was comfortable, spacious, soft. There was
little danger of her falling asleep. In her present state of excitement
and anxiety sleep would keep off. But even if she should happen to
doze, there was small risk. Nothing could be more unlikely than that
she should slip out of that capacious chair and attract attention by
the noise of her fall to the floor.
She sat herself further back in the chair to avoid the possibility of
such an accident. She had remarked during the day, that sound
passed easily and fully through the building, owing, no doubt, to the
absence of furniture from many of the rooms and the intense
stillness surrounding the house.
Until now, she had not noticed the utter silence of the place. All
day long she had been too much agitated to perceive it. She was
accustomed to the bustle and hum of Great London, which, even in
its quietest streets, day and night, never suffers solution of the
continuity of sound, artificial sound, sound the product of man. In
that deepest hush, that awful calm that falls upon London between
one and three in the morning, there may be moments when distinct,
individualized sound is wanting, but there is always a faint dull hum,
the murmur of the breathing of mute millions of men.
Here, in this room, was not complete silence, for abroad the rain
still fell upon the grass and trees with a murmur like the secret
speeding of a smooth fast river through the night.
She sat with her back to the partition between her and the dining-
room. She had not dared to move the heavy chair for fear of making
noise. The chair stood with its back to the partition. It was midway
between the outer wall of the house and the partition of the inner
hall. On her left, four yards from where she sat, rose a pale blue
luminous space, the open window through which she had entered.
On her right, at an equal distance, was the invisible door which she
had locked upon retiring hours ago. The large, old-fashioned
mahogany four-posted bedstead stood in the middle of the room,
between the door and the window. The outline of the bedstead
facing the window was dimly discernible in mass. No detail of it
could be made out. Something stood there, it was impossible to say
what. All the rest of the furniture was lost, swallowed up in gloom,
annihilated by the dark.
Of all this, beyond the parts of the bedstead fronting the window,
Edith could see nothing now. She sat with her hands folded in her
lap, her arms close to her side, her head resting on the back of the
chair. She closed her eyes, not from drowsiness, but to shut out as
much as possible the memory of the place, the thoughts of her
situation. She told herself she was once more back in her
unpretending little room in Grimsby Street. She tried to make herself
believe the beating of the rain on the trees and glass of the
conservatory and gravelled carriage sweep in front of the house was
the dull murmur of London heard through some new medium. She
should hear her grandmother's voice soon.
Edith Grace sat up in her chair and gasped with terror. The words
seemed spoken at her ear. The voices were those of Oscar Leigh, the
hunchback dwarf, and his mother, Mrs. Leigh, the paralysed old
woman! Whence came those voices? What was she about to hear?
For a moment Edith hardly breathed. She had to exercise all her
powers of self-control to avoid springing up and screaming. The
voices seemed so close to her she expected to hear her own name
called out, to feel a hand placed upon her shoulder.
"Yes," the voice of the man said, "I have made the drawings and
the calculations. It has taken me time. A great deal of time, mother.
But I am right. I have triumphed. I generally am right, mother. I
generally do triumph, mother." He spoke in a tone of elation that
rose as he progressed in this speech. His accents changed rapidly,
and there was a sound of some one moving. "But, mother, you are
tired. It has been a long day for you. You would like to go to your
room." His voice had fallen, and was low and guttural, but full of
eager solicitude and tenderness.
"Not tired; no, Oscar. I am feeling quite well and lively and strong
to-night. For an old woman, who has lost the use of her limbs, I
keep very well. When you are with me, Oscar dear, I do not seem so
old as when you are away from me, my son." The voice was very
low, and tremulous with maternal love.
"Old! Old!" he cried with harsh emphatic gaiety. "You are not old,
mother! You are a young woman. You are a girl, compared with the
old women I know in London, who would fly into a rage if you hinted
that they were past middle life--if you did not, in fact, say they were
young. Why, mother, what is seventy? Nothing! I know dozens of
women over eighty, and they keep up their spirits and are blithe and
gay, and ready to dance at a wedding, if any man should only ask
them. Up to sixty-five, a woman ages faster than a man, but once
over sixty-five, women grow young again." Towards the end his
voice had lost its tone of unpleasant excitement, it became merely
jocular and buoyant.
"My spirits are always good when you are here, my son. But when
you are away I am very dull. Very dull, dear. It is only natural for me
to feel dull, when half of my body is dead already. I cannot be long
for the world, Oscar."
"Nonsense," said the other voice gaily. "Your affliction has nothing
to do with death. The doctors say it is only a local disturbance.
Besides, you know, cracked vessels are last broken. You are
compelled to take more care of yourself than other women, and you
do take care of yourself, I hope. If you do not, I shall be very angry,
and keep away altogether from Eltham."
"I take every care of myself, Oscar dear. Every care. I do not want
to go away from you. I want to stay with you as long as I can. Oscar
dear, I hope it may be granted to me to see your children before I
die, dear." The voice was low and tremulous and prayerful. The
mournfulness of a mother's heart was in the tone.
"And when, my dear son, do you think the great clock will be
finished? Tell me all about it. It is the only thing in the world I am
jealous of. Tell me how it gets on. Have you added any new wonders
to it? When will you be done with it?"
The fright had by this time died out of Edith's heart. She now
understood who the owners of the voices were, why the speakers
seemed so near. Oscar Leigh was talking to his mother in the dining-
room. They both believed she was in deep sleep and could not hear,
or they forgot the thinness of the substance separating them.
Between the dining-room and where she sat was only the slight
panel of a folding door. This room, now a sleeping apartment, had
once been the breakfast-parlour. She had not in the daytime noticed
that the two rooms were divided only by folding doors. If she had
the alternative, she would have got up and left the room. But she
had no alternative. She would much rather not hear the words, the
voices of these two people. If she coughed, or made a noise, she
would but attract attention to herself, bring some one, perhaps,
knocking at her door. Nothing could be more undesirable than a
visitor, or inquiries at her door. If she coughed, to show the speakers
that she was awake, Mrs. Leigh, or he, might knock and speak to
her. Mrs. Leigh might, on some plea, ask to see her, ask to be
allowed to roll her invalid chair into the room, and then she would
find the tenant of it dressed for out of doors, the bed untossed, the
floor littered with the scattered contents of her trunk, the wet
bedraggled clothes and boots she had taken off. There was nothing
for her to do but to remain perfectly still. She was not listening, in
the mean or hateful sense of the word. She did not want to
overhear, but she could not help hearing. She could not cover her
ears, for that would shut out all sound, and the use of hearing was
essential to her own safety, her own protection, situated as she
found herself. Leigh had given her to understand he was a
mechanician. He was telling his mother of his work. He was about to
give her particulars of a clock upon which he was engaged. Let them
talk on about this clock. It was nothing to her. She was interested
intensely in the passage of time, but in no clock. She did not want to
hear of an hour-measurer, but of the hour-maker. She cared nothing
for man's divisions of time: she prayed with all her heart for a sight
of God's time-marker, the sun.
CHAPTER III.
AN OFFER OF MARRIAGE.
"About the clock," said Mrs. Leigh. "You were going to tell me
what new wonders you have added to it, and when the crowning
wonder of all was to be fixed."
"Something about the clock, dear. But, Oscar, do not mind telling
me about it now. You seem not well. Perhaps you had better rest
yourself. You can explain about the clock to-morrow."
"Oh, ay, the clock. Of course. I am quite well, mother. You need
not be uneasy about me. What was I going to tell you about the
clock?"
"You were going to tell me--I do not know really what. I asked
you when it would be completed. That is my chief anxiety, for then
you will be always here--always here, near me, my dear son."
"But why can't you come down and stop here always, my Oscar?
Surely your clock could be brought to Millway, and back to London
again when 'tis finished?" The voice of the woman was caressing,
pleading. "I have not very long to live, Oscar. Might not I have you
near me that little time?" The tone was tremulous and pathetic.
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.
textbookfull.com