master
mms37 2 years ago
parent 76443602f5
commit dfdda34bd8

@ -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"}]

@ -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 + '\'';
}
}

@ -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;
}
}

@ -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){
//}

@ -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;
}
}
Loading…
Cancel
Save