Package MySTARS
Class Helper
java.lang.Object
MySTARS.Helper
public final class Helper
extends java.lang.Object
A Helper Class with all properties and methods that are generally needed across the application.
- Since:
- 2020-11-1
- Version:
- 1.0
- Author:
- Bhargav, Jia Hui, Timothy, Kah Ee
-
Field Summary
Fields Modifier and Type Field Description static java.util.ScannerscA single Scanner object that reads input from console so that memory resources are efficiently used. -
Constructor Summary
Constructors Constructor Description Helper() -
Method Summary
Modifier and Type Method Description static org.joda.time.DateTimeformatTime(DayOfWeek day, int hour_24, int minute)A date formatter that takes in the current day and time and returns aDateTimeobject.static java.lang.StringgetPasswordInput()A method to read passwords from Console without displaying the characters on the screen.static voidload()A load function that prints progress bars across the screen at 500ms intervals.static voidpause()A pause function that waits for the user to press the Enter key to proceed on with the next task.static voidprintLargeSpace()Prints 7 lines of spacestatic voidprintLine(int size)Method that prints a horizontal line across the screen.static voidprintMediumSpace()Prints 5 lines of spacestatic voidprintSmallSpace()Prints 3 lines of spacestatic java.lang.StringreadLine()Reads standard input using the Scanner.static java.lang.StringreadTime()Reads time input using Scanner.static voidsendMailNotification(Student receipient, java.lang.String course)A method that sends an email from the Administrative Gmail Account to the user if their course has been registered.
-
Field Details
-
sc
public static java.util.Scanner scA single Scanner object that reads input from console so that memory resources are efficiently used.
-
-
Constructor Details
-
Helper
public Helper()
-
-
Method Details
-
load
public static void load()A load function that prints progress bars across the screen at 500ms intervals. -
pause
public static void pause()A pause function that waits for the user to press the Enter key to proceed on with the next task. -
formatTime
A date formatter that takes in the current day and time and returns aDateTimeobject.- Parameters:
day- ADayOfWeekEnum corresponding to the day of the week.hour_24- The hour in 24 hour format.minute- The minutes of the hour.- Returns:
- A DateTime Object.
-
sendMailNotification
public static void sendMailNotification(Student receipient, java.lang.String course) throws java.lang.ExceptionA method that sends an email from the Administrative Gmail Account to the user if their course has been registered.- Parameters:
receipient- The network username of the student.course- The String value of the course that they have been successfully registered for.- Throws:
java.lang.Exception- Throws Exception when unable to send mail successfully.
-
getPasswordInput
public static java.lang.String getPasswordInput()A method to read passwords from Console without displaying the characters on the screen.- Returns:
- A String representing the password that was keyed in.
-
readLine
public static java.lang.String readLine()Reads standard input using the Scanner.- Returns:
- The read input in capitalised form.
-
readTime
public static java.lang.String readTime() throws java.lang.ExceptionReads time input using Scanner. Prints error message if invalid format.- Returns:
- 24 hour time.
- Throws:
java.lang.Exception- if the time does not meet the specified format.
-
printSmallSpace
public static void printSmallSpace()Prints 3 lines of space -
printMediumSpace
public static void printMediumSpace()Prints 5 lines of space -
printLargeSpace
public static void printLargeSpace()Prints 7 lines of space -
printLine
public static void printLine(int size)Method that prints a horizontal line across the screen.- Parameters:
size- The length of the line to print
-