Class StringManipulationService
java.lang.Object
com.iu.javadatastructureslab.services.StringManipulationService
Utility service showcasing Java string manipulation techniques.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyTemplate(String name, String tableNumber, String date, String time) Applies the message template with placeholders.buildReservationMessage(Booking booking) Builds a reservation confirmation message from a booking object.buildReservationMessage(String name, String date, String time, int tableNumber) Builds a reservation confirmation message from raw input values.capitalizeFirstLetter(String input) Capitalizes the first letter of the provided string.formatCustomerName(String name) Formats a customer name to title case.formatDate(String date) Formats the date string for display.formatTableNumber(int tableNumber) Formats a table number for display.formatTime(String time) Formats the time string into HH:mm format when possible.Returns the list of string methods highlighted in the demo.normalizeWhitespace(String input) Normalizes repeated whitespace to single spaces.reverseString(String input) Reverses the provided string.sanitizeInput(String input) Strips unwanted characters from input values.toLowerCase(String input) Lowercases the input string.toUpperCase(String input) Uppercases the input string.
-
Constructor Details
-
StringManipulationService
public StringManipulationService()
-
-
Method Details
-
buildReservationMessage
Builds a reservation confirmation message from raw input values.- Parameters:
name- customer namedate- reservation datetime- reservation timetableNumber- table number- Returns:
- formatted confirmation message
-
buildReservationMessage
Builds a reservation confirmation message from a booking object.- Parameters:
booking- booking details- Returns:
- formatted confirmation message
-
formatCustomerName
Formats a customer name to title case.- Parameters:
name- raw name input- Returns:
- formatted name
-
sanitizeInput
Strips unwanted characters from input values.- Parameters:
input- raw input- Returns:
- sanitized input
-
normalizeWhitespace
Normalizes repeated whitespace to single spaces.- Parameters:
input- raw input- Returns:
- normalized string
-
formatTableNumber
Formats a table number for display.- Parameters:
tableNumber- table number- Returns:
- formatted table label
-
formatDate
Formats the date string for display.- Parameters:
date- raw date input- Returns:
- formatted date
-
formatTime
Formats the time string into HH:mm format when possible.- Parameters:
time- raw time input- Returns:
- formatted time
-
applyTemplate
Applies the message template with placeholders.- Parameters:
name- formatted customer nametableNumber- formatted table labeldate- formatted datetime- formatted time- Returns:
- populated message
-
reverseString
Reverses the provided string.- Parameters:
input- input text- Returns:
- reversed string
-
toUpperCase
Uppercases the input string.- Parameters:
input- input text- Returns:
- uppercased string
-
toLowerCase
Lowercases the input string.- Parameters:
input- input text- Returns:
- lowercased string
-
capitalizeFirstLetter
Capitalizes the first letter of the provided string.- Parameters:
input- input text- Returns:
- string with a capitalized first letter
-
getUsedMethods
Returns the list of string methods highlighted in the demo.- Returns:
- list of method names
-