Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
3.6 kB
2
Indexable
Never
import java.time.LocalDate;

public class MyDate {
    private int day;
    private int month;
    private int year;
    private static LocalDate borrowDate;

    public MyDate(int day, int month, int year) {
        this.day = day;
        this.month = month;
        this.year = year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public static LocalDate returnDate(int borrowerID, int resourceID) {
        borrowDate = new LocalDate.now();
        switch (borrowerID) {
            case 1:
                switch (resourceID) {
                    case 1:{
                        LocalDate returnDateStudents = borrowDate.plusDays(30); //book
                        return returnDateStudents;
                        break;}
                    case 2:{
                        LocalDate returnDateStudents = borrowDate.plusDays(60); //ebook
                        return returnDateStudents;
                        break;}
                    case 3:{
                        LocalDate returnDateStudents = borrowDate.plusDays(14); //journal
                        return returnDateStudents;
                        break;}
                    case 4:
                        LocalDate returnDateStudents = borrowDate.plusDays(10); //dissertation
                        return returnDateStudents;
                        break;
                    default:
                        return returnDateStudents;
                        break;
                }

            case 2:{
                LocalDate returnDateStaffAndFaculty = borrowDate.plusDays(60);
                return returnDateStaffAndFaculty;
                break;}

            case 3:
                LocalDate returnDateStaffAndFaculty = borrowDate.plusDays(60);
                return returnDateStaffAndFaculty;
                break;
            default:
                return returnDateStaffAndFaculty;
                break;
        }
    }

    public static LocalDate extendReturnDate(int borrowerID, int resourceID) {
        LocalDate currentDate = new LocalDate.now();
        switch (borrowerID) {
            case 1:
                switch (resourceID) {
                    case 1: {
                        LocalDate borrowDate = currentDate.plusDays(30); // book
                        return borrowDate;
                        break;
                    }
                    case 2: {
                        LocalDate borrowDate = currentDate.plusDays(60); // ebook
                        return borrowDate;
                        break;
                    }
                    case 3: {
                        LocalDate borrowDate = currentDate.plusDays(14); // journal
                        return borrowDate;
                        break;
                    }
                    case 4:
                        LocalDate borrowDate = currentDate.plusDays(10); // dissertation
                        return borrowDate;
                        break;
                    default:
                        return borrowDate;
                        break;
                }

            case 2: {
                LocalDate borrowDate = currentDate.plusDays(60);
                return borrowDate;
                break;
            }

            case 3:
                LocalDate borrowDate = currentDate.plusDays(60);
                return borrowDate;
                break;
            default:
                return borrowDate;
                break;
        }

    }

    public String toString() {
        return String.format("%d/%d/%d", day, month, year);
    }

}