วันอาทิตย์ที่ 6 กันยายน พ.ศ. 2558

Lab3_Delivery_Service

Delivery Services

void setup() {
  size(500, 300);
  background(#D16565);
  textSize(30);
  text("Expressimo Delivery Service", 50, 100);
  /////1=Next Day Priority 2=Next Day Standard 3=2-Day/////
 /////fill the detail//////
  calculate_letter(0,0);
  calculate_box(1,8);
}
void calculate_letter(int weight, int type_service) {
  textSize(20);
  ///////////// SERVICE OF LETTER////////////
  if (weight<=8&&type_service==1) {
    text("Letter "+weight+" Oz", 100, 200);
    text("Charges = $12.00", 100, 250);
    text(": Next Day Priority", 220, 200);
  } else if (weight<=8&&type_service==2) {
    text("Letter "+weight+" Oz", 100, 200);
    text("Charges = $10.50", 100, 250);
    text(": Next Day Standrard", 220, 200);
  } else if (weight>8||type_service>2) { 
    textSize(25);
    text("Not available", 170, 250);
  }
}
void calculate_box(int weight, int type_service) {
  float value1=(weight-1)*1.25;
  float charge1=15.75;
  float value2=(weight-1)*1.00;
  float charge2=13.75;
  float value3=(weight-1)*0.50;
  float charge3=7.00;
  textSize(20);
  ///////////// SERVICE OF BOX////////////
  if (weight==1&&type_service==1) {
    text("Box "+weight+" pound", 100, 200);
    text("Charge = $15.75", 100, 250);
    text(": Next Day Priority", 270, 200);
  }
  if (weight>1&&type_service==1) {
    text("Box "+weight+" pounds", 100, 200);
    text("Charges = $"+(charge1+value1), 100, 250);
    text(": Next Day Priority", 270, 200);
  }
  if (weight==1&&type_service==2) {
    text("Box "+weight+" pound", 100, 200);
    text("Charge = $13.75", 100, 250);
    text(": Next Day Standrad", 270, 200);
  }
  if (weight>1&&type_service==2) {
    text("Box "+weight+" pounds", 100, 200);
    text("Charges = $"+(charge2+value2), 100, 250);
    text(": Next Day Standrad", 270, 200);
  } 
  if (weight==1&&type_service==3) {
    text("Box "+weight+" pound", 100, 200);
    text("Charge = $7.00", 100, 250);
    text(": 2-Day", 270, 200);
  }
  if (weight>1&&type_service==3) {
    text("Box "+weight+" pounds", 100, 200);
    text("Charges = $"+(charge3+value3), 100, 250);
    text(": 2-Day", 270, 200);
  }else if (type_service>3) { 
    textSize(25);
    text("Not available", 170, 250);
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น