You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.5 KiB
74 lines
2.5 KiB
package model;
|
|
|
|
import javafx.scene.image.Image;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
import java.time.LocalDate;
|
|
|
|
/**
|
|
* Created by Gondr on 1/06/2017.
|
|
*/
|
|
public class Driver extends User{
|
|
|
|
protected LicenseType licenseType;
|
|
protected String licenseNumber;
|
|
protected LocalDate licenseDateIssued;
|
|
protected LocalDate licenseDateExpire;
|
|
private LocalDate lastNotified;
|
|
|
|
public enum LicenseType{
|
|
RESTRICTED("Restricted"), FULL("Full"), FULL2YEARS("Full for 2 Years");
|
|
public String name;
|
|
|
|
LicenseType(String name){
|
|
this.name = name;
|
|
}
|
|
public static LicenseType getValueOf(String s){
|
|
switch (s){
|
|
case "Restricted":
|
|
return RESTRICTED;
|
|
case "Full":
|
|
return FULL;
|
|
case "Full for 2 Years":
|
|
return FULL2YEARS;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Driver(int studentNumber, String email, String password, String address, String homephone, String mobilephone,
|
|
Image photo, LicenseType licenseType, String licenseNumber, LocalDate licenseDateIssued, LocalDate licenseDateExpire){
|
|
super(studentNumber, email, password, address, homephone, mobilephone, photo);
|
|
this.accountType = AccountType.DRIVER;
|
|
this.licenseType = licenseType;
|
|
this.licenseNumber = licenseNumber;
|
|
this.licenseDateIssued = licenseDateIssued;
|
|
this.licenseDateExpire = licenseDateExpire;
|
|
lastNotified = LocalDate.MIN;
|
|
}
|
|
|
|
public String getLicenseNotification(){
|
|
if (licenseDateExpire.minusWeeks(4).isBefore(LocalDate.now())){
|
|
if (licenseDateExpire.minusWeeks(2).isBefore(LocalDate.now())){
|
|
if (licenseDateExpire.minusWeeks(1).isBefore(LocalDate.now())){
|
|
if (licenseDateExpire.minusWeeks(1).isAfter(lastNotified)){
|
|
lastNotified = LocalDate.now();
|
|
return "Your License is expiring in 1 weeks.";
|
|
}
|
|
}
|
|
if (licenseDateExpire.minusWeeks(2).isAfter(lastNotified)){
|
|
lastNotified = LocalDate.now();
|
|
return "Your License is expiring in 2 weeks.";
|
|
}
|
|
}
|
|
if (licenseDateExpire.minusWeeks(4).isAfter(lastNotified)){
|
|
lastNotified = LocalDate.now();
|
|
return "Your License is expiring in 4 weeks.";
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|