100% found this document useful (7 votes)
24 views

Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera - Download the full ebook now to never miss any detail

The document promotes a collection of eBooks available for download at textbookfull.com, including titles focused on Java programming, algorithms, and research methods. It highlights the book 'Polymorphism in Java' by Carlos Alberto Privitera, which aims to teach advanced Java concepts through polymorphic algorithms and design patterns. The book is designed for readers with a foundational knowledge of Java and provides practical skills for programming and problem-solving in computer systems.

Uploaded by

peitlpeader39
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (7 votes)
24 views

Polymorphism in Java: Methods and polymorphic algorithms applied to computer games 1st Edition Privitera - Download the full ebook now to never miss any detail

The document promotes a collection of eBooks available for download at textbookfull.com, including titles focused on Java programming, algorithms, and research methods. It highlights the book 'Polymorphism in Java' by Carlos Alberto Privitera, which aims to teach advanced Java concepts through polymorphic algorithms and design patterns. The book is designed for readers with a foundational knowledge of Java and provides practical skills for programming and problem-solving in computer systems.

Uploaded by

peitlpeader39
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Explore the full ebook collection and download it now at textbookfull.

com

Polymorphism in Java: Methods and polymorphic


algorithms applied to computer games 1st Edition
Privitera

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

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Applied Evolutionary Algorithms in Java Ghanea Hercock


Robert

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

textbookfull.com

Research Methods for Education Gregory J Privitera

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

textbookfull.com

Analysis for Computer Scientists Foundations Methods and


Algorithms Michael Oberguggenberger

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

textbookfull.com

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/

textbookfull.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/
textbookfull.com

Learning Java Through Games 1st Edition Stanchev Lubomir

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

textbookfull.com

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/

textbookfull.com

Classic Computer Science Problems in Java 1st Edition


David Kopec

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

textbookfull.com

Genetic Algorithms in Java Basics Jacobson Lee Kanber


Burak

https://textbookfull.com/product/genetic-algorithms-in-java-basics-
jacobson-lee-kanber-burak/

textbookfull.com
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:


