Skip to content

Commit 3872301

Browse files
Commit ithsjava25#3 - Add perishable and Shippable interfaces
1 parent 08e7533 commit 3872301

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.example;
2+
3+
import java.time.LocalDate;
4+
5+
/*
6+
* Interface för produkter som kan förvaras
7+
*/
8+
public interface Perishable {
9+
10+
LocalDate expirationDate();
11+
12+
//Check för utgången produkt
13+
default boolean isExpired() {
14+
return expirationDate().isBefore(LocalDate.now());
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example;
2+
3+
import java.math.BigDecimal;
4+
5+
/*
6+
* Interface för produkter som kan skickas
7+
*/
8+
public interface Shippable {
9+
10+
double weight(); //Vikt i kg
11+
12+
BigDecimal calculateShippingCost(); // fraktkostnad
13+
}

0 commit comments

Comments
 (0)