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.Scanner
sc
A 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.DateTime
formatTime(DayOfWeek day, int hour_24, int minute)
A date formatter that takes in the current day and time and returns aDateTime
object.static java.lang.String
getPasswordInput()
A method to read passwords from Console without displaying the characters on the screen.static void
load()
A load function that prints progress bars across the screen at 500ms intervals.static void
pause()
A pause function that waits for the user to press the Enter key to proceed on with the next task.static void
printLargeSpace()
Prints 7 lines of spacestatic void
printLine(int size)
Method that prints a horizontal line across the screen.static void
printMediumSpace()
Prints 5 lines of spacestatic void
printSmallSpace()
Prints 3 lines of spacestatic java.lang.String
readLine()
Reads standard input using the Scanner.static java.lang.String
readTime()
Reads time input using Scanner.static void
sendMailNotification(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 aDateTime
object.- Parameters:
day
- ADayOfWeek
Enum 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
-