Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Class to implement lease inputs, ouput and logic
- //
- // Author: <Please insert your name here>
- //
- import java.util.Calendar; // Required for getting today's date
- import java.text.SimpleDateFormat; // Required for formatting the date
- import java.util.*;
- import javax.swing.*; // Required for GUI
- class LeaseContents
- {
- // Method returns todays date formated as dd MMM yyyy (eg: 25 Nov 2011)
- public static String getTodaysDate()
- {
- Calendar cal = Calendar.getInstance();
- SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");
- return sdf.format(cal.getTime());
- }
- LeaseContents() // Constructor
- {
- boolean emailConfirm = false; // Defines a "confirmation flag."
- String email;
- do
- {
- email = JOptionPane.showInputDialog(null, "Please enter your educational email!", "Your Email Address", JOptionPane.OK_CANCEL_OPTION);
- email.checkEmail();
- }
- while (emailConfirm = false);
- }
- public boolean checkEmail(String email, boolean emailConfirm) // Method to check the emails length and whether it ends with .ac.uk or .gov.uk
- {
- if(email.endsWith(".ac.uk") || email.endsWith(".gov.uk")) return true;
- if(email.length() < 3) return true;
- if(email.length() > 30) return true;
- return false;
- }
- }
Add Comment
Please, Sign In to add comment