So for a program im currently writing, there are different membership levels in the form of cards for customers and a coupon for each level depending on how long they've held the card for and how much they've spent in a year
Ive done the total spent portion but im having a big of trouble with the date difference.
Below are the two related classes.
import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.util.*;
class Date {
    LocalDate createdDate = LocalDate.of(2000, Month.MAY, 19);
    LocalDate today = LocalDate.now();
    public void Date() {
        Period difference = Period.between(createdDate, today);
        int years = difference.getYears();
        System.out.println("The created date is: " + createdDate);
        System.out.println("Difference between created date and current date is: " + difference.getYears() + " years");
    } 
    }
import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.util.*;
class silverCard {
    double coupon = 0;
    public void calCoup() {
        Date date = new Date();
        cardDetails card = new cardDetails(0001, "Adam Gong", 7000);
        if (card.getBalance() < 3500) {
            coupon = 0.04;
        } else if (card.getBalance() > 3500 && date.getYears() < 3){
            coupon = 0.05;
        }
        double totalCoupon = card.getBalance() - (card.getBalance() * coupon);
        System.out.println("Your coupon for silver card is: " + totalCoupon);
    }
}
The error comes from the line
} else if (card.getBalance() > 3500 && date.getYears() < 3){
in which the complier doesnt see the method getYears. Im aware that getYears in the date class isnt a method but im unsure of how i would call it from the silverCard class. Ive created a Date object and used it to call getYears. Ive also tried calling period.between and period difference to no luck
Thankyou :)
 
     
    