Package sc2002.FCS1.grp2.builders
Class DisplayMenu.Builder
Object
Builder
- Enclosing class:
DisplayMenu
Use this class to build a menu.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCenteredContent(String content, int width) Add a row where contents in this row is centered, as long as width provided fits the menu/table well.addContent(String content) Add a row in the current section of this menu or table.addContents(List<String> contents) Add an entire section of this menu or table.Finalise the current section by adding the divider.build()Finalise and build menu or table.Set the title of this menu.
-
Field Details
-
title
Title of the rectangle box, centered on top. Optional. -
contents
Sections of rows of content -
current
Incomplete section of content of currrent.
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setTitle
Set the title of this menu.- Parameters:
title- The title to be shown in menu.- Returns:
- this builder object.
-
addContents
Add an entire section of this menu or table. If there exists an incomplete section, calling this will finalise that section.- Parameters:
contents- Row of contents.- Returns:
- this builder object.
-
addContent
Add a row in the current section of this menu or table.- Parameters:
content- A new row of content.- Returns:
- this builder object.
-
addCenteredContent
Add a row where contents in this row is centered, as long as width provided fits the menu/table well.- Parameters:
content- A new row of content.width- width of this row, unit: characters.- Returns:
- this builder object.
-
addDivider
Finalise the current section by adding the divider.- Returns:
- this builder object.
-
build
Finalise and build menu or table.- Returns:
- display menu object, which can export to
Stringor display menu or table in console.
-