Complete Download Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera PDF All Chapters
Complete Download Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera PDF All Chapters
com
https://textbookfull.com/product/polymorphism-in-java-
methods-and-polymorphic-algorithms-applied-to-computer-
games-1st-edition-privitera/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/applied-evolutionary-algorithms-in-
java-ghanea-hercock-robert/
textboxfull.com
https://textbookfull.com/product/research-methods-for-education-
gregory-j-privitera/
textboxfull.com
https://textbookfull.com/product/analysis-for-computer-scientists-
foundations-methods-and-algorithms-michael-oberguggenberger/
textboxfull.com
https://textbookfull.com/product/analysis-for-computer-scientists-
foundations-methods-and-algorithms-second-edition-oberguggenberger/
textboxfull.com
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/
textboxfull.com
https://textbookfull.com/product/learning-java-through-games-1st-
edition-stanchev-lubomir/
textboxfull.com
https://textbookfull.com/product/research-methods-for-the-behavioral-
sciences-2nd-edition-gregory-j-privitera/
textboxfull.com
https://textbookfull.com/product/classic-computer-science-problems-in-
java-1st-edition-david-kopec/
textboxfull.com
https://textbookfull.com/product/genetic-algorithms-in-java-basics-
jacobson-lee-kanber-burak/
textboxfull.com
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
Other documents randomly have
different content
— Vous trouvez que j’ai eu tort ? N’était-ce pas la plus simple
solution ?
— Un peu trop simple. Heureusement Agnès est intelligente…
Elle suivait sur son visage l’impression de chaque parole. Il ne
parut que surpris d’un blâme pourtant discret. Sa mère jugeait son
acte en femme du monde ou en dévote ; lui, il négligeait ces vaines
prudences. De leur entretien elle conclut trop vite que l’amour n’avait
pas inspiré son empressement pour Agnès.
En fait, il était d’abord content de lui : devant une nécessité
subite il avait montré sa décision et sa vigueur. Mais comment
l’étreinte de la belle nymphe flexible qu’il avait pressée contre son
cœur n’aurait-elle pas éveillé dans ses fibres un sourd émoi ? Il ne
se disait pas : J’aime. Était-ce déjà de l’amour ? Son inclination
restait latente. Le bourgeon, à la veille d’éclore, ne sait point qu’il
éclora. Il cédait à la volupté d’un attrait dont il ne voulait pas faire un
lien. Le bonheur initial de celui qui aime, c’est d’aimer.
Cependant, par intervalles, il se demandait :
— Que pense-t-elle de moi ? Me suppose-t-elle amoureux ?…
Elle s’est bien peu défendue. Si elle m’aimait, elle serait plus
coquette. N’importe ! Elle se souviendra toujours que moi, le premier,
je l’aurai portée dans mes bras.
Le premier ? Qui peut savoir ?…
Mais, sur-le-champ, il s’indigna contre un tel doute : Agnès était
pure, la promptitude même de sa confiance tenait à son ingénuité. Il
ne pouvait admettre d’elle une image diminuée ou flétrie ; à l’amie
réelle il substituait une idole ; et un déplaisir lui venait d’être incertain
si l’idole serait insensible ou devinerait son adoration.
Il se voyait fruste, impropre aux gentillesses qui éblouissent les
femmes. Qu’induire des façons d’Agnès avec lui, de clins d’œil, de
silences, de brusques rougeurs ? Chez elle, si nerveuse, les signes
apparents trompaient sur la vérité des impressions. Elle traitait
Jérôme, selon le mot d’Antoinette, « en camarade ». A supposer qu’il
lui parlât d’amour, que répondrait-elle ? Un refus, une attitude
évasive rompraient leur amitié ; elle n’aurait plus qu’à s’en aller, il la
perdrait. Donc, il devait attendre et se taire.
Mais ce mot : attendre fit sonner dans sa mémoire le conseil de
Dom Estienne : « Attendez et priez. » Jérôme priait peu et mal ; il
craignait qu’en se tournant vers Dieu il n’entendît l’injonction claire :
« Quitte tout et suis-moi. » Loyal dans ses rapports avec les
hommes, il rusait avec Celui qu’on n’élude pas.
Dans cet amour naissant il fuyait l’autre Amour.
La guérison d’Agnès fut plus lente qu’elle ne le présumait. Si elle
posait à terre son pied enflé, une vive souffrance la rendait boiteuse.
Pour qu’elle prît l’air dans le jardin et n’eût pas à descendre au
moment des repas, Mme Élise lui donna comme chambre provisoire,
au rez-de-chaussée, le petit salon.
Là, juste en face de son lit, s’offraient à sa méditation deux
cadres :
A gauche, une toile italienne, assez fraîche de tonalité,
représentant Andromède liée contre un roc, au-dessus de la mer. Le
monstre, à ses pieds, hurlait, impatient de la déchirer ; les vagues
écumaient autour d’elle ; le vent agitait sur son corps un lambeau de
voile et ses cheveux blonds. Les yeux de l’infortunée s’élançaient
vers le ciel d’où se penchait un cavalier, glaive en main, que portait
un cheval aile : le sauveur imprévu.
Et, à droite, un portrait de Jérôme adolescent. Comme, depuis la
guerre, il suivait la mode et rasait même sa moustache, elle
retrouvait sur sa figure de seize ans les traits familiers. Son œil
d’émerillon n’avait pas changé, ni son menton bien fendu par une
fossette, ni la jolie gouttière qu’il montrait sous ses narines. Mais les
joues étaient moins rondes, l’ossature des tempes et des pommettes
se dégageait plus virile. Les sourcils remontaient d’un trait un peu
rude. Accent de physionomie par où il rappelait ses ascendants
paternels et l’oncle Gaston.
Le regard d’Agnès, dans une fantaisie contemplative, allait de
Jérôme à Andromède :
— Andromède, c’est moi, qu’attend plus tard la solitude ou un
mariage bête. Toutes les tristesses pour me dévorer. A moins qu’un
libérateur…
Et, revenant à Jérôme :
— Il est à moi plus qu’il ne le sera sans doute jamais. Personne
ne peut savoir…
Personne ? Antoinette ne manqua pas d’observer la présence du
portrait. Une fois, en la quittant, elle lui dit avec un sourire de fine
malice :
— Je ne te laisse pas seule ; Jérôme te tient compagnie…
Pour la démentir, Agnès alla dehors s’étendre sur une chaise-
longue, auprès de deux cèdres qui massaient leurs touffes sombres
à gauche de la maison. De cet endroit la terrasse offrait à ses yeux
une ligne écarlate de géraniums, la file des élégants troënes, à tronc
mince, à tête arrondie, disposés dans des caisses rondes comme
les arbustes d’un décor de songe, et, au bas du double escalier, le
parterre entouré de roses, ouvertes maintenant, telles sur leurs tiges
que des joyaux. Çà et là, dans le jardin et à travers la campagne, les
pommiers fleuris faisaient comme des nuées de papillons éparses
au milieu de l’herbe.
Appuyée contre des coussins, Agnès voyait au-dessus d’elle de
clairs nuages, presque immobiles dans l’azur, semblables à des
arbres blancs. Sur ses mains, sur ses paupières l’air coulait doux
comme une eau tiède. Elle jouissait d’un parfait bien-être, et sa
beauté n’avait pas encore brillé d’une transparence aussi calme.
C’était un dimanche matin. Antoinette, avec Mme Élise, venait de
descendre pour la grand’messe. Les cloches en sonnaient le dernier
coup. Agnès se redressa, prit un paroissien qu’elle avait apporté, et
se mit à lire son office. Elle arrivait au dernier Évangile, quand
Jérôme sortit de la maison, rentra, ressortit et s’approcha d’elle. Il
avait une mine insolite, exaltée et soucieuse. Il prononça d’abord
des phrases dont il paraissait être absent :
— N’avez-vous besoin de rien ? On vous abandonne !
— Comment ! se récria-t-elle. Mais on est trop bon pour moi.
Quelle chose exquise, être malade ! On me fait un devoir de vivre en
enfant gâtée. Je dis à ma sœur : « Toinon, va me chercher du fil.
Toinon, apporte-moi de l’encre et du papier. » Elle quitte tout, elle
vole. Et votre mère, elle me comble, elle ne sait qu’inventer… Tenez,
c’est drôle, d’habitude, quand je vais à l’église, je suis très mal ma
messe ; les plus folles distractions, parce que j’ai le prêtre et l’autel
devant moi, m’emportent ailleurs. Ici, parce que l’église est loin, je
l’ai lue, ma messe, avec une attention dont je ne reviens pas. Je me
sens tellement tiède, évaporée !
— Moi aussi, dit Jérôme, et, ce qui est plus désolant, je veux
l’être. L’amour de Dieu m’épouvante comme une fournaise d’où plus
rien de ce qui est moi ne sortirait vivant.
Sans penser au mouvement qu’elle faisait, Agnès étira sur ses
jambes le bas de sa robe, et, avec une nuance de brusque ironie :
— Vous avez peur du feu ?
— Non, je n’ai peur de rien… sauf de moi-même.
Sa voix s’assombrit, il détourna les yeux ; d’autres aveux, peut-
être, allaient lui échapper. Agnès, au lieu de les solliciter, par un
recul de timide orgueil, brisa le dangereux entretien :
— Vous êtes bien tragique aujourd’hui ; allez faire un tour dans
les bois ; promenez Mob ; cela vous changera les idées.
Il s’éloigna, sans répondre, lentement, et disparut derrière la villa.
Agnès n’avait pas manqué à son rôle de femme : elle s’était mise en
défense, elle avait fait sentir sa supériorité.
Mais elle demeura bouleversée de joie, de compassion et
d’angoisse :
— Antoinette a bien vu ; il m’aime ; si je l’avais tant soit peu
poussé, il parlait… J’aurais dû peut-être. L’instant perdu reviendra-t-il
une autre fois ? Oui, si vraiment il m’aime, c’est une conversation
qu’il reprendra… Il ne m’a rien dit ; mais puis-je m’y tromper ? Cette
agitation, ce désarroi. Lui, d’ordinaire, si ferme… Le pauvre garçon !
Je lui ai fait une grande peine. Mais pourquoi cette peur de lui-
même ? quels scrupules ? quel secret ? Il faut savoir. Mon Dieu !
notre bonheur, vous le tenez dans votre main. Restera-t-elle fermée,
et que faire pour qu’elle s’ouvre ?
V
Ainsi Jérôme avait failli brûler ses vaisseaux. Moins fière, moins
rétractile, moins dénuée d’expérience, Agnès le conduisait à révéler
son tourment :
— Je vous aime ; mais, entre vous et moi, il y a cette chose
lourde, l’inquiétude d’une vocation…
Elle eût, de ses doigts légers, écarté l’invisible obstacle ; il
tombait à ses genoux.
C’est qu’en effet la nécessité d’un choix, jusqu’alors esquivée,
commençait à surgir devant lui, telle qu’au milieu d’une route une
statue dont la présence immobile impose à l’homme qui marche une
décision : passer à droite ou à gauche. Il n’hésitait pas, comme
Hercule, entre la Volupté et la Vertu. Il n’avait à se prononcer
qu’entre une vie plus parfaite et une autre qui l’était moins.
Se marier, s’établir en bon terrien, former une lignée vigoureuse
et nourrie de saintes traditions, était-ce un méprisable avenir ?
L’œuvre des survivants d’après-guerre serait assez belle s’ils
refaisaient la France et la chrétienté.
Mais il fallait aussi des prêtres. « Un pays sans prêtres, disait
Montcalm, ressemble à ces landes maudites où même les ajoncs
épineux ne savent plus pousser. » Parmi les morts de la guerre,
combien de prêtres et de futurs prêtres ? Qui les remplacerait ?
Ce dimanche-là, pendant la messe, Jérôme, cherchant l’évangile
du jour, avait rencontré une parole qui le traversa comme une plainte
exhalée hier : « Messis multa ; operarii pauci. Pour la moisson
immense trop peu d’ouvriers. »
Au moment de la communion, un dégoût de sa tiédeur l’avait
secoué : « Jésus veut la Cène préparée dans une grande salle, avec
des lits de repos. Et je le reçois dans le vestibule, dans le coin d’un
taudis maussade, en l’expédiant ! » Une minute il avait pris son âme
entre ses mains : « Seigneur, que faut-il que je fasse ? »
La réponse n’était pas venue, sans doute parce qu’il désirait
qu’elle ne vînt pas. Il avait quitté l’église plus assailli qu’avant
d’objections contre le séminaire. Elles formaient autour de sa
pensée une chaîne dansante, d’abord subtile, molle, mais qui se
resserrait comme un cercle d’airain.
— Si j’étais prêtre, je voudrais l’être absolument, mourir à moi-
même ; donc il vaut mieux ne pas l’être. A mon âge, quand j’ai, trop
longtemps déjà, vécu sous la férule d’autrui, aller m’asseoir sur les
bancs pour quatre ou cinq années d’études ; moi qui ai en horreur
les abstractions, grabeler des arguments scholastiques, éplucher
des cas de conscience, réfuter de vieilles hérésies, est-ce mon
affaire ? Et une vie étiolée entre quatre murs, celle de fusains pâles
dans une charmille sans soleil… Et le pli à prendre de la soumission
en tout… Non, vraiment, Montcalm s’est trompé. Ces héroïsmes ne
sont pas dans la ligne de mon avenir.
Et, surtout, ma mère a besoin de moi. Il faut que je l’aide à gérer
nos terres. Les métayers, là-bas, les braves gens d’alentour
attendent aussi mon aide. Je me dois à ce morceau du pays que je
puis sauver.
Une raison qu’il n’énonçait pas ajoutait, il le sentait bien, son
poids à toutes les autres : Agnès avait pris son cœur ; à présent elle
l’aurait tenu lié « avec un seul de ses cheveux. »
— Eh bien ! quoi ! je l’aime ! Est-ce que je fais mal ? Seulement,
voudra-t-elle ?…
Comme ce débat fléchissait vers une pauvre anxiété d’amoureux
incertain de la bonne réponse, il avait vu Agnès sortir sur la terrasse,
et, marchant avec précaution pour ne point paraître écloppée, aller
s’étendre à l’ombre bleue des cèdres, fermer voluptueusement les
yeux. Il s’était dit :
— Allons ; c’est l’instant.
Il descendit, l’aperçut qui lisait dans son paroissien ; un retour
d’idées pieuses le troubla ; il résolut de lui déclarer ce qu’il éprouvait,
le scrupule qui le séparait du bonheur. L’attente qui se prolongeait
irrita son angoisse ; il fit quelques pas dehors, mais n’osa
s’approcher. Une timidité imprévue, à la minute de l’aveu,
déconcertait son élan ; il rentra, se fit honte de son indécision, et,
ressortant, aborda la jeune fille avec cette figure étrange dont elle fut
saisie. Le mystère, le décousu des confidences ébauchées la mit en
alerte ; sous l’ironie de la rebuffade il ne discerna point l’émotion
terrible. Quand il avait eu le bras droit cassé par une balle, le choc
l’avait surpris comme un coup de fouet qui l’eût pincé jusqu’à l’os ; la
chiquenaude d’Agnès le blessa d’une douleur autrement cuisante. Il
se retira, comme abasourdi, humilié, certain qu’elle le jugeait
absurde, et consterné de la découvrir cruelle, au moment où il
n’aspirait qu’à fondre son âme en la sienne, dans la plus tendre
confiance.
Jérôme souffrait d’une imagination excessive ; ses désirs
bondissaient plus loin que le réel ; si quelque chose d’imprévu lui
résistait, il désespérait des autres et de lui-même.
Il s’en alla par l’avenue des tilleuls, prit au hasard, voyant à peine
où il marchait, sur la droite, un chemin désert. Il se demandait
pourquoi il existait encore ; sa personne lui semblait un point morne,
inutile dans l’immensité du monde. Son chagrin n’était qu’une folle
impatience de joie ; et il croyait la joie manquée à jamais !
Au bout du chemin, il s’arrêta, étonné d’être là plutôt qu’ailleurs. Il
se retourna, comme voulant renouer le nœud de ses sensations.
Derrière lui, clairsemés parmi des chênes, des genêts roux faisaient
des brasiers de fleurs. Aux Clouzeaux, dans son Bocage, il
connaissait un coin pareil. Cette analogie le dépaysa tout d’un coup ;
il se réveilla de son égarement.
— Agnès s’est moquée de moi. Elle a bien fait. Ma contenance,
le ton de ma voix étaient par trop stupides. Elle a vu, de loin, venir le
mot que je n’aurais peut-être pas dit. Elle a paré l’offensive ; elle a
rompu les chiens. Coquetterie ? Ou plutôt, c’est que je ne lui plais
guère. Tant pis pour elle !
Un sursaut d’amour-propre masculin le redressa ; de son
amertume il tira une reprise d’énergie. Il rentra, décidé à ne rien
laisser paraître. Il monta dans sa chambre où son miroir l’avertit que
sa mine portait les traces d’une commotion. Il se doucha d’eau
froide, peignit avec lenteur ses cheveux châtains dont les boucles
animaient la vigueur sanguine d’une oreille finement ourlée. Ses
joues avaient repris leur vive carnation. Détendu, dispos et beau
comme un astre, il redescendit pour le déjeuner.
Il s’attendait à retrouver Agnès ironique et distante. Elle se
montra simplement gentille. Démêlait-elle qu’il affectait de n’avoir
pas souffert ? Ne doutant point qu’elle l’avait peiné, elle s’appliquait à
dissiper leur malentendu. Elle le regardait manger, revenir à tous les
plats par une ostentation d’appétit où elle devinait une bravade. Elle
sentait chez ce garçon une force indomptée. Aurait-elle désiré la
soumettre ou s’y perdre ? Elle ne savait.
Au sortir de la table, on s’assit dehors, près de la maison. Le
Père lui-même, qui avait passé une excellente nuit, oublia sa sieste,
vint prendre l’air en compagnie des siens.
Mme Élise insista pour qu’Agnès s’étendît sur la chaise-longue.
Elle refusa, prétendant que cette position « de statue funéraire »
l’excédait. En se mettant sur une chaise basse à côté de Jérôme,
elle eut une manière imperceptible de se pencher vers lui et un
sourire qui signifiait : « Sommes-nous amis maintenant » ? Il en
pénétra l’intention et, tout d’un coup, redevint pleinement,
éperdument heureux. Par-dessus la tête d’Agnès il dominait les
rosiers de la pelouse ; un grand arbuste — le bouquet de la mariée,
— toutes ses fleurs blanches ouvertes, ressemblait à un buste de
femme sous de mousseuses dentelles. La conque verte du vallon,
couronnée d’azur, n’était plus pour lui qu’une corbeille nuptiale
offerte à la bien-aimée.
Il avait allumé un de ces petits cigares qu’on appelait, alors des
« diabolos ». Le Père, en veine de plaisanterie, aventura un
alexandrin dont il fit l’honneur à François Coppée :
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