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

Lab 3 : Delivery Charge

void setup() {
  size(700, 700);
  background(0);

  cal_charge(2,2,4,22);

  fill(#DE1FFC);
  textSize(80);
    text("Delivery Charge", 40, 200);
}

/////pack1=letter , pack2=box , service1=next day priority , service2=next day standard
/////service3=2-day price=num of packservice

void cal_charge(int pack,int service,int weight,int price) {

  int x=100;
  int y=300;
  float boxprio=15.75+((weight-1)*1.25);
  float boxstard=13.75+((weight-1)*1.00);
  float boxday=7.00+((weight-1)*0.50);

  textSize(35);
  fill(#5A94F0);
  if (pack==1 && service==1 && weight<=8 && price==11){
    text("Package Type : Letter", x, y);
    text("Service type : Next Day Priority", x, y+80);
    text("Weight : "+weight+" oz",x,y+160);
    text("Price : $12.00",x,y+240);
  }
   if (pack==1 && service==2 && weight<=8 && price==12){
    text("Package Type : Letter", x, y);
    text("Service type : Next Day Standard", x, y+80);
    text("Weight : "+weight+" oz",x,y+160);
    text("Price : $10.50",x,y+240);
  }
   if (pack==1 && service==3 && price==13){
    text("Package Type : Letter", x, y);
    text("Service type : 2-Day", x, y+80);
    text("Weight : "+weight+" oz",x,y+160);
    text("Price : Not available",x,y+240);
  }
   if (pack==2 && service==1 && price==21){
    text("Package Type : Box", x, y);
    text("Service type : Next Day Priority", x, y+80);
    text("Weight : "+weight+" pound",x,y+160);
    text("Price : $"+boxprio,x,y+240);
  }
   if (pack==2 && service==2 && price==22){
    text("Package Type : Box", x, y);
    text("Service type : Next Day Standard", x, y+80);
    text("Weight : "+weight+" pound",x,y+160);
    text("Price : $"+boxstard,x,y+240);
  }
   if (pack==2 && service==3 && price==23){
    text("Package Type : Box", x, y);
    text("Service type : 2-Day", x, y+80);
    text("Weight : "+weight+" pound",x,y+160);
    text("Price : $"+boxday,x,y+240);
  }
  if(pack!=1 && pack!=2 || service!=1 && service!=2 && service!=3 || price!=11 && price!=12 && price!=13 && price!=21 && price!=22 && price!=23){
    text("Package Type : Not available", x, y);
    text("Service type : Not available", x, y+80);
    text("Weight : Not available",x,y+160);
    text("Price : Not available",x,y+240);
  }
}


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

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