วันพฤหัสบดีที่ 3 กันยายน พ.ศ. 2558

Lab03 : Delivery Charge

// packagetype -> letter=1 , box=2
// service type -> NextDayPriority=1 , NextDayStandard=2 , 2-DAY=3

void setup() {
  size(350, 150); 
  background(51);
  textSize(15);
  int packagetype=2;
  int servicetype=1;
  int weight=1;
  String charge="";
  if (packagetype==1) {
    charge="Package Type : Letter\n";
  } else if (packagetype==2) {
    charge="Package Type : Box\n";
  }
  if (servicetype==1) {
    charge+="Service Type : Next Day Priority\n";
  } else if (servicetype==2) {
    charge+="Service Type : Next Day Standard\n";
  } else if (servicetype==3) {
    charge+="Service Type : 2-Day\n";
  }
  if (packagetype == 1 && servicetype==3) {
    //do noting
  } else if (packagetype==1) {
    charge+="Weight : " + weight +" oz\n";
  } else if (packagetype==2) {
    charge+="Weight : " + weight +" pound\n";
  }
  charge+=delivery_charge(packagetype, servicetype, weight);
  text(charge, (width-textWidth(charge))/2, 50);
}

String delivery_charge (int pktype, int svtype, int weight) {
  float chargebox=0;
  String text1="";
  //================== start package 1 ==================//
  if (pktype==1) {
    if (svtype==1) { //service type 1
      if (weight<=8 && weight>0) {
        fill(#49E34A);
        text1="CHARGE :$ 12.00";
      } else {
        fill(255, 0, 0);
        text1="Not Avaliable - incorrect weight";
      }
    } else if (svtype==2) { // service type 2
      if (weight<=8 && weight>0) {
        fill(#49E34A);
        text1="CHARGE :$ 10.50";
      } else {
        fill(255, 0, 0);
        text1="Not Avaliable - incorrect weight";
      }
    } else if (svtype==3) { // service type 3
      fill(255, 0, 0);
      text1="Not Avaliable";
    }
  }
  // end package1
  //================== start package 2 ==================//
  if (pktype==2) {
    if (svtype==1) {
      if (weight>0) {
        fill(#49E34A);
        chargebox=15.75+(weight-1)*1.25;
        text1="CHARGE :$ "+chargebox;
      } else {
        fill(255, 0, 0);
        text1="Not Avaliable - incorrect weight";
      }
    } else if (svtype==2) {
      if (weight>0) {
        fill(#49E34A);
        chargebox=13.75+weight-1;
        text1="CHARGE :$ "+chargebox;
      } else {
        fill(255, 0, 0);
        text1="Not Avaliable - incorrect weight";
      }
    } else if (svtype==3) {
      if (weight>0) {
        fill(#49E34A);
        chargebox=7.00+(weight-1)*0.5;
        text1="CHARGE :$ "+chargebox;
      } else {
        fill(255, 0, 0);
        text1="Not Avaliable - incorrect weight";
      }
    }
  }
  // end package2 


  return text1;
}

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

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

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...