mirror of
https://github.com/smyalygames/kahoot-challenge-2025.git
synced 2025-05-18 16:54:15 +02:00
refactor: make functions static
This commit is contained in:
parent
0dbd6eb471
commit
74d4189808
@ -6,7 +6,7 @@ public class EMail {
|
|||||||
* @param email The email address being checked
|
* @param email The email address being checked
|
||||||
* @return <code>true</code> if the email is correctly formatted, otherwise <code>false</code>
|
* @return <code>true</code> if the email is correctly formatted, otherwise <code>false</code>
|
||||||
*/
|
*/
|
||||||
public boolean validate(String email) {
|
public static boolean validate(String email) {
|
||||||
// Set up regex for email format
|
// Set up regex for email format
|
||||||
String emailRegex = "[^@ \\t\\r\\n]+@[^@ \\t\\r\\n]+\\.[^@ \\t\\r\\n]+";
|
String emailRegex = "[^@ \\t\\r\\n]+@[^@ \\t\\r\\n]+\\.[^@ \\t\\r\\n]+";
|
||||||
Pattern pattern = Pattern.compile(emailRegex);
|
Pattern pattern = Pattern.compile(emailRegex);
|
||||||
@ -20,7 +20,7 @@ public class EMail {
|
|||||||
* @param email A valid email address
|
* @param email A valid email address
|
||||||
* @return The domain of the email address from the parameter
|
* @return The domain of the email address from the parameter
|
||||||
*/
|
*/
|
||||||
public String getDomain(String email) {
|
public static String getDomain(String email) {
|
||||||
// Checks that the email address is valid, otherwise throw exception
|
// Checks that the email address is valid, otherwise throw exception
|
||||||
if (!validate(email)) {
|
if (!validate(email)) {
|
||||||
throw new IllegalArgumentException("The email address provided is not valid");
|
throw new IllegalArgumentException("The email address provided is not valid");
|
||||||
|
@ -10,7 +10,7 @@ public class ReadFile {
|
|||||||
* @param filename the name of the file with, only allowing a .txt extension
|
* @param filename the name of the file with, only allowing a .txt extension
|
||||||
* @return The contents of the file
|
* @return The contents of the file
|
||||||
*/
|
*/
|
||||||
public List<String> open(String filename) {
|
public static List<String> open(String filename) {
|
||||||
// Check that the filetype is correct, otherwise, throw IllegalArgumentException
|
// Check that the filetype is correct, otherwise, throw IllegalArgumentException
|
||||||
if (!filename.endsWith(".txt")) {
|
if (!filename.endsWith(".txt")) {
|
||||||
throw new IllegalArgumentException("The filename is not a .txt format");
|
throw new IllegalArgumentException("The filename is not a .txt format");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user