100% found this document useful (4 votes)
14 views

Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera download

The document provides an overview of the book 'Polymorphism in Java' by Carlos Alberto Privitera, which focuses on teaching programming concepts based on polymorphism and its application in computer games. It includes detailed explanations of design patterns, object-oriented programming, and polymorphic algorithms, aimed at advanced learners familiar with Java SE. The book also offers practical examples and a structured approach to learning Java programming, making it suitable for students, educators, and professionals in the field.

Uploaded by

reddipborne6b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
14 views

Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera download

The document provides an overview of the book 'Polymorphism in Java' by Carlos Alberto Privitera, which focuses on teaching programming concepts based on polymorphism and its application in computer games. It includes detailed explanations of design patterns, object-oriented programming, and polymorphic algorithms, aimed at advanced learners familiar with Java SE. The book also offers practical examples and a structured approach to learning Java programming, making it suitable for students, educators, and professionals in the field.

Uploaded by

reddipborne6b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Polymorphism in Java: Methods and polymorphic

algorithms applied to computer games 1st Edition


Privitera pdf download

https://textbookfull.com/product/polymorphism-in-java-methods-
and-polymorphic-algorithms-applied-to-computer-games-1st-edition-
privitera/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Applied Evolutionary Algorithms in Java Ghanea Hercock


Robert

https://textbookfull.com/product/applied-evolutionary-algorithms-
in-java-ghanea-hercock-robert/

Research Methods for Education Gregory J Privitera

https://textbookfull.com/product/research-methods-for-education-
gregory-j-privitera/

Analysis for Computer Scientists Foundations Methods


and Algorithms Michael Oberguggenberger

https://textbookfull.com/product/analysis-for-computer-
scientists-foundations-methods-and-algorithms-michael-
oberguggenberger/

Analysis for computer scientists foundations methods


and algorithms Second Edition 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/

Learning Java Through Games 1st Edition Stanchev


Lubomir

https://textbookfull.com/product/learning-java-through-games-1st-
edition-stanchev-lubomir/

Research Methods for the Behavioral Sciences 2nd


Edition Gregory J. Privitera

https://textbookfull.com/product/research-methods-for-the-
behavioral-sciences-2nd-edition-gregory-j-privitera/

Classic Computer Science Problems in Java 1st Edition


David Kopec

https://textbookfull.com/product/classic-computer-science-
problems-in-java-1st-edition-david-kopec/

Genetic Algorithms in Java Basics Jacobson Lee Kanber


Burak

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

First edition 2018

Author: Carlos Alberto Privitera

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

About the Author:


Carlos Alberto Privitera is a specialist in Java SE and has been dedicated to the construction of
computer systems with Java SE since 2000. He has extensive experience in teaching the Java
language. He has specialized in creating content to teach courses on the Java SE language.
It has the titles of:
 “Técnico Analista de Sistemas de información” awarded by the “Instituto Superior de
Informática 9-012”.
 “Licenciado en Educación” awarded by the “Universidad Nacional de Quilmes”.
 “Profesor en Ciencias de la Computación” awarded by the “Universidad de Mendoza”.
 “Magister en Ingeniería del Software” awarded by the “Instituto Técnico de Buenos Aires”.

All rights reserved:


This work is the intellectual property of its author and any partial or total reproduction without
written permission of the author is expressly prohibited.

Rights of third parties:


The mention of brands, companies and tools are not intended to infringe any type of ownership of
third parties, are mentioned in this book for educational and practical purposes in the process of
teaching and learning the Java SE language.

Additional material on the Web


 https://libropolimorfismoenjava.blogspot.com/
 https://github.com/carlosprivitera

Contact with the author of the book:


 carlosprivitera@yahoo.com.ar
Dedication:

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.

Recipients of the book


The book is aimed at anyone who wants to learn to program computers with Java SE, also the book
is very useful for people who want to teach the Java language. The professionals will find a
modern and updated work worthy of being studied and put into practice. Level of the book: it is
of advanced level. It requires knowledge of the basic details of 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.

The content of the book is applicable to all operating systems.

How to continue after learning the content of this book?


