Class FunIT
- java.lang.Object
-
- FunIT
-
public class FunIT extends java.lang.ObjectName: Tan Kok Kiang Joel
Admin No.: 174866J
Course Name: DPST
Class: BI1701
Start Date: 12 June 2017
Completed Date: 28 July 2017- Since:
- 1.0
- Version:
- 7.5
- Author:
- Joel
- See Also:
scInt(),scBigDecimal(),quitProcess(Object),namePrompt(),printTransactions(String[][], String[], int[]),updateTransPlayerCount(String[][], int, int),addTransactions(String[][], String[], int[], int, int, String...),removeTransOldestEntry(String[][]),printBox(String, int, String, int, char...)
-
-
Constructor Summary
Constructors Constructor Description FunIT()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String[][]addTransactions(java.lang.String[][] transactions, java.lang.String[] name, int[] age, int rideGrp, int playerCount, java.lang.String... strs)For adding values to transactions & helps to ensure that key or important values are placed in the right index.static voidmain(java.lang.String[] args)NOTE:
Some clarification,static java.lang.StringnamePrompt()For prompting player name and display appropriate message after input.static voidprintBox(java.lang.String display, int width, java.lang.String align, int opt, char... border)This method is being use to print a table or box with or without message in it with ease,
without having to manually count the number of characters to ensure equal length for a table / box.static voidprintTransactions(java.lang.String[][] transactions, java.lang.String[] name, int[] age)For printing or displaying entire day transactionsstatic booleanquitProcess(java.lang.Object input)Checks if input is -99, display appropriate message and return value to boolean quitProcess.static java.lang.String[][]removeTransOldestEntry(java.lang.String[][] transactions)For removing oldest rideGrp entries in transactions when transaction is cap.static voidrtnToMenuPrompt()For prompting user to press enter to return to the main menu.static java.math.BigDecimalscBigDecimal()Try & Catch BigDecimal input with own error message.static intscInt()Fixes Java nextInt() / nextLine() issues.
Documentation on Oracle.static java.lang.String[][]updateTransPlayerCount(java.lang.String[][] transactions, int rideGrp, int playerCount)For updating transactions player count for the current ride group.
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
NOTE:
Some clarification,
currentPlayers[5][]
Is for storing current ride players, 1 adult & one child is consider 2 players, and 1 adult is considered as 1 player.transactions[1000][]
Is for storing transactions. 1 adult or 1 adult & 1 child is considered one transaction.BigDecimal
The reason for using BigDecimal instead of double or float is because double/float can inexact as
you performed multiple calculation (addition, subtraction, multiplication, division),
which makes floats and doubles inadequate for dealing with money.
-
scInt
public static int scInt()
Fixes Java nextInt() / nextLine() issues.
Documentation on Oracle.- Returns:
- User input value [ int ]
-
scBigDecimal
public static java.math.BigDecimal scBigDecimal()
Try & Catch BigDecimal input with own error message.- Returns:
- User input value [ BigDecimal ]
-
quitProcess
public static boolean quitProcess(java.lang.Object input)
Checks if input is -99, display appropriate message and return value to boolean quitProcess.- Parameters:
input- Input value to check with [ String / double / int ]- Returns:
- boolean false / boolean true
-
namePrompt
public static java.lang.String namePrompt()
For prompting player name and display appropriate message after input.- Returns:
- User input value. [ String ]
-
rtnToMenuPrompt
public static void rtnToMenuPrompt()
For prompting user to press enter to return to the main menu.
-
updateTransPlayerCount
public static java.lang.String[][] updateTransPlayerCount(java.lang.String[][] transactions, int rideGrp, int playerCount)For updating transactions player count for the current ride group.- Parameters:
transactions- 2 Dimensional transactions array to be updated. [ String[][] transactions ]rideGrp- Current ride group number. [ int rideGrp ]playerCount- Current number of players. [ int playerCount ]- Returns:
- Updated 2 Dimensional transactions array [ String[][] transactions ]
-
addTransactions
public static java.lang.String[][] addTransactions(java.lang.String[][] transactions, java.lang.String[] name, int[] age, int rideGrp, int playerCount, java.lang.String... strs)For adding values to transactions & helps to ensure that key or important values are placed in the right index.- Parameters:
transactions- 2 Dimensional transactions array to be updated. [ String[][] transactions ]name- Name to be added. [ String[] name ]age- Age to be added. [ int[] age ]rideGrp- Current ride group number to be added. [ int rideGrp ]playerCount- Player count to be added. [ int currentPlayerList.size() ]strs- Various values that needs to be added. [ String variables ]- Returns:
- Updated 2 Dimensional transactions array [ String[][] transactions ]
-
removeTransOldestEntry
public static java.lang.String[][] removeTransOldestEntry(java.lang.String[][] transactions)
For removing oldest rideGrp entries in transactions when transaction is cap.- Parameters:
transactions- 2 Dimensional transactions array to be updated. [ String[][] transactions ]- Returns:
- Updated 2 Dimensional transactions array [ String[][] transactions ]
-
printTransactions
public static void printTransactions(java.lang.String[][] transactions, java.lang.String[] name, int[] age)For printing or displaying entire day transactions- Parameters:
transactions- 2 Dimensional transactions array to be updated. [ String[][] transactions ]name- For counting name[] length [ String[] age ]age- For counting age[] length [ int[] age ]
-
printBox
public static void printBox(java.lang.String display, int width, java.lang.String align, int opt, char... border)This method is being use to print a table or box with or without message in it with ease,
OPTION:
without having to manually count the number of characters to ensure equal length for a table / box.- Message Only with side border.
- Top border & Message.
- Top & bottom border with Message.
- Bottom border with Message.
- Border Only. (Default)
- Parameters:
display- Message to be display. [ String ]width- Width of border / table. [ int ]align- Alignment of the text in the table. (Defaults to left) [ String left / center / right ]opt- See OPTION for style explanation. [ int 1 / 2 / 3 / 4 ]border- Style of the top & bottom border. (e.g. '-', '=' & e.t.c) [ char '-' / '=' / '_' ]
-
-