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;
}
}
46 changes: 31 additions & 15 deletions src/org/edureka/shipping/ShipmentServiceImpl.java
Original file line number Diff line number Diff line change
@@ -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<Integer, Shipment> 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;
}
}