Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 114 additions & 93 deletions src/org/edureka/shipping/Shipment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
28 changes: 28 additions & 0 deletions src/org/edureka/shipping/Utilities.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
package org.edureka.shipping;

import java.util.HashMap;
import java.util.Map;

public class Utilities {

private static Map<Integer, Shipment> shipmentData = new HashMap<>();

public static void addShipment(Shipment shipment) {
shipmentData.put(shipment.getResourceId(), shipment);
System.out.println("Shipment added in memory: " + shipment.getResourceId());
}

public static Shipment getShipment(int resourceId) {
if (shipmentData.containsKey(resourceId)) {
System.out.println("Shipment retrieved from memory: " + resourceId);
return shipmentData.get(resourceId);
}
System.out.println("Shipment not found in memory: " + resourceId);
return null;
}

public static boolean deleteShipment(int resourceId) {
if (shipmentData.containsKey(resourceId)) {
shipmentData.remove(resourceId);
System.out.println("Shipment deleted from memory: " + resourceId);
return true;
}
System.out.println("Shipment not found to delete: " + resourceId);
return false;
}
}