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.
25 lines
924 B
25 lines
924 B
package cmpt213.assignment2.packagedeliveriestracker.model;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
/**
|
|
* It's a subclass of PackageInfo that adds an expiry date
|
|
*/
|
|
public class PerishablePackage extends PackageInfo {
|
|
LocalDateTime expiryDate;
|
|
|
|
// It's a constructor that initializes the object with the given parameters.
|
|
public PerishablePackage(String name, String note, double price, double weight, boolean delivered, LocalDateTime expectedDate, LocalDateTime expiryDate) {
|
|
super(name, note, price, weight, delivered, expectedDate);
|
|
this.expiryDate = expiryDate;
|
|
this.setType("perishable");
|
|
}
|
|
|
|
// It's a method that returns a string representation of the object.
|
|
@Override
|
|
public String toString() {
|
|
return super.toString() + "\nExpiry date: " + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format(expiryDate);
|
|
}
|
|
}
|