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

Lab3-Leap year

int whenYear = 1997;
void setup(){
    size(500,500);
    background(#FFFFCC);

    }
void draw(){
    textSize(50);
    fill(0);
    word();

     }
void word(){
    text("Leap Year",width/5,height/5);
    text(+whenYear,width/2-230,height/2);
    showLeap(leapYear(whenYear));  
}
void showLeap(boolean booLean){
  if (booLean == true){
    fill(255,0,0);
    text("is Leap Year ",width/2-110,height/2);
    fill(#666666);
  }else{
    text("isn't Leap Year ",width/2-110,height/2);
  }
}

boolean leapYear(int whenYear){
  boolean value=false;
  if(whenYear%4 == 0){
    if(whenYear%100 ==0){
      if(whenYear%400 ==0){
        value = true;}
      }else{
        value = true;}
    }else{
      value = false;
    }
    return value;
}

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

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