The learning of computer programming with the Java SE language is the gateway to learning
advanced content related to companies and corporate environments; it is advisable after learning
the content of this book to start learning Java EE, Java Web or Java for cell phones, if the reader
wishes.
Index of titles and subtitles

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.

Proposal for a basic architecture

Layer 1 - Application layer or view layer or software product


The layer of the software product is the layer that the user sees or should use, the application layer
provide the functionalities that the user has requested or wants. The application layer is a
concrete implementation of the design pattern. The application layer traditionally uses structured
algorithms, but this time the polymorphic algorithms will be added.

Layer 2 - Use the pattern


Layer 2 must create objects of the pattern type, some are objects created at runtime and others are
created at the design time of the application. Objects are considered artifacts that perform
different functions; an artifact can invoke different behaviors to the design pattern. The different
artifacts access a method interface. With access to the methods interface, polymorphic algorithms
can be written that provide functions to the application layer.

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.

Layer 4 - Pattern structure


Layer 4 - Pattern structure: Layer 4 is the design pattern that implements the strategy that solves the
problem that has been raised, the design pattern contains the specialized and traditional
algorithms. Different patterns can be implemented depending on the problem to be solved. A
pattern has the property of supporting the solution of many problems. A group of problems can
be solved by a single pattern. A very simple and useful pattern is the pattern that has a generic
superclass and many specialized subclasses in an algorithm. Java is a language that allows the
creation of hierarchical class structures, classes are related through inheritance.

Página 13 de 130
POLYMORPHISM IN JAVA
Design pattern based on inheritance

The following image shows a pattern of related classes through inheritance.

Layer 4 - Design pattern

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.

Layer 1 - Apply the pattern


Application (Software Product)
View of the pattern

Capa 2 – Mensajes al patrón


Use the pattern
• main () • Object factory
• test () • object store
• Object.myMethod () • artifacts

Layer 3 - Polymorphism Layer 4 - Design pattern

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

A design pattern based on inheritance has the following parts:


 A generic superclass
 Several specialized subclasses
 Algorithms implemented in subclasses or superclasses
 Inheritance relationship between the superclass and the subclasses using the Java keyword:
extends
 Interface: public methods of access to private data
 Interface: of abstract methods
 Interface: declaration of prototypes of methods
 Implementation relationship of the interface that declares prototypes of methods using the
Java keyword: implements
 Relationship of creation of objects between classes using the Java keyword: new

Types of relations between classes


1. The extension relationship joins two classes of the same type, one class extends another class.
2. The implementation relationship adds parts to a class; a class is added to another class to be
implemented as a component part of the class.
3. The object creation relation indicates that a class has an object reference to an object instance.

Java has a keyword to declare each relationship


1. extends: relation of equal or extension types or inheritance relation
2. implements: relationship of adding parts to a class or inheriting an interface
3. new: relation of composing or using objects for a class, classes have or use instances of
objects

Criteria for building groups of configurations of patterns of architectures by


layers

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 are abstract methods?


An abstract method has no body, { }. The method can not implement code since it has no body to
write Java code.

What are abstract classes?


A class is abstract if it is declared as abstract using the keyword: abstract, or if at least one
abstract method is declared in its body, { }. You can not instantiate objects of an abstract class.

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

There are two ways to declare abstract methods:


1. Declare methods using the keyword abstract
2. Declare prototypes of abstract methods in an interface

How to overwrite methods that are abstract?

There is a way to implement the missing code of abstract methods:


1. Overwrite abstract methods using the tag: @Override

Criteria for assembling the different configurations of a design pattern


The name of each configuration will depend on the creation of references to objects and the creation
of objects.

What is a reference in Java?


This line of code is a statement of a reference to an object: Rectangulo rectangulo = null;

What is an object in Java?


This line of code is a declaration to create an instance of an object, given a reference: rectangulo
= new Rectangulo(3, 4);

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

Graphical representation of the groups of configurations of a design pattern

Design pattern

abstract classes Interface

Group 1 Group 2 Group 3

Configurations Configurations Configurations

Variants Variants Variants

Mutable
Polymorphism Polymorphism
polymorphism

Definition of restrictions to assemble a design pattern

The restrictions are based on the possibility or impossibility of declaring:


