In this mini-project, you will continue our text layout / text block example.
1. Implement Truncated.java
, Centered.java
, and RightJustified.java
,
as described in the subtype polymorphism lab.
Truncated,
Centered, or
RightJustfied` have
a sensible width parameter. If the user provides an inauspicious width
parameter, do whatever you’d like.2. Implement HorizontallyFlipped.java
and VerticallyFlipped.java
, which
do what they say. (That is, rearrange the text blocks horizontally and
vertically.)
"Hello"
would give "olleH"
.3. Design and implement at least one other new kind of text block.
4. There are (at least) three models of equality for TextBlock
objects:
Implement these as TBUtils.equal(TextBlock t1, TextBlock t2)
, TBUtils.eqv(TextBlock t1, TextBlock t2)
, and TBUtils.eq(TextBlock t1, TextBlock t2)
, respectively. If you find it useful to require and implement similar procedures in each of the kinds of TextBlocks
(e.g., every TextBlock
must include equal(TextBlock other)
or eqv(TextBlock other)
), you can add them to the interface.
5. Write appropriate tests for each of your procedures. Make sure to check edge cases.
The rubric may evolve slightly during grading.
Submissions that fail to meet any of these requirements will get an I.
[ ] Includes the specified `.java` files, correctly named.
[ ] Each class has an introductory Javadoc comment that indicates
the author and purpose.
[ ] Includes a `README.md` file that contains the appropriate information
(authors, purpose, acknowledgements if appropriate)
[ ] All files compile correctly.
[ ] Includes one more text block.
[ ] The `README.md` includes a link to the GitHub repo.
[ ] The GitHub repo has at least five commits.
Submissions that fail to meet any of these requirements but meet all previous requirements will receive an R.
[ ] Appears to follow Google Java style guidelines for indentation and such.
[ ] Includes tests for each of the different kinds of textblocks as a
top-level block.
[ ] `Truncated` works for widths at least 1 and less than or equal to
the width of the parameter block.
[ ] `Centered` works for widths greater than or equal to the width of
the parameter block.
[ ] `RightJustified` works for widths greater than or equal to the width
of the parameter block.
[ ] `HorizontallyFlipped` works for nonempty blocks of two or more lines.
[ ] `VerticallyFlipped` works for nonempty blocks of two or more lines.
[ ] The GitHub repo has at least five meaningful commits.
[ ] Each commit has an appropriate commit message.
Submissions that fail to meet any of these requirements but meet all previous requirements will receive an M.
[ ] All (or most) repeated code has been factored out into individual
methods.
[ ] All or most variable names are appropriate.
[ ] Includes tests for each of the different kinds of text blocks as
parameters to other text blocks (or themselves).
[ ] Tests include interesting edge cases, such as empty blocks.
[ ] `Truncated` works with a width of 0.
[ ] `Centered` works with a width greater than the width of the
parameter block.
[ ] `HorizontallyFlipped` works with empty blocks (`new TextLine("")`).
[ ] `VerticallyFlipped` works with empty blocks (`new TextLine("")`).
Truncated
constructor look like?new Truncated(myblock, 5)
truncates the block at 5 characters wide.BoxedBlock
?Truncated
constructor do if the width is greater than the width of the block?eqv
?TextBlock
objects provide
an eqv(TextBlock other)
method that does something similar.eq
?==
.TextBlockTests.java
Centered
and RightJustified
truncate if necessary?new BoxedBlock(new TextLine("Hello"))
, you know that the width should be 7, the height should be 3, lines 0 and 2 should be "+-----+"
and line 1 should be "|Hello|"
.equal
, you can create a variety of equal boxed blocks in different ways. For example, new HorizontallyFlipped(new HorizontallyFlipped(new TextLine("Hello")))
should be equal to new TextLine("Hello")
but not eq
or eqv
.toString(TextBlock block)
method to TBUtils
.