diff --git a/list.json b/list.json deleted file mode 100644 index 18167f8..0000000 --- a/list.json +++ /dev/null @@ -1 +0,0 @@ -[{"name":"name","note":"notes","price":15.0,"weight":5.0,"delivered":true,"expectedDate":"2022-07-20T12:12"},{"name":"n2","note":"n2","price":15.0,"weight":16.0,"delivered":false,"expectedDate":"2023-05-20T15:20"},{"name":"n3","note":"n3","price":5.0,"weight":10.0,"delivered":false,"expectedDate":"2020-05-05T12:15"}] \ No newline at end of file diff --git a/out/production/cmpt213.assignment1.packagedeliveriestracker/TextMenu.class b/out/production/cmpt213.assignment1.packagedeliveriestracker/TextMenu.class index 54c609b..ca05863 100644 Binary files a/out/production/cmpt213.assignment1.packagedeliveriestracker/TextMenu.class and b/out/production/cmpt213.assignment1.packagedeliveriestracker/TextMenu.class differ diff --git a/src/BookPackage.java b/src/BookPackage.java new file mode 100644 index 0000000..16abec8 --- /dev/null +++ b/src/BookPackage.java @@ -0,0 +1,17 @@ +import java.time.LocalDateTime; + +public class BookPackage extends PackageInfo{ + String author; + + public BookPackage(String name, String note, double price, double weight, boolean delivered, LocalDateTime expectedDate, String author) { + + super(name, note, price, weight, delivered, expectedDate); + this.author = author; + } + + @Override + public String toString() { + return super.toString()+"author='" + author + '\''; + } +} + diff --git a/src/ElectronicPackage.java b/src/ElectronicPackage.java new file mode 100644 index 0000000..13847b2 --- /dev/null +++ b/src/ElectronicPackage.java @@ -0,0 +1,15 @@ +import java.time.LocalDateTime; + +public class ElectronicPackage extends PackageInfo{ + double handlingFee; + + public ElectronicPackage(String name, String note, double price, double weight, boolean delivered, LocalDateTime expectedDate, double handlingFee) { + super(name, note, price, weight, delivered, expectedDate); + this.handlingFee = handlingFee; + } + + @Override + public String toString() { + return super.toString()+"handlingFee=" + handlingFee; + } +} diff --git a/src/PackageFactory.java b/src/PackageFactory.java new file mode 100644 index 0000000..595bcb5 --- /dev/null +++ b/src/PackageFactory.java @@ -0,0 +1,24 @@ +import java.time.LocalDateTime; + +public enum PackageFactory { + Book { + public PackageInfo getInstance(String name, String notes, double price, double weight, boolean delivered, LocalDateTime expectedDate, String author) { + return new BookPackage(name, notes, price, weight, delivered, expectedDate, author); + } + } + + Perishable { + public PackageInfo getInstance (String name, String notes,double price, double weight, + boolean delivered, LocalDateTime expectedDate, LocalDateTime expiryDate){ + return new PerishablePackage(name, notes, price, weight, delivered, expectedDate, expiryDate); + } + } + + Electronic{ + public PackageInfo getInstance(String name, String notes, double price, double weight, boolean delivered, LocalDateTime expectedDate, double handlingFee){ + return new ElectronicPackage(name, notes, price, weight, delivered, expectedDate, handlingFee); + } + } +} + //public static PackageInfo getInstance(PackageType type, String name, String notes, double price, double weight, boolean delivered, LocalDateTime expectedDate, @Nullable String author, @Nullable LocalDateTime expiryDate, @Nullable double handlingFee){ + //} diff --git a/src/PerishablePackage.java b/src/PerishablePackage.java new file mode 100644 index 0000000..a589e49 --- /dev/null +++ b/src/PerishablePackage.java @@ -0,0 +1,15 @@ +import java.time.LocalDateTime; + +public class PerishablePackage extends PackageInfo{ + LocalDateTime expiryDate; + + 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; + } + + @Override + public String toString() { + return super.toString()+"expiryDate=" + expiryDate; + } +}