From eede4af29b368306d5f671fbb4c78c398ad169a5 Mon Sep 17 00:00:00 2001 From: Prince Date: Wed, 24 Sep 2025 07:55:25 +0530 Subject: [PATCH 1/2] feat: add shipmentStatus and insuranceAmount fields to Shipment.java --- src/org/edureka/shipping/Shipment.java | 207 ++++++++++++++----------- 1 file changed, 114 insertions(+), 93 deletions(-) diff --git a/src/org/edureka/shipping/Shipment.java b/src/org/edureka/shipping/Shipment.java index 3e9822d..466c155 100644 --- a/src/org/edureka/shipping/Shipment.java +++ b/src/org/edureka/shipping/Shipment.java @@ -3,97 +3,118 @@ import java.util.Date; public class Shipment { - int resourceId; - Date shipmentDate; - Date expiryDate; - String deliveryText; - Order order; - ShipmentLocation shipmentLocation; - Date deliveryDate; - int trackigNumber; - int chargeAmount; - - public int getResourceId() { - return resourceId; - } - - public void setResourceId(int resourceId) { - this.resourceId = resourceId; - } - - public Date getShipmentDate() { - return shipmentDate; - } - - public void setShipmentDate(Date shipmentDate) { - this.shipmentDate = shipmentDate; - } - - public Date getExpiryDate() { - return expiryDate; - } - - public void setExpiryDate(Date expiryDate) { - this.expiryDate = expiryDate; - } - - public String getDeliveryText() { - return deliveryText; - } - - public void setDeliveryText(String deliveryText) { - this.deliveryText = deliveryText; - } - - public Order getOrder() { - return order; - } - - public void setOrder(Order order) { - this.order = order; - } - - public ShipmentLocation getShipmentLocation() { - return shipmentLocation; - } - - public void setShipmentLocation(ShipmentLocation shipmentLocation) { - this.shipmentLocation = shipmentLocation; - } - - public Date getDeliveryDate() { - return deliveryDate; - } - - public void setDeliveryDate(Date deliveryDate) { - this.deliveryDate = deliveryDate; - } - - public int getTrackigNumber() { - return trackigNumber; - } - - public void setTrackigNumber(int trackigNumber) { - this.trackigNumber = trackigNumber; - } - - public int getChargeAmount() { - return chargeAmount; - } - - public void setChargeAmount(int chargeAmount) { - this.chargeAmount = chargeAmount; - } - - static class ShipmentLocation { - String firstName; - String lastName; - String streetAddress; - int Pincode; - } - - static class Order { - int resourceId; - } - + int resourceId; + Date shipmentDate; + Date expiryDate; + String deliveryText; + Order order; + ShipmentLocation shipmentLocation; + Date deliveryDate; + int trackigNumber; + int chargeAmount; + + // NEW FIELDS for assignment + String shipmentStatus; // e.g., Pending, Shipped, Delivered + double insuranceAmount; // insurance cost for shipment + + public int getResourceId() { + return resourceId; + } + + public void setResourceId(int resourceId) { + this.resourceId = resourceId; + } + + public Date getShipmentDate() { + return shipmentDate; + } + + public void setShipmentDate(Date shipmentDate) { + this.shipmentDate = shipmentDate; + } + + public Date getExpiryDate() { + return expiryDate; + } + + public void setExpiryDate(Date expiryDate) { + this.expiryDate = expiryDate; + } + + public String getDeliveryText() { + return deliveryText; + } + + public void setDeliveryText(String deliveryText) { + this.deliveryText = deliveryText; + } + + public Order getOrder() { + return order; + } + + public void setOrder(Order order) { + this.order = order; + } + + public ShipmentLocation getShipmentLocation() { + return shipmentLocation; + } + + public void setShipmentLocation(ShipmentLocation shipmentLocation) { + this.shipmentLocation = shipmentLocation; + } + + public Date getDeliveryDate() { + return deliveryDate; + } + + public void setDeliveryDate(Date deliveryDate) { + this.deliveryDate = deliveryDate; + } + + public int getTrackigNumber() { + return trackigNumber; + } + + public void setTrackigNumber(int trackigNumber) { + this.trackigNumber = trackigNumber; + } + + public int getChargeAmount() { + return chargeAmount; + } + + public void setChargeAmount(int chargeAmount) { + this.chargeAmount = chargeAmount; + } + + // NEW getter/setter for shipmentStatus + public String getShipmentStatus() { + return shipmentStatus; + } + + public void setShipmentStatus(String shipmentStatus) { + this.shipmentStatus = shipmentStatus; + } + + // NEW getter/setter for insuranceAmount + public double getInsuranceAmount() { + return insuranceAmount; + } + + public void setInsuranceAmount(double insuranceAmount) { + this.insuranceAmount = insuranceAmount; + } + + static class ShipmentLocation { + String firstName; + String lastName; + String streetAddress; + int Pincode; + } + + static class Order { + int resourceId; + } } From d3d8f3b090f1928f6a0383bcd6da4e411ae75716 Mon Sep 17 00:00:00 2001 From: Prince Date: Wed, 24 Sep 2025 08:32:40 +0530 Subject: [PATCH 2/2] feat: implement ShipmentServiceImpl with add, delete, and get operations --- .../edureka/shipping/ShipmentServiceImpl.java | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/org/edureka/shipping/ShipmentServiceImpl.java b/src/org/edureka/shipping/ShipmentServiceImpl.java index 695b10c..c87434f 100644 --- a/src/org/edureka/shipping/ShipmentServiceImpl.java +++ b/src/org/edureka/shipping/ShipmentServiceImpl.java @@ -1,23 +1,39 @@ package org.edureka.shipping; +import java.util.HashMap; +import java.util.Map; + public class ShipmentServiceImpl implements IShipment { - @Override - public boolean addShipment() { - // TODO Auto-generated method stub - return false; - } + private Map shipments = new HashMap<>(); - @Override - public boolean deleteShipment() { - // TODO Auto-generated method stub - return false; - } + @Override + public boolean addShipment() { + Shipment shipment = new Shipment(); + shipment.setResourceId(101); + shipment.setDeliveryText("Shipment Added"); + shipments.put(shipment.getResourceId(), shipment); + System.out.println("Shipment added successfully: " + shipment.getResourceId()); + return true; + } - @Override - public boolean getShipment() { - // TODO Auto-generated method stub - return false; - } + @Override + public boolean deleteShipment() { + if (shipments.containsKey(101)) { + shipments.remove(101); + System.out.println("Shipment deleted successfully: 101"); + return true; + } + return false; + } + @Override + public boolean getShipment() { + if (shipments.containsKey(101)) { + Shipment shipment = shipments.get(101); + System.out.println("Shipment found: " + shipment.getDeliveryText()); + return true; + } + return false; + } }