Guest User

Untitled

a guest
May 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. //
  2. //  Class to implement lease inputs, ouput and logic
  3. //
  4. //  Author: <Please insert your name here>
  5. //
  6.  
  7. import java.util.Calendar; // Required for getting today's date
  8. import java.text.SimpleDateFormat; // Required for formatting the date
  9. import java.util.*;
  10. import javax.swing.*; // Required for GUI
  11.  
  12. class LeaseContents
  13. {
  14.    
  15.     // Method returns todays date formated as dd MMM yyyy (eg: 25 Nov 2011)
  16.    
  17.     public static String getTodaysDate()
  18.     {
  19.         Calendar cal = Calendar.getInstance();
  20.         SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");
  21.         return sdf.format(cal.getTime());
  22.     }  
  23.    
  24.    
  25.    
  26.  
  27.     LeaseContents() // Constructor
  28.     {
  29.        
  30.        
  31.        
  32.  
  33.         boolean emailConfirm = false; // Defines a "confirmation flag."
  34.         String email;
  35.         do
  36.         {
  37.             email = JOptionPane.showInputDialog(null, "Please enter your educational email!", "Your Email Address", JOptionPane.OK_CANCEL_OPTION);
  38.  
  39.             email.checkEmail();
  40.         }
  41.         while (emailConfirm = false);
  42.  
  43.        
  44.        
  45.        
  46.     }
  47.  
  48.  
  49.  
  50.     public boolean checkEmail(String email, boolean emailConfirm) // Method to check the emails length and whether it ends with .ac.uk or .gov.uk
  51.     {
  52.  
  53.         if(email.endsWith(".ac.uk") || email.endsWith(".gov.uk")) return true;
  54.         if(email.length() < 3) return true;
  55.         if(email.length() > 30) return true;
  56.         return false;
  57.  
  58.     }
  59.  
  60.  
  61. }
Add Comment
Please, Sign In to add comment