Class BalanceChecker
java.lang.Object
BalanceChecker
- All Implemented Interfaces:
BalanceChecker_Interface
Checks for balanced symbols. HW 09.
- Author:
- Dr. Lillis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a pair of open/close characters.booleanisBalanced(String s) Checks the given parameter and returns true if it contains balanced symbols and returns false if the symbols are not balanced.booleanChecks to see if the given character has already been added as a closing symbol.booleanChecks to see if the given character has already been added as an opening symbol.booleanCheck of the two given characters are a match.
-
Constructor Details
-
BalanceChecker
public BalanceChecker()Default constructor for the BalancedChecker.
-
-
Method Details
-
addPair
Adds a pair of open/close characters.- Specified by:
addPairin interfaceBalanceChecker_Interface- Parameters:
open- The opening character to add.close- The closing character to add.- Throws:
DuplicateCharacterException- if either character has already been added.
-
isBalanced
Checks the given parameter and returns true if it contains balanced symbols and returns false if the symbols are not balanced.- Specified by:
isBalancedin interfaceBalanceChecker_Interface- Parameters:
s- The string to check.- Returns:
- true of the given string contains balanced symbols, returns false otherwise.
-
isOpening
Checks to see if the given character has already been added as an opening symbol.- Specified by:
isOpeningin interfaceBalanceChecker_Interface- Parameters:
c- The character to look for.- Returns:
- true if the given character has already been added as an opening symbol.
-
isClosing
Checks to see if the given character has already been added as a closing symbol.- Specified by:
isClosingin interfaceBalanceChecker_Interface- Parameters:
c- The character to look for.- Returns:
- true if the given character has already been added as a closing symbol.
-
match
Check of the two given characters are a match.- Specified by:
matchin interfaceBalanceChecker_Interface- Parameters:
c1- The first character to check.c2- The second character to check.- Returns:
- true of the two symbols match, false otherwise.
-