2. References to objects
3. Instances of objects.

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.

Structure of the design pattern


The design pattern is based on a superclass and many subclasses and different combinations that
implement the interface of the abstract methods.

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.

1. Declare references of the subclasses or the superclass


2. Declare objects of the subclasses or the superclass
3. Inherit subclasses or superclasses for extension reasons
4. Overwrite the public methods of the design pattern for implementation reasons

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.

Java code to create the configuration 1.1

Variant 1 - a reference and an object in memory


SuperClase objeto = null; //crear una referencia única
objeto = new SubClase01(); //apuntar la referencia a un nuevo objeto

objeto = new SubClase02(); //apuntar la referencia a un nuevo objeto

objeto = new SubClase03(); //apuntar la referencia a un nuevo objeto

objeto = new SubClaseN(); //apuntar la referencia a un nuevo objeto

Variant 2 - many references and one object by reference


SuperClase objeto1 = null; //crear una referencia única
objeto1 = new SubClase01(); //apuntar la referencia a un nuevo objeto

SuperClase objeto2 = null; //crear una referencia única
objeto2 = new SubClase02(); //apuntar la referencia a un nuevo objeto

SuperClase objeto3 = null; //crear una referencia única
objeto3 = new SubClase03(); //apuntar la referencia a un nuevo objeto

SuperClase objetoN = null; //crear una referencia única
objetoN = new SubClaseN(); //apuntar la referencia a un nuevo objeto

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.

Properties of configuration 1.1


Create references Create objects
Superclass (abstract) Yes Not allowed
Subclass X (restriction) Yes

Utility of configuration 1.1


It is a suitable configuration for when there is a large number of specialized objects, each object has
the need to implement a particular or unique algorithm.

This configuration has two variants:


1. A reference and an object in memory (consumes little memory). The garbage collector has a
lot of work collecting old instances of unreferenced objects.
2. Many references and one object for each reference (consumes more memory). The garbage
collector has little work.

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.

• Polymorphic algorithms send messages, (clients)


• Specialized algorithms receive messages. (providers)

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

Public methods Subclasses


interface

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.

There are different ways to organize a Java application by layers:


1. A project with a package for all classes, (not recommended)
2. A project with two packages that will contain the classes assigned to each layer
(recommended)
3. Two projects in one application, one project for each layer. (Recommended for teams of
programmers or for large projects)

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.

Some popular IDEs to write Java code:


 JDeveloper: http://oracle.com
 NetBeans: https://netbeans.org/
 Eclipse: https://www.eclipse.org/
 IntelliJ: https://www.jetbrains.com/
 Visual Studio Code: https://code.visualstudio.com/
 Android Studio: https://developer.android.com/

Layer number one: client layer


• The package called "app" will contain the classes that are clients and the classes that
implement the polymorphic algorithms.

Layer number two: provider layer


• The package called "patron" will contain the inheritance pattern between classes.

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;

public class Main {


public Main() {
super();
}
private static Figura unaFigura = null;

public static void main(String[] args) {


Main main = new Main(); //el objeto main tiene información relevante a
la clase Main{}

//esto es un error, no es posible crear instancias de una clase


abstracta
//Figura figura = new Figura();

System.out.println("Polimorfismo dinámico o de referencia");

unaFigura = new Rectangulo(6, 8);


polimorfismo(unaFigura);

unaFigura = new TrianguloRectangulo(6, 8);


polimorfismo(unaFigura);

} //Fin del cuerpo del método main()

//Método polimórfico o sobrecargado por el argumento del parámetro


//El parámetro acepta tipos de argumentos distintos
//En algunas ocasiones el argumento es del tipo rectángulo
// y en otras es del tipo triángulo rectángulo

private static void polimorfismo(Figura figura) {

//Líneas polimórficas, tienen comportamiento distinto dependiendo de la


figura
//El compilador Java decide que comportamiento ejecutar dependiendo del
tipo

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());

} //Fin del cuerpo del método polimórfico


} //Fin del cuerpo de la clase Main{}

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

