I'm designing a simple covid 19 tracking system. The system creates Visits object that is stored in an ArrayList everytime a Customer(objects in ArrayList) visits a Shop(objects in ArrayList).
The superclass Details.
public class Details {
private String name;
private String phoneNumber;
private Status status;
// Customer
public Details(String name, String phoneNumber, Status status) {
this.name = name;
this.phoneNumber = phoneNumber;
this.status = status;
}
I'm using java.time package to create the datetime along with Visit object like so
public class Visit extends Details {
private String dateTimeFinal;
private String shopName;
public Visit(String name, String phoneNumber,String shopName, Status status) {
super(name, phoneNumber, status);
this.shopName = shopName;
LocalDateTime dateTime = LocalDateTime.now();
DateTimeFormatter dateTimeFormatted = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
dateTimeFinal = dateTime.format(dateTimeFormatted);
}
My customer class constructor looks like this
public class Customer extends Details {
private String password;
public Customer (String name, String phoneNumber, String password, Status status){
super(name, phoneNumber, status);
this.password = password;
}
My shop class constructor looks like this
public class Shop extends Details{
private String managerName;
public Shop(String name, String phoneNumber, Status status, String managerName){
super(name, phoneNumber, status);
this.managerName = managerName;
}
I also have a Status enum in another file that looks like this
public enum Status{
NORMAL,
CASE,
CLOSE
}
What I'm trying to accomplish now is, if a customer that has been flagged as CASE visits a Shop, all customers that also visit the shop within a 1 hour time range before & after automatically gets flagged as a close contact (CLOSE). I also want know how to create time&date that is not localdatetime.now, because I need to generate visits to test if the flagging algorithm works or not.
question from:
https://stackoverflow.com/questions/65650037/how-do-i-auto-flag-related-records-in-an-arraylist-based-on-date-and-time