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

Lab 3 : Delivery Charge

 
void setup(){
  background(#3B7EE8);
  size(500,500);
  textAlign(CENTER);                  //text
  textSize(40);
  fill(#ffffff);
  text("Delivery Charge",width/2,70);

  // package
  //     Letter = 1        Box = 2
  // Service
  //     Next Day Priority = 1    Next Day Standard = 2    2-Day = 3

  int pack=2;
  int ser=3;
  int weight=2;

  charge(pack,ser,weight);
}

void charge(int pack,int ser,int weight){

  textSize(25);
  textAlign(LEFT);

  if(pack==1){
    text("Package Type = Letter",50,height/2-100);
  }else if(pack==2){
    text("Package Type = Box",50,height/2-100);
  }else{
    text("Package Type = No Package",50,height/2-100);
  }

  // ----------- PACKAGE LETTER ----------
  if(pack==1 && ser==1){
    text("Your Service = Next Day Standard",50,height/2);
     if(weight<=8){
       text("Your Weight = "+weight+" oz",50,height/2+100);
       text("Cost = 10.50 $",50,height-50);
     }
     if(weight>8){
       text("Your Weight = Overweight",50,height/2+100);
       text("Cost = - $",50,height-50);
     }
  }if(pack==1 && ser==2){
    text("Your Service = Next Day Priority",50,height/2);
     if(weight<=8){
       text("Your Weight = "+weight+" oz",50,height/2+100);
       text("Cost = 12 $",50,height-50);
     }
     if(weight>8){
       text("Your Weight = Overweight",50,height/2+100);
       text("Cost = - $",50,height-50);
     }
  }if(pack==1 && ser==3){
    text("Your Service = 2-Day",50,height/2);
    text("Your Weight = Not available",50,height/2+100);
    text("Cost = Not available",50,height-50);
  }

  // ----------- PACKAGE BOX ----------
  float weightPack2Ser1 = (weight/weight*15.75)+(weight-1)*1.25;
  float weightPack2Ser2 = (weight/weight*13.75)+(weight-1)*1;
  float weightPack2Ser3 = (weight/weight*7)+(weight-1)*0.5;
  if(pack==2 && ser==1){
    text("Your Service = Next Day Standard",50,height/2);
    text("Your Weight = "+weight+" pound",50,height/2+100);
    text("Cost = "+weightPack2Ser1+"$",50,height-50);
  }if(pack==2 && ser==2){
    text("Your Service = Next Day Standard",50,height/2);
    text("Your Weight = "+weight+" pound",50,height/2+100);
    text("Cost = "+weightPack2Ser2+"$",50,height-50);
  }if(pack==2 && ser==3){
    text("Your Service = Next Day Standard",50,height/2);
    text("Your Weight = "+weight+" pound",50,height/2+100);
    text("Cost = "+weightPack2Ser3+"$",50,height-50);
  }


}

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

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