اذهب إلى المحتوى
  • 0

ارجو المساعدة في حل كود جافا

حنان العبطان

السؤال

Recommended Posts

  • 0
public class Shipment {
  private int number;
  private String destination;
  private String deliveryOptions;
  private double deliveryPrice;

  public Shipment(int number, String destination, String deliveryOptions, double deliveryPrice) {
    this.number = number;
    this.destination = destination;
    setDeliveryOptions(deliveryOptions);
    this.deliveryPrice = deliveryPrice;
  }

  public int getNumber() {
    return number;
  }

  public void setNumber(int number) {
    this.number = number;
  }

  public String getDestination() {
    return destination;
  }

  public void setDestination(String destination) {
    this.destination = destination;
  }

  public String getDeliveryOptions() {
    return deliveryOptions;
  }

  public void setDeliveryOptions(String deliveryOptions) {
    if (deliveryOptions.equals("PickUp") || deliveryOptions.equals("HomeDelivery")) {
      this.deliveryOptions = deliveryOptions;
    } else {
      System.out.println("Invalid delivery option, only 'PickUp' or 'HomeDelivery' are allowed.");
    }
  }

  public double getDeliveryPrice() {
    return deliveryPrice;
  }

  public void setDeliveryPrice(double deliveryPrice) {
    this.deliveryPrice = deliveryPrice;
  }

  public double calPriceWithTax() {
    return deliveryPrice * 1.15 + deliveryPrice;
  }
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...