[email protected]
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:
*Big Shot. 1929.
*Big Show. © 1923.
*Big Tent. © 1927.
*Big Time Charlie. 1929.
*Big-Top Champions. 1930.
*Big Town. © 1924.
*Bigger and Better Blondes. © 1927.
*Bigger and Better Jails. © 1925.
*Bike Bug. © 1921.
*Billy Blazes, Esq. © 1919.
*Birds of Passage. © 1924.
*Bit of Life in Java. 1928.
*Biting the Dust. © 1924.
*Black Ace. 1928.
*Black Book. (Serial)
*Black Cyclone. © 1925.
*Black Duck. 1929.
*Black Hand Blues. © 1925.
*Black Magic. © 1924.
*Black Narcissus. 1929.
*Black Oxfords. © 1924.
*Black Secret. (Serial)
*Black Shadows. © 1923.
*Black Sheep. © 1924.
*Blaze Away. © 1922.
*Blaze of Glory. 1928.
*Blind Man's Luck. © 1917.
*Bliss. © 1917.
*Blonde for a Night. 1928.
*Blonde's Revenge. © 1926.
*Blood Barrier. © 1920.
*Blood Will Tell. © 1926.
*Blow 'Em Up. © 1922.
*Blue Danube. 1928.
*Boats and Fishermen of the Arctic and the Tropics. 1928.
*Body Building. 1929.
*Body in the Bag. © 1924.
*Bone Dry. © 1922.
*Bonehead Age. © 1925.
*Boobs in the Wood. © 1924.
*Border Blackbirds. © 1927.
*Border Law. © 1922.
*Border Patrol. 1928.
*Border Raiders. © 1918.
*Born to Battle. © 1927.
*Boss of Rustler's Roost. 1928.
*Boss's Orders. 1930.
*Bottle Babies. © 1924. LU20185, LU20460.
*Bouncer. © 1925.
*Bound and Gagged. (Serial)
*Bow Wows. © 1922.
*Bowled Over. © 1923.
*Bows and Arrows. 1930.
*Boy and the Dog. © 1922.
*Boy Friend. 1927.
*Boyhood Memories. 1929.
*Boys To Board. © 1923.
*Boys Will Be Joys. © 1925.
*Brain and Brawn. © 1924.
*Brave Heart. © 1927.
*Break of Day. 1929.
*Breakfast in Bed. 1930.
*Breaking the Ice. © 1925.
*Bride and Gloom. © 1918.
*Bride-To-Be. © 1922.
*Bridle Byways. 1929.
*Bring Home the Turkey. © 1927.
*Broadcasting. © 1922.
*Broadway Cowboy. © 1920.
*Broke in China. © 1927.
*Bromo and Juliet. © 1926.
*Bronc Stomper. 1928.
*Bronco Buster. 1927.
*Brother of the Bear. © 1921.
*Brothers Divided. © 1919.
*Brothers Under the Chin. © 1924.
*Bubbles. © 1925.
*Bubbling Over. © 1921, © 1927.
*Buccaneers. © 1924.
*Buck Fever. © 1926.
*Bucking the Bucket Shop. © 1924.
*Bucking the Handicap. 1927.
*Buggy Ride. © 1926.
*Bughouse College Days. 1929.
*Bugville Field Day. © 1925.
*Bugville Romance. 1930.
*Building Winners. © 1924.
*Bull and Sand. © 1924.
*Bull Fighter. © 1927.
*Bullet Mark. 1928.
*Bull's-Eyes. © 1926.
*Bully. © 1927.
*Bumper Crop. © 1926.
*Bumping into Broadway. © 1920.
*Bungalow Boobs. © 1924.
*Bunker Battlers. 1928.
*Burglar. 1928.
*Burglar Alarm. © 1923.
*Burglars Bold. © 1921.
*Buried Treasure. © 1926.
*Burning Bridges. 1928.
*Burnt Fingers. © 1927.
*Busy Bees. © 1922.
*Busy Bodies. 1927.
*Butter Fingers. © 1925.
*Button My Back. 1929.
*By Hook or Crook. © 1924.
*By Land and Air. 1929.
*By the Sad Sea Waves. © 1917.
*By the Wholesale. © 1926.
*Cabaret. 1929.
*Cake Eater. © 1924.
*Calcutta. 1927.
*Caleb Piper's Girl. © 1919.
*California or Bust. © 1923.
*Call a Taxi. © 1920.
*Call for Mr. Caveman. © 1919.
*Call of the Game. © 1924.
*Call of the Wild. © 1923.
*Call the Witness. © 1921.
*Calling Hubby's Bluff. 1929.
*Camille of the Barbary Coast. © 1925.
*Camping Out. 1928.
*Campus Carmen. 1928.
*Campus Champs. 1931.
*Campus Favorites. 1930.
*Campus Vamp. 1928.
*Canadian Lynx. © 1922.
*Canned Thrills. 1928.
*Cannon-Ball Express. © 1924.
*Captain Kidder. © 1924.
*Captain Kidd's Kids. © 1920.
*Captain Swagger. 1928.
*Capturing a Great Anteater. © 1926.
*Capturing Lions by Aeroplane. © 1921.
*Caretaker's Daughter. © 1925.
*Carnival Revue. 1930.
*Carnival Week. 1927.
*Carolina Capers. 1929.
*Carolyn of the Corners. © 1919.
*Casey of the Coast Guard. (Serial)
*Cash Customers. © 1921.
*Cat and the Canary. © 1921.
*Cat and the Magnet. © 1924.
*Cat and the Mice. © 1921.
*Cat and the Monkey. © 1921.
*Cat and the Pig. © 1922.
*Cat and the Swordfish. © 1922.
*Cat Came Back. © 1923.
*Cat That Failed. © 1923.
*Catalina, Here I Come. © 1927.
*Catching a Coon. © 1921.
*Cats and Law. © 1921.
*Cat's Meow. © 1924.
*Cat's Revenge. © 1923.
*Cat's Whiskers. © 1923.
*Caught in a Taxi. 1929.
*Caught in the Draft. 1928.
*Caught in the Kitchen. 1928.
*Caught in the Rapids. © 1921.
*Celebrity. 1928.
*Challenge. © 1916.
*Champeen. © 1922.
*Champion. © 1924.
*Champion Makers. 1930.
*Champions. © 1924.
*Change the Needle. © 1925.
*Charleston Queen. © 1926.
*Charley My Boy. © 1926.
*Charming Mrs. Chase. © 1920.
*Chasing Rainbows. © 1927.
*Chasing the Chaser. © 1925.
*Check Your Baggage. © 1918.
*Chicago. 1928.
*Chicken. 1928.
*Chicken Feed. © 1927.
*Chills and Fever. © 1927, 1930.
*Chink. © 1921.
*Chop Suey & Co. © 1919.
*Chop Suey and Noodles. © 1926.
*Christmas Cheer. 1927.
*Cigarette Girl. © 1917.
*Circus. © 1923.
*Circus Capers. 1930.
*Circus Fever. © 1925.
*Circus Time. 1929.
*Circus Today. © 1926
*City Slicker. © 1918.
*City Slickers. 1928.
*Civet Cat. © 1921.
*Clean Up Week. © 1925.
*Cleopatsy. © 1918.
*Clever Feet. © 1925.
*Close Call. 1929.
*Close Figuring. 1929.
*Close Shave. 1929.
*Closer Than a Brother. © 1925.
*Clothes and the Game. 1928.
*Cloven Tongue. © 1918.
*Clowning the Game. 1929.
*Clunked on the Corner. 1928.
*Coast to Coast. 1928.
*Cobb Goes Fishing. 1930.
*Cobbler. © 1923.
*Code of the Cow Country. © 1927.
*Cold Steel. 1929.
*Cold Turkey. © 1925.
*Collars and Cuffs. © 1923.
*College Kiddo. © 1927.
*Combat. © 1927.
*Come and Get Me! © 1922.
*Commencement Day. © 1924.
*Common Clay. © 1919.
*Conceited Donkey. © 1921.
*Concentrate. 1929.
*Conditioning. 1929.
*Convict 993. © 1918.
*Cop. 1928.
*Cop's Bride. 1929.
*Corinne, Come Here. © 1919.
*Corner Pocket. © 1921.
*Cougar. © 1921.
*Count the Votes. © 1919.
*Count Your Change. © 1919.
*Country Doctor. 1927.
*Country Mouse. © 1921.
*Country Mouse and the City Cat. © 1922.
*County Fair. 1928.
*Courtship of Miles Sandwich. © 1923.
*Cover Charge. 1930.
*Covered Pushcart. © 1923.
*Covering Ground. 1928.
*Cowboy Blues. 1931.
*Cowboy Cavalier. 1928.
*Cowboy Sheik. © 1924.
*Cow's Kimono. © 1926.
*Crack Your Heels. © 1919.
*Cracked Ice. © 1927.
*Cracked Wedding Bells. © 1920.
*Cradle Robbers. © 1924.
*Craig's Wife. 1928.
*Crashing Through. 1928.
*Crawl Stroke Kid. © 1927.
*Crazy Like a Fox. © 1926.
*Crazy to Act. © 1927.
*Crime in a Big City. © 1922.
*Crimson Flash. (Serial)
*Crooked Romance. © 1917.
*Crosby's Corners. 1930.
*Cross-Country Run. 1928.
*Crowd Bait. © 1927.
*Crowned Heads. 1928.
*Cry of the Weak. © 1919.
*Crystal Ascension. © 1923.
*Crystal Champions. 1929.
*Cuckoo Love. © 1925.
*Cupid by Proxy. © 1918.
*Cupid, Registered Guide. © 1921.
*Cupid's Boots. © 1925.
*Cups and Contenders. © 1927.
*Cure or Kill. 1928.
*Cured in the Excitement. © 1927.
*Custard Nine. © 1921.
*Custard Pies. 1929.
*Cut the Cards. © 1920.
*Cutting a Melon. © 1927.
*Cyclone Cowboy. © 1926.
*Daddy Boy. © 1927.
*Daddy Goes a Grunting. © 1925.
*Daddy's Girl. © 1918.
*Damsel in Distress. © 1920.
*Dance with Me. 1930.
*Dancing Around. 1929.
*Danger Lure. © 1924.
*Dangerous Curves Behind. © 1925.
*Dangerous Dollars. © 1921.
*Dangerous Trails. © 1922.
*Dangerous Youth. 1930.
*Daredevil. © 1923.
*Daredevil Jack. (Serial)
*Dark Horse. © 1923.
*Darkest Africa. © 1925.
*Darkest Hour. © 1923.
*Darktown Follies. 1930.
*Daughter of the West. © 1918.
*Dawn. © 1919.
*Day in the Wilds. © 1921.
*Days Off. 1928.
*Days of Old. © 1922.
*Day's Outing. © 1925.
*Deadlier Sex. © 1920.
*Deaf, Dumb, and Daffy. © 1924.
*Dear Departed. © 1920.
*Dear Ol' Pal. © 1923.
*Death Ray. © 1924.
*Death Trap. © 1921.
*Deep South. 1930.
*Deep Stuff. © 1925.
*Deputized. © 1922.
*Derby Day. © 1923. LU19594, MU2318.
*Desert of the Lost. 1927.
*Desert Sheiks. © 1924.
*Desert Wolf. © 1921.
*Desha's Tryst with the Moon. © 1927.
*Desperate Courage. 1928.
*Despoilers of Jungle Gardens. © 1926.
*Devil Horse. © 1926.
*Devil To Pay. © 1920.
*Devil's Twin. © 1927.
*Dice of Destiny. © 1920.
*Died in the Wool. © 1927.
*Dig Up. © 1922.
*Digging for Gold. © 1927.
*Dinner Hour. © 1920.
*Dinner Jest. © 1926.
*Dinner Time. 1928.
*Dippy Dentist. © 1920.
*Dirty Little Half Breed. © 1924.
*Discord. © 1927.
*Dissatisfied Cobbler. © 1922.
*Diving. 1928.
*Divorce Dodger. © 1926.
*Dixie Chase. 1930.
*Dixie Days. 1930.
*Dixie Doodle. © 1926.
*Dizzy Daddies. © 1926.
*Do Detectives Think? © 1927.
*Do Husbands Deceive. © 1918.
*Do Me a Favor. © 1922.
*Do Women Pay? © 1923.
*Do You Love Your Wife? © 1918.
*Do Your Duty. © 1926.
*Do Your Stuff. © 1923.
*Doctor Jack. © 1922.
*Dodge Your Debts. © 1921.
*Dog and the Bone. © 1921.
*Dog and the Flea. © 1921.
*Dog and the Mosquito. © 1922.
*Dog and the Thief. © 1922.
*Dog and the Wolves. © 1922.
*Dog Days. © 1925.
*Dog Shy. © 1926.
*Dogging It. 1929, 1930.
*Dog's Day. © 1927.
*Dogs of Solitude. 1931.
*Dogs of War. © 1923.
*Doing Phil a Favor. 1930.
*Doing Time. © 1920.
*Dollar for Dollar. © 1920.
*Dolly Does Her Bit. © 1918.
*Dolly's Vacation. © 1918.
*Don Desperado. © 1927.
*Don Key, Son of Burro. © 1926.
*Donkey in Lion's Skin. © 1921.
*Don't Flirt. © 1923.
*Don't Forget. © 1924.
*Don't Park There! © 1924.
*Don't Rock the Boat. © 1920.
*Don't Say Die. © 1923.
*Don't Shove. © 1919.
*Don't Tell Dad. © 1925.
*Don't Tell Everything. © 1927.
*Don't Weaken. © 1920.
*Double Adventure. (Serial)
*Double Cinched. © 1923.
*Dough Boys. © 1926.
*Down and Out. © 1922.
*Down on the Farm. © 1924.
*Down to the Sea. © 1927.
*Down to the Sea in Shoes. © 1923.
*Dozen Socks. © 1927.
*Dress Parade. 1927.
*Drifter. © 1922.
*Driftin' Thru. © 1926.
*Drink Hearty. © 1920.
*Dross and Diamonds. © 1916.
*Drums of Fear. 1930.
*Duck Soup. © 1927.
*Dude Ranch Days. © 1925.
*Dude Ranching. 1930.
*Duffer Swings. 1931.
*Duffers and Champs. 1929.
*Dumb-Bell. © 1922.
*Dumb Waiter. 1928.
*Durable Souls. © 1926.
*Dutiful Dub. © 1919.
*Eagle of the Night. (Serial)
*Early Bird. 1928.
*Earthquakes. 1928.
*East of the Water Plug. © 1924.
*Eastern Westerner. © 1920.
*Ebony Shrine. 1930.
*Echoes from the Alps. © 1925.
*Emotional Miss Vaughn. © 1920.
*Empire of Diamonds. © 1920.
*Empress. © 1917.
*Enchanted Flute. 1929.
*End of the World. © 1925, 1929.
*Enemy of Soap. © 1918.
*English Channel Swim. © 1925.
*Eternal Triangle. © 1922.
*Every Man for Himself. © 1924.
*Everybody's Flying. 1928.
*Eve's Fall. 1930.
*Eve's Love Letters. © 1927.
*Excuse My Glove. © 1925.
*Exploring England with Will Rogers. 1927.
*Extra Girl. © 1923.
*Extra Seven. © 1923.
*Eyes and Angles. © 1927.
*Eyes of the Totem. © 1927.
*Fable of a Fish Story. © 1923.
*Fable of a Fisherman's Jinx. © 1923.
*Fable of a Raisin and a Cake of Yeast. © 1923.
*Fable of a Stone Age Romeo. 1922.
*Fable of Brewing Trouble. © 1922.
*Fable of Cheating the Cheater. © 1922.
*Fable of Day by Day in Every Way. © 1923.
*Fable of Farmer Al Falfa's Bride. © 1923.
*Fable of Fearless Fido. © 1922.
*Fable of Friday the 13th. © 1922.
*Fable of Henpecked Harry. © 1922.
*Fable of Henry's Busted Romance. © 1922.
*Fable of One Hard Pull. © 1923.
*Fable of Pharoah's Tomb. © 1923.
*Fable of Spooks. © 1923.
*Fable of the Alley Cat. © 1923.
*Fable of the Big Flood. © 1922.
*Fable of the Boastful Cat. © 1922.
*Fable of the Boy and the Bear. © 1922.
*Fable of the Dog and the Fish. © 1922.
*Fable of the Dog's Paradise. © 1922.
*Fable of the Elephant's Trunk. © 1922.
*Fable of the Enchanted Fiddle. © 1922.
*Fable of the Farmer and the mice. © 1922.
*Fable of the Fortune Hunters. © 1922.
*Fable of the Frog and the Catfish. © 1922.
*Fable of the Gamblers. © 1923.
*Fable of the Gliders. © 1923.
*Fable of the Hated Rivals. © 1922.
*Fable of the Jolly Rounders. © 1923.
*Fable of the Man Who Laughed. © 1922.
*Fable of the Mechanical Horse. © 1922.
*Fable of the Mischievous Cat. © 1922.
*Fable of the Mouse Catcher. © 1923.
*Fable of the Mysterious Hat. © 1923.
*Fable of the Rolling Stone. © 1922.
*Fable of the Romantic Mouse. © 1922.
*Fable of the Sheik. © 1923.
*Fable of the Spider and the Fly. © 1923.
*Fable of the Traveling Salesman. © 1923.
*Fable of the Two Explorers. © 1922.
*Fable of the Worm That Turned. © 1922.
*Fable of Troubles on the Ark. © 1923.
*Fable of Two of a Trade. © 1922.
*Face the Camera. © 1922.
*Fair Affair. 1928.
*Fair Exchange. © 1927.
*Fair Week. © 1922.
*Fairway Favorites. 1930.
*Fairways and Foul. 1929.
*Faithful Pup. 1929.
*False Code. © 1920.
*Family Album. © 1926.
*Family Entrance. © 1924.
*Family Frolics. 1927.
*Famous Playgrounds. 1928.
*Fancy That. 1929.
*Fangs of Fate. 1928.
*Farm Foolery. 1930.
*Farm Hands. © 1926.
*Farmer Al Falfa's Pet Cat. © 1923.
*Farmer and His Cat. © 1922.
*Farmer and the Ostrich. © 1922.
*Farmer's Goat. 1929.
*Fashionable Fox. © 1921.
*Fast Black. © 1924.
*Fast Company. © 1924.
*Fast Worker. © 1925.
*Fatal Ring. (Serial)
*Father's Close Shave. © 1920.
*Feet of Mud. © 1924.
*Feline Fighter. 1930.
*Felix O'Day. © 1920.
*Fellow Citizens. © 1920.
*Fellow Romans. © 1921.
*Feminine Fitness. 1929.
*Festive Haul. © 1924.
*Fiddlesticks. © 1926.
*Fields of Glory. © 1924.
*Fifteen Minutes. © 1921.
*Fifty Miles from Broadway. 1930.
*Fight Game. 1929.
*Fight Night. © 1926.
*Fightin' Comeback. © 1927.
*Fighting Cressy. © 1920.
*Fighting Eagle. 1927.
*Fighting Fluid. © 1924.
*Fighting Marine. © 1926.
*Fighting Marine. (Serial)
*Fighting Relatives. 1928.
*Find the Girl. © 1920.
*Finding His Job. © 1927.
*Finer Points. © 1924.
*Finger Prints. © 1923.
*Fins and Feathers. © 1925.
*Fire Detective. (Serial)
*Fire Fighters. © 1922, © 1926.
*Fire the Fireman. © 1922.
*Fireman Save My Child. © 1918.
*First Law. © 1918.
*First 100 Years. © 1924.
*Fish and Feathers. 1929.
*Fish Day. 1929.
*Fish, Fowl, and Fun. 1931.
*Fisherman's Luck. © 1925.
*Fishin' Fever. © 1924.
*Fishing Fool. 1928.
*Five Fifteen. © 1923.
*Five Orphans of the Storm. © 1924.
*Flaming Fathers. © 1927.
*Flaming Flappers. © 1925.
*Flaming Trail. © 1921.
*Flat Broke. © 1920.
*Fleeced for Gold. © 1922.
*Flickering Youth. © 1924.
*Flight That Failed. 1928.
*Flip Flops. © 1923.
*Flirt. © 1917.
*Flirty Four Flushers. © 1926.
*Flivver. © 1922.
*Floor Below. © 1920.
*Fluttering Hearts. © 1927.
*Fly and the Ant. © 1921.
*Fly Time. © 1926.
*Flyin' Buckaroo. 1928.
*Flying Age. 1928.
*Flying Carpet. © 1924.
*Flying Elephants. © 1927.
*Flying Feet. © 1927, 1930.
*Flying Fever. © 1924.
*Flying Fishers. © 1927.
*Flying Fool. 1929.
*Flying Hoofs. 1928.
*Flying Luck. 1927.
*Fly's Bride. 1929.
*Follow the Crowd. © 1918.
*Follow the Leader. 1929.
*Foolish Follies. 1930.
*Foolish Husbands. 1929.
*Football Sense. (Serial)
*Footwork. 1929.
*For Art's Sake. © 1923.
*For Guests Only. © 1923.
*For Rent, Haunted. © 1922.
*For Safe Keeping. © 1923.
*For Sale. © 1918.
*For Sale, a Bungalow. © 1927.
*For the Love of a Gal. © 1925.
*Forbidden Love. 1928.
*Forbidden Valley. © 1920.
*Forbidden Woman. 1927.
*Fore. 1931.
*Forest Samson. © 1921.
*Forgotten Sweeties. © 1927.
*Fortieth Door. (Serial)
*Fortunes of Corinne. © 1918.
*45-Calibre War. 1929.
*45 Minutes from Hollywood. © 1926.
*Fourth Alarm. © 1926.
*Foul Play. 1929.
*Fox. © 1921.
*Fox and Crow. © 1921.
*Fox and Goat. © 1921.
*Fox and the Grapes. © 1922.
*Fox Hunt. © 1925, © 1927.
*Fraidy Cat. © 1924.
*Fresh Eggs. © 1923.
*Fresh Paint. © 1920.
*Freshman. 1925.
*Friday, the 13th. © 1922.
*Friend Husband. © 1924.
*Frog and the Ox. © 1921.
*Frolics in Frost. 1927.
*From Caves to Skyscrapers. © 1927.
*From Hand to Mouth. © 1920.
*From Rags to Britches. © 1925.
*From Rags to Riches and Back Again. © 1924.
*From Soup to Nuts. © 1927.
*Frontier Trail. © 1926.
*Frost Line. © 1927.
*Frozen Frolics. 1930.
*Frozen Hearts. © 1923.
*Fruitful Farm. 1929.
*Fruits of Faith. © 1922.
*Full o' Pep. © 1922.
*Fully Insured. © 1923.
*Fun Afoot. 1928.
*Fundamental Football. © 1927.
*Funnymooners. © 1926.
*Furniture Movers. © 1918.
*Future Greats. © 1927.
*Galloping Bungalows. © 1924.
*Galloping Ghosts. © 1927.
*Galloping Gobs. © 1927.
*Galloping Hoofs. (Serial)
*Garden of Eatin'. 1929.
*Garden of Gethsemane. © 1926.
*Gas and Air. © 1923.
*Gates of Brass. © 1919.
*Gay Old Dog. © 1919.
*Gee Whiz Genevieve! © 1924.
*Gem of Agra. 1930.
*Gentlemen of the Evening. 1929.
*Geraldine. 1929.
*Get Busy. © 1924.
*Get 'Em Young. © 1926.
*Get Out and Get under. © 1920.
*Get Your Man. © 1923.
*Getaway Kate. © 1918.
*Getting His Goat. © 1920.
*Getting on the Green. 1931.
*Getting Together. 1928.
*Ghost of Folly. © 1926.
*Ghost of the Rancho. © 1918.
*Giants Vs. Yanks. © 1923.
*Giddap. © 1924.
*Ginger and Genius. © 1927.
*Girl and the Gangster. © 1924.
*Girl from Bohemia. © 1918.
*Girl from Everywhere. 1927.
*Girl from Nowhere. 1928.
*Girl in the Pullman. 1927.
*Girl in the Web. © 1920.
*Girl Shy. © 1924.
*Girl That Didn't Matter. © 1916.
*Girl Who Won. © 1916.
*Girls and Records. © 1923.
*Girls Will Be Boys. 1929.
*Give Me Action. 1930.
*Giving the Bride Away. © 1919.
*Glaciers. 1929.
*Glacier's Secret. 1930.
*Gliding. 1930.
*Glorious Fourth. © 1927.
*Glory of Spain. 1930.
*Glory or Dollars. © 1926.
*Go As You Please. © 1920.
*Go Easy, Doctor. 1929.
*Go Get 'Em Garringer. © 1919.
*Go Get 'Em Hutch. (Serial)
*Go West. © 1923.
*Godless Girl. 1928.
*Going! Going! Gone! © 1918.
*Going to Congress. © 1924.
*Gold Digger of Weepah. © 1927.
*Gold from Weepah. 1927.
*Gold Push. © 1926.
*Golden Clown. 1927.
*Golden Pagoda. 1930.
*Golf Bug. © 1922.
*Golf in Slow Motion. © 1926.
*Golf Nut. © 1927.
*Golfing with Bobby Jones. © 1926.
*Golfing with Jess Sweetser. © 1927.
*Gone to the Country. © 1921.
*Good Cheer. © 1926.
*Good Morning, Judge. © 1922.
*Good Morning, Madam! © 1925.
*Good Morning, Nurse. © 1925.
*Good Old Circus Days. © 1924.
*Good Old College Days. © 1924.
*Good Old Days. © 1923.
*Good Old School Days. 1930.
*Good Riddance. © 1923.
*Good Samaritan. © 1927.
*Good Ship Nellie. 1928.
*Goofy Age. © 1924.
*Goose Land. © 1926.
*Goose That Laid the Golden Egg. © 1921.
*Gosh-Darn Mortgage. © 1925.
*Grab the Ghost. © 1920.
*Grace in Slow Motion. © 1926.
*Grand Parade. 1930.
*Grandma's House. 1929.
*Great Adventure. © 1918.
*Great Arena. © 1926.
*Great Explorers. © 1923.
*Great Gamble. (Serial)
*Great International Race, Papyrus Vs. Zev. © 1923.
*Great Open Spaces. © 1925.
*Great Outdoors. © 1923.
*Great Water Peril. © 1918.
*Greek Meets Greek. © 1921.
*Green Archer. (Serial)
*Green Cat. © 1922.
*Gridiron Cocktail. 1928.
*Gridiron Demons. 1928.
*Gridiron Glory. © 1924, 1929.
*Grief in Bagdad. © 1925.
*Grip of Evil. (Serial)
*Guest. © 1924.
*Guild Cities of Belgium. 1928.
*Gun Shy. © 1926.
*Gyped in Egypt. 1930.
*Hale and Hearty. © 1922.
*Half a Chance. © 1920.
*Halfback of Notre Dame. © 1924.
*Hands Up. (Serial)
*Hansom Cabman. © 1924.
*Happy Days. 1928.
*Happy Go Luckies. © 1923.
*Happy Golf. 1930.
*Happy Hunting Grounds. © 1926.
*Happy Years. © 1924.
*Hard Boiled. © 1925.
*Hardboiled Hampton. 1929.
*Hard-Boiled Tenderfoot. © 1924.
*Hard Cider. © 1927.
*Hard Knocks. © 1924.
*Hare and Frogs. © 1921.
*Hare and Tortoise. © 1921.
*Harem Knight. © 1926.
*Harp in Hock. 1927.
*Harvest Hands. © 1923.
*Haunted. 1929.
*Haunted Honeymoon. © 1925.
*Haunted House. © 1925.
*Haunted Ship. 1930.
*Haunted Spooks. © 1920.
*Haunted Valley. (Serial)
*Have a Drink. 1927.
*Hawaii the Beautiful. 1928.
*Hawk of the Hills. (Serial)
*Hawks of the Sea. © 1924.
*Hayfoot, Strawfoot. © 1926.
*He Forgot To Remember. © 1926.
*He Leads, Others Follow. © 1919.
*He Who Gets Smacked. © 1925.
*Heap Big Chief. © 1919.
*Hear 'Em Rave. © 1918.
*Heart Line. © 1921.
*Heart of Doreon. © 1921.
*Heart of Lincoln. © 1927.
*Heart of the Yukon. © 1927.
*Hearts and Hoofs. 1930.
*Hearts and Showers. © 1926.
*Heavy Seas. © 1923.
*Hello Baby. © 1924.
*Hello Teacher. © 1918.
*Hello Uncle. © 1920.
*Help One Another. © 1924.
*Help Wanted, Female. 1931.
*Help Wanted—Male. © 1920.
*Her Actor Friend. © 1926.
*Her Ben. © 1926.
*Her Dangerous Path. (Serial)
*Her Hired Husband. 1930.
*Her Man. © 1918, 1930.
*Her Memory. © 1924.
*Her New Chauffeur. 1929.
*Her Private Affair. 1929.
*Her Sister's Rival. © 1917.
*Her Unwilling Husband. © 1920.
*Here Comes the Girls. © 1918.
*Here's Your Men. © 1922.
*Herman, the Great Mouse. © 1924.
*Hermit and Bear. © 1921.
*Hero Wins. © 1925.
*Hesitating Horses. © 1926.
*Hey There. © 1918.
*Hidden Aces. © 1927.
*Hidden Ball. 1930.
*Hidden Hand. (Serial)
*High and Dizzy. © 1920.
*High Brow Stuff. © 1924.
*High Flyers. © 1923.
*High Hand. © 1926.
*High Rollers. © 1921.
*High Seas. 1928.
*High Society. © 1924.
*High Stakes. 1927.
*High Steppers. 1930.
*High Tide. © 1922.
*High Toned. 1930.
*High Voltage. 1929.
*Hiking Through Holland with Will Rogers. © 1927.
*Hillcrest Mystery. © 1918.
*Hired and Fired. © 1922, © 1926.
*His Best Girl. © 1921.
*His Birthday Suit. 1930.
*His Busy Day. © 1918.
*His Dog. 1927.
*His Enemy's Friend. © 1922.
*His First Command. 1930.
*His First Flame. © 1926.
*His Foreign Wife. © 1927.
*His Marriage Wow. © 1924.
*His New Mamma. © 1924.
*His New Stenographer. 1928.
*His Only Father. © 1919.
*His Operation. 1929.
*His Own Law. © 1922.
*His Pal's Gal. © 1920.
*His Royal Slyness. © 1919.
*His Unlucky Night. 1928.
*His Vampy Ways. © 1919.
*His Wooden Wedding. © 1925.
*Hit the High Spots. © 1924.
*Hitting the Rails. © 1926.
*Hobbies. © 1924.
*Hobgoblins. © 1921.
*Hobo of Pizen City. © 1920.
*Hoboken to Hollywood. © 1926.
*Hocus-Pocus. © 1921.
*Hold 'Em Yale. 1928.
*Hold Everything. © 1926.
*Hold My Baby. © 1925.
*Hold That Thought. © 1925.
*Hold the Baby. 1930.
*Hold-up Man. © 1920.
*Hole in One. © 1927.
*Holiday. 1930.
*Hollywood Kid. © 1924.
*Home Stretch. © 1920.
*Home Sweet Home. © 1926, 1930.
*Home Talent. © 1924.
*Homeless Cats. 1929.
*Homeless Pups. © 1924.
*Honest Crooks. 1930.
*Honest Thief. © 1918.
*Honeymoon Hardships. © 1924.
*Honeymoon Hints. 1927.
*Honor Man. © 1927.
*Honor of Rameriz. © 1921.
*Honor System. © 1925.
*Hon. Mr. Buggs. © 1927.
*Hoof Beats. © 1924.
*Hoof Marks. © 1927.
*Hook, Line, and Melody. 1929.
*Hook, Line, and Sinker. © 1922, © 1927.
*Hooked. 1930.
*Hooked at the Altar. © 1926.
*Hooks and Holidays. © 1926.
*Hoot Mon. © 1919.
*Horace Greely, Jr. © 1925.
*Horse Shoes. © 1927.
*Horses! Horses! © 1927.
*Horses, Horses, Horses. © 1927.
*Hot Cakes for Two. © 1925.
*Hot Heels. © 1924.
*Hot Off the Press. © 1922
*Hot Stuff. © 1924.
*Hot Tamale. 1930.
*Hot Times in Iceland. © 1925.
*Hot Water. 1924.
*Hot Wires. 1931.
*Hotsy Totsy. © 1925.
*House Cleaning. © 1924.
*House Cleaning Time. 1929.
*House of Hats. (Serial)
*House of the Tolling Bell. © 1920.
*House Without a Key. (Serial)
*Housing Shortage. © 1925.
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