Homework
Homework this semester will be structured as follows. There are five
tasks listed below. Each is a visitor to be defined on both an
LRStruct or a BRStruct. Each visitor implementation counts as one
assignment, for a total of 10 (5 visitors * 2 structures = 10
assignments).
Task 1
Write a visitor for a structure of Strings (i.e. one for
LRStruct and one for BRStruct) which
returns, as an Integer, the number of elements in the structure which
begin with an upper-case (capital) "A". In the empty case the correct
answer is 0.
You must name your LRStruct visitor Task1LinearVisitor
You must name your BRStruct visitor Task1BinaryVisitor
Task 2
Write a visitor for a structure of Strings (i.e. one for
LRStruct and one for BRStruct) which
returns, as an Integer, the number of elements in the structure which
begin with an upper-case vowel (i.e. "A", "E", "I", "O" or "U"). In
the empty case the correct answer is 0.
You must name your LRStruct visitor Task2LinearVisitor
You must name your BRStruct visitor Task2BinaryVisitor
Task 3
Write a visitor for a structure of any type (i.e. one for
LRStruct and one for BRStruct) which returns
the "last" element contained in the strucuture (the last element of an
LRStruct, and the rightmost elements of a BRStruct). In the empty
case the correct answer is to have the structure throw an exception.
You must name your LRStruct visitor Task3LinearVisitor
You must name your BRStruct visitor Task3BinaryVisitor
Task 4
Write a visitor for a structure of Integers (i.e. one
for LRStruct and one for BRStruct)
which returns, as an Integer, the sum of all the even integers in the
structure. In the empty case the correct answer is to return 0.
You must name your LRStruct visitor Task4LinearVisitor
You must name your BRStruct visitor Task4BinaryVisitor
Task 5
Write a visitor for a structure of Integers (i.e. one for
LRStruct and one for BRStruct)
which returns a copy of the structure: i.e. an LRStruct (or
BRStruct) which has the same overall structure and which
stores the same references. In the empty case the correct answer is
to return a new empty structure (LRStruct or
BRStruct, as appropriate).
You must name your LRStruct visitor Task5LinearVisitor
You must name your BRStruct visitor Task5BinaryVisitor
Submission Submit using Web-CAT, no later than 11:59 PM on
the last day of classes (4/28).
This page written an maintained by Carl Alphonce.
|