Algorithms and Data Structures in an Object-Oriented Framework (“ADSOOF”)
Code for “Interface Types and Generics” section
PricedObject
by an interface.
PricedObject
.
PricedObject
objects as arguments.
PricedObject
objects as arguments, and also arrayLists of PricedObjects
objects (showing a bounded type variable).
ScrabbleWord1
objects being compared using
methods which have PricedObject
arguments.
ScrabbleWord1
objects
passed as an argument a generic method taking an arrayList of objects
which extend PricedObject
as its argument.
DrinksMachine
object, and how the methods that may be called on it work.
The file is annotated so that DrinksMachine
objects
also have type PricedObject
.
Can
object, and how the methods that may be called on it work.
Can.java
as code in
this class uses it, but no direct reference is made to it in this module.
DrinksMachine
objects being compared using
methods which have PricedObject
arguments.
DrinksMachine
objects
passed as an argument a generic method taking an arrayList of objects
which extend PricedObject
as its argument.
Comparable
Comparable
interface.
Comparable
interface.
Comparable
interface.
Comparable
interface so that objects of this class
have a natural ordering given by the Scrabble scores of the words they
represent.
ScrabbleWord
.
QuickSort.java
applied to an arrayList of objects of the type
defined in ScrabbleWord
.
ScrabbleWord
.
QuickSortLispLists.java
applied to a Lisp list of objects of the type
defined in ScrabbleWord
.
Comparable
interface.
QuickSort
applied to an arrayList of integers.
QuickSortLispLists
applied to a LispList
of integers.
QuickSortLispLists
applied to a LispList
of strings.
.class
file enabling you to create and use objects of type
LispList<E>
for any value of E
.
LispList.class
, as code in that class uses it.
transform
which takes an object of the interface's type argument and returns
an object of the same type.
applyConst
,
which takes an arrayList and an object of type Transformer
and applies the transform
method from the object
to every element in the arrayList to create a new arrayList.
Integer
and the transform
method giving the multiply by 10 operation.
String
and the transform
method giving the append
"Hello"
at the front operation.
TenTimes
, but instead of multiplying by 10, the
transform
method mutiplies by a value given when the
Multiplier
object is created.
String
and the transform
method giving an operation which
appends the string representation of a number (increased by one each time
it is called) to the string.
join
which takes two objects of the interface's type argument and returns
an object of the same type.
zipLists
,
which takes two objects of type LispList
and an
object of type Joiner
and returns a LispList
object given by joining the corresponding items from the argument Lisp lists
using the Joiner
argument's join
method.
Integer
and the join
method giving the addition operation.
TenTimes
being used with the applyConst
method from Transformers.java.
HelloAdder
being used with the applyConst
method from Transformers.java.
Multiplier
being used with the applyConst
method from Transformers.java.
NumberAdder
being used with the applyConst
method from Transformers.java.
JoinByAdding
being used with the zipLists
method from Joiners.java.
Last modified: 16 July 2019