public abstract class Figura {

private Integer altura = 0;


private Integer base = 0;

public Figura(Integer b, Integer a) {


base = b;
altura = a;
//super();
}

public void setAltura(Integer altura) {


this.altura = altura;
}

public void setBase(Integer base) {


this.base = base;
}

public Integer getAltura() {


return altura;
}

public Integer getBase() {


return base;
}

public abstract Integer area();

public abstract Color obtenerColor();

package patron;

import java.awt.Color;

public class Rectangulo extends Figura {

private Color color = new Color(0, 0, 0);

public Rectangulo(Integer b, Integer a) {


super(b, a); //Acceder a la estructura de datos de la superclase
color = Color.orange;
}

@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;

public class TrianguloRectangulo extends Figura {

private Color color = new Color(0, 0, 0);

public TrianguloRectangulo(Integer b, Integer a) {


super(b, a); //Acceder a la estructura de datos de la superclase
color = Color.green;
}

@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.

public class Main {

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.

private static Figura unaFigura = null;

Statement of the main() method, the main() method will be searched and executed by the JVM at
the time of instantiating the Main{} class.

public static void main(String[] args) {

Main main = new Main(); //el objeto main tiene información relevante a
la clase Main{}

//esto es un error, no es posible crear instancias de una clase


abstracta
//Figura figura = new Figura();

System.out.println("Polimorfismo dinámico o de referencia, una


referencia muchos objetos, con recolector de basura");

This statement will point to the reference named unaFigura to the new object created by the
constructor named Rectangulo().

unaFigura = new Rectangulo(6, 8);

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);

} //Fin del cuerpo del método main()

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.

//Método polimórfico o sobrecargado por el argumento del parámetro


//El parámetro acepta tipos de argumentos distintos
//En algunas ocasiones el argumento es del tipo rectángulo
// y en otras es del tipo triángulo rectángulo
private static void polimorfismo(Figura figura) {

//Líneas polimórficas, tienen comportamiento distinto dependiendo de la


figura
//El compilador Java decide que comportamiento ejecutar dependiendo del
tipo
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());

} //Fin del cuerpo del método polimórfico

}//Fin del cuerpo de la clase Main{}

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.

Title: Miracle Gold: A Novel (Vol. 1 of 3)

Author: Richard Dowling

Release date: April 8, 2013 [eBook #42498]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by Charles Bowen

*** START OF THE PROJECT GUTENBERG EBOOK MIRACLE GOLD:


A NOVEL (VOL. 1 OF 3) ***
Transcriber's Notes:

1. Page scan source:


http://books.google.com/books?id=hT4VAAAAQAAJ
(Oxford University)

2. The diphthong oe is represented by [oe]

MIRACLE GOLD.

New Novels at the Libraries.


MARVEL. By the Author of "Molly Bawn." 3
vols.
FOR FREEDOM. By TIGHE HOPKINS. 2 vols.
MOLLY'S STORY; a Family History. 3
vols.
AN ADVENTURESS. 2 vols.
LADY STELLA AND HER LOVER. 3 vols.
ONE MAID'S MISCHIEF. By G. M. FENN. 3
vols.
UNCLE BOB'S NIECE. By LESLIE KEITH. 3
vols.
A VOICE IN THE WILDERNESS. By C.
FOTHERGILL. 3 vols.

WARD & DOWNEY, PUBLISHERS,


LONDON.

MIRACLE GOLD.
A Novel.

BY
RICHARD DOWLING,

AUTHOR OF

"The Mystery of Killard," "The Weird Sisters,"


"Tempest Driven," "Under St. Paul's," &c.

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.

"Thank you, I have no luggage--with me." She looked around


apprehensively, as though dreading pursuit.

"Would you like me to call a fly for you, miss?"

"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?"

"Yes, miss; heavy."

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.

The porter lingered in the hope of being of use. He had no


mercenary motive. He wanted merely to remain as long as possible
near this beautiful girl. He would have done any service he could for
her merely that he might come and go near where she stood, within
the magic radius of her eyes. Even railway porters, when they are in
quiet stations, are no more than other men in the presence of the
beauty of woman.

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.

The meeting took place at Mrs. Grace's lodgings in Grimsby


Street, Westminster, and although Miss Grace shrank from the
appearance and manners of Mr. Leigh, she accepted the situation.
The poor old grandmother was so much overcome by the notion of
impending separation between her and Edith, that she took no
particular notice of Mr. Leigh, and looked upon him simply as a man
indifferent to her, save that he was arranging to carry beyond her
sight the girl she had brought up, and who now stood in the place of
her own dead children who had clung to her knees in their curly-
headed childhood, grown-up, and long since passed away for ever.
Mr. Oscar Leigh was very short, and had shoulders of unequal
height, and a slight hunch on his back. His face was long and
cadaverous, and hollow-cheeked. The eyes small and black, and
piercingly bright. His expression was saturnine, sinister, cruel; his
look at one and the same time furtive and bold. His arms were long
to deformity. His hands and fingers long, and thin, and bony, and
where they were not covered with lank, shining black hair, they were
of a dull brown yellow colour. His teeth were fang-like and yellow.
His voice hollow when he spoke low, and harsh when he raised it.
His breath came in short gasps now and then, and with sounds, as
though it disturbed dry bones in its course. He drooped towards the
right side, and carried a short and unusually thick stick, with huge
rugged and battered crook. When he stood still for any time, he
leant upon this stick, keeping his skinny, greedy, claw-like hand on
the crook, and the crook close against his right side. He wore a
glossy silk hat, a spotless black frock coat, and moved through a
vapour of eau-de-cologne. His feet were large, out of all proportion
to the largest man. They were flat, with no insteps, more like a
monkey's than a man's. She would have pitied him only for his
impudent glances. She would have loathed him only she could not
forget that his deformities were deserving of pity.

"You will have one unpleasantness to endure," he had said. "You


will have to make your mind up to one cruel privation." He smiled a
hard, cruel, evil smile.

"May I know what my child will have to do without?" asked Mrs.


Grace. And then, without waiting for an answer, she said: "I know
what I shall have to do without."

"And what is that, madam? What will you have to do without?"

"I shall have to do without her."

"Ah, that would be a loss," he said, with hideous, offensive


gallantry. "You are to be pitied, madam. You are, indeed, to be
pitied, madam. Miss Grace will have to make up her mind on her
side to do without----"

"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.

It was impossible for her to stay at Eltham House, utterly


impossible. This man Leigh had told her he should see little or
nothing of her at the place, and yet when she reached the house his
was the first face and figure she laid eyes on. He had opened the
door for her and welcomed her to Eltham House, and on the very
threshold he had attempted to kiss her! Great heavens! it was
incredibly horrible, but it was true! The first man who had ever
dared to try to kiss her was this odious beast, this misshapen fiend,
this scented monster!

Ugh! The very attempt was degradation.

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?"

She would have answered: "I am not concerned to answer in a


purely imaginary case. I am not a cook or a dairymaid. I am a lady.
All I know is that attempting to kiss me was an unpardonable
outrage, and if he ventured upon such an attempt again I should kill
him if I had a weapon by me. Yes, kill him!"

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 unshaded carriage-drive from the gate to the house was


winding, and about a hundred yards long. A straight line across the
ill-kept lawn would not measure more than fifty paces. Edith chose
this way because of the silence secured to her footsteps by the
grass, and the additional obscurity afforded by its darker colour. In
front of the house ran a thick row of trees and evergreen shrubs. So
that in daylight, when the trees were in leaf, the ground-floor of the
house was hidden from the road, and the road from the ground-floor
of the house.

The house itself was of modest appearance and dimensions. In


the front stood the porch and door, on each side of which was a
window. On the floor above were three windows, and in the roof
three dormers. On the right hand of the hall lay the drawing-room,
on the left-hand side the dining-room, behind the drawing-room the
library, which had been converted into a sleeping chamber for Mrs.
Leigh, who, owing to her malady, was unable to ascend the stairs.
Behind the dining-room stood the breakfast parlour, which had been
converted into a sleeping chamber for Mrs. Leigh's companion, so
that the companion might be near Mrs. Leigh in the night time. At
the rear of the companion's sleeping chamber was a large
conservatory in which the invalid took great delight, seated in her
wheeled chair. Behind the library was the kitchen, no higher than the
conservatory. The back walls of the breakfast-room and library
formed the main wall of the house. The conservatory and kitchen
were off-builds, and separated from one another by a narrow
flagged yard, in which were a large uninhabited dog kennel, water
butts, a pump, and ashbin. Beyond the flagged yard lay a large,
neglected vegetable garden. The flower garden spread beneath the
conservatory, and on the other side of the house to the right of the
kitchen, as one looked from the lawn, languished an uncared-for
orchard.

The floor above consisted wholly of bed and dressing-rooms,


except the large billiard-room, in which there was no table. Above
the first floor nestled a number of attics, for servants and bachelors
in emergency. Only two of the bedrooms on the first floor were
furnished, and the attic story had been locked up all the time Mrs.
Brown acted as lodge-keeper, about five years.

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.

Edith Grace walked straight to the left hand corner of Eltham


House, and looked carefully through the trees and shrubs before
venturing out on the drive. Not a soul was stirring. She could hear
no sound but the rain which still fell in heavy sheets. No light was
visible in any room, but whether this was due to the absence of light
inside, or to heavy curtains and blinds she could not say. Against the
glass of the fan-sash in the porch a faint light, like that of a weak
candle or dimmed lamp, gleamed, making a sickly solitary yellow
patch upon the black, blank front of the house.

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.

Thank heaven, the window was open!

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.

The room was large and lofty. It was wainscotted as high as a


man could reach. Above the wainscot the wall was painted dark
green. A heavy cornice ran round the angles of the walls. From door
to window was twenty feet. From the partition against which she sat
to the wall opposite her was twenty-four feet. The curtains of the
bedstead were gathered back at the head and foot posts.

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.

"Have you done, Oscar?"

"Yes, mother. I have finished for the night."

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 so you shall, mother," he said briskly, cheerfully. "I mean to


astonish you soon. I mean to marry a very handsome wife. I have
one in my eye already, mother." He added more gravely, "I have a
very handsome wife in my eye. I mean to marry; and I mean to
marry her. You know I never make up my mind to do anything that
in the end does not come off. But before I marry I must finish my
great work. When I have put the last touches to it I shall sell it for a
large sum, and retire from business, and live here with you, mother,
at my ease."

"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.

"Soon, soon, mother. I shall be finished soon. I cannot tell exactly


when, but not very far off. I see the end of my labours, the reward
of all my study, the fruit of all my life," said the voice of the
hunchbacked dwarf.

There was a pause in the speech. "Hah," breathed Leigh, in loud


inspiration. Then there was a snuffing sound, and another loud
inspiration. "Hah! that is refreshing--most refreshing. Will you have
some, mother? Do. You won't? Very well. What was I saying?"

The strong, subtle vapour of eau-de-cologne penetrated through


the slits and joints of the folding-doors, and floated past Edith
towards the open windows.

"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."

"What?" cried the voice of the dwarf, loudly, harshly, angrily.


"What do you know of the crowning wonder? Tell me, woman, at
once!" His tone was violent, imperious, threatening.

"Oscar! Oscar! What is the matter? What do you mean by calling


me 'woman'? Oscar, my son, are you ill? What is the matter? Why do
you look at me in that way? You are crushing my hand. What is the
matter, Oscar, my own boy?" The woman's accents were full of
alarm.
"Agh! Agh! Pardon me. Agh! Pardon me, my dear mother. Agh!"
he coughed violently, hoarsely. "The spirit of the eau-de-cologne
must have gone down my throat and caught my breath. I am quite
right now. Pray excuse me, mother. What was I saying?"

"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."

"Certainly; when I sell my unrivalled clock, I'll give up living in


London and come down here to you, mother, and become a private
gentleman."

"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.

"Dear, dear mother," he said softly, tenderly. "I cannot--I cannot


move the clock. You forget how large it is. I have told you over and
over again it would half fill this room. Besides, I have other business
in London I cannot leave just now. I will come as soon as ever I can.
You may take my word for that. Let us say no more on that subject
at present. I was going to explain to you about my marvellous clock.
Let me see. What have I already told you?"

"Oh, it was too wonderful to remember. Tell me over again."


Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like