วันพุธที่ 17 ธันวาคม พ.ศ. 2557

Assignment2 ส่วนแก้ไขต่างๆ

ในโปรแกรมได้ทำการแก้ไขส่วนต่างๆ ดังนี้
*ส่วนที่เขียนด้วยตัวอักษรสีดำคือ "ส่วนเดิมที่ไม่ถูกแก้ไข"
**ส่วนที่เขียนด้วยตัวักษรสีแดงคือ "ส่วนที่ได้รับการแก้ไขแล้ว"

----หัวข้อ Array -----
แก้ไขโดยทำเนื้อหาการสอนเพิ่ม
เรื่องการนำลูปเข้ามาใช้ในการวน index แต่ละตัวใน array 1มิติ

int y4 = 700;
int y5 = 700;
int y6 = 700;

void setup () {
  size (900, 700);
}

void draw () {
  // Array_1 ();
  //Array_2 ();
  //Array_3();
}

void Array_1 () {
  background (102, 0, 51);
  for (int y = 0; y<width; y=y+220) {
    noStroke();
    fill (51, 0, 102);
    rect (0, y, width, 110);
  }
  fill (255);
  textSize(45);
  text ("Array 1 D", (width/2)-110, 70);
  Array_move1 ();
}

void Array_2 () {
  background (255, 0, 0);
  noStroke();
  fill (102, 51, 0);
  ellipse (width/2, height/2, 950, 750);

  fill (255);
  textSize(45);
  text ("Array 1 D", (width/2)-80, 70);
  Array_move2 ();
}

void Array_3 () {
  background (255, 102, 102);
  noStroke();
  fill (255, 255, 153);
  ellipse (width/2, height/2, 950, 750);

  fill (0);
  textSize(45);
  text ("Array 1 D", (width/2)-80, 70);
  Array_move3 ();
}

void Array_2_Article (int y4) {
  fill (204, 255, 102);
  textSize(30);
  text ("How to use", (width/2)-75, y4);
  text ("Parallel Array", (width/2)-75, y4+380);
  textSize (25);
  text ("Principle is similar to that of the variable. The steps as follows.", 80, y4+30);
  textSize (20);
  fill (255, 255, 0);
  text ("Step 1 : Declare", 120, y4+60);
  text ("Type follow by a symbol indicating the array and follow Array named.", 100, y4+80);
  text ("For Exemple", 100, y4+100);
  text ("int [] Value = new int [3];", 100, y4+120);
  text ("//Array declaration New at length 3", 100, y4+140);
  text ("Step 2 : Defined", 120, y4+160);
  text ("Add a value to the array within the braces.", 100, y4+180);
  text ("For Example", 100, y4+200);
  text ("int Value [] = {12, 13, 15, 17};", 100, y4+220);
  text ("//Defined value of Array, value are 12, 13, 15, 17", 100, y4+240);
  text ("Step 3 : Run", 120, y4+260);
  text ("Write a Array name only", 100, y4+280);
  text ("For Example", 100, y4+300);
  text ("Calculate (Value);", 100, y4+320);
  text ("//Pull out the value in array to use in function", 100, y4+340);

  text ("Similar to Array 1 D very different in that each Array index is equal.", 100, y4+410);
  text ("For Example", 100, y4+430);
  text ("String [] name = {''Lucy'', ''John'', ''David''};", 100, y4+450);
  text ("int [] salary = {20000, 15000, 35000};", 100, y4+470);
}

void Array_3_Article (int y6) {
  fill (102, 0, 51);
  textSize(30);
  text ("For-Loop that index of Array", (width/2)-200, y6);
  textSize (25);
  text ("We use a for-loop to load data in each of index of Array", 120, y6+30);
  textSize (20);
  fill (102, 51, 0);
  text ("EXAMPLE:", 120, y6+60);
  text ("int sum = 0;", 100, y6+80);
  text ("int [] a = {2, 4, 9, 10, 15};", 100, y6+100);
  text ("for (int i = 0; i<a.length; i++) {", 100, y6+120);
  text ("sum = sum + a[i]; }", 100, y6+140);

  fill (204, 51, 102);
  text ("ARRAY LIKE A BOX THAT WE LOAD DATA ON IT", 100, y6+190);

  fill (255, 0, 0);
  rect (205, y6+230, 150, 150);

  fill (0, 255, 0);
  rect (385, y6+230, 150, 150);

  fill (0, 0, 255);
  rect (565, y6+230, 150, 150);

  fill(255);
  textSize (20);
  text ("INDEX = 0", 233, y6+305);
  text ("INDEX = 1", 413, y6+305);
  text ("INDEX = 2", 593, y6+305);
  fill (0);
  text ("Click to each box for look data in box", (width/2)-150, y6+500);

  if (mouseX >= 205 && mouseX <= 355 && mouseY >= y6+230 && mouseY <= y6+380) {
    fill (125, 5, 245);
    text ("data in box of index 0", 180, y6+450);
    stroke (53, 53, 53);
    strokeWeight (7);
    line (270, y6+430, 270, y6+400);
    line (260, y6+420, 270, y6+400);
    line (280, y6+420, 270, y6+400);
    noStroke();
  }
  if (mouseX >= 385 && mouseX <= 535 && mouseY >= y6+230 && mouseY <= y6+380) {
    fill (125, 5, 245);
    text ("data in box of index 1", 360, y6+450);
    stroke (53, 53, 53);
    strokeWeight (7);
    line (450, y6+430, 450, y6+400);
    line (440, y6+420, 450, y6+400);
    line (460, y6+420, 450, y6+400);
    noStroke();
  }

  if (mouseX >= 565 && mouseX <= 715 && mouseY >= y6+230 && mouseY <= y6+380) {
    fill (125, 5, 245);
    text ("data in box of index 2", 540, y6+450);
    stroke (53, 53, 53);
    strokeWeight (7);
    line (630, y6+430, 630, y6+400);
    line (620, y6+420, 630, y6+400);
    line (640, y6+420, 630, y6+400);
    noStroke();
  }
}


void Array_MindMap (int y5) {
  stroke (255, 0, 102);
  strokeWeight(10);
  line ((width/2)-5, y5+45, (width/2)-5, y5+100);
  line ((width/2)-210, y5+100, (width/2)+110, y5+100);

  line ((width/2)+255, y5+130, (width/2)+255, y5+185);
  line ((width/2)-275, y5+130, (width/2)-275, y5+195);
  line ((width/2)-275, y5+160, (width/2)-25, y5+160);
  line ((width/2)-25, y5+160, (width/2)-25, y5+304);

  line ((width/2)-275, y5+365, (width/2)-275, y5+305);
  line ((width/2)-275, y5+305, (width/2)-140, y5+305);
  line ((width/2)-140, y5+305, (width/2)-140, y5+160);

  strokeWeight (3);
  stroke(255, 255, 0);
  fill (255, 0, 102);
  ellipse ((width/2), y5, 300, 100);
  fill (0);
  textSize (40);
  text ("array 1 D", (width/2)-90, y5+10);
  //First Topic

  fill (102, 255, 0);
  ellipse ((width/2)-250, y5+100, 300, 70);
  ellipse ((width/2)+250, y5+100, 300, 70);
  fill (0);
  textSize (30);
  text ("How to use?", (width/2)-340, y5+110);
  text ("Parallel Array", (width/2)+160, y5+110);
  //Second Topic

  fill (255, 255, 0);
  ellipse ((width/2)-280, y5+230, 230, 80);
  ellipse ((width/2)-30, y5+340, 230, 80);
  ellipse ((width/2)-280, y5+400, 180, 80);
  ellipse ((width/2)+260, y5+230, 350, 100);

  fill (0);
  textSize (20);
  text ("Array Declaration", (width/2)-365, y5+235);
  text ("Array Assignment", (width/2)-115, y5+345);
  text ("Array Run", (width/2)-330, y5+405);
  text ("Array 1 D that length of index", (width/2)+120, y5+230);
  text ("in each of array to equal", (width/2)+150, y5+250);
  //Thrid Topic
  noStroke();
}

void Array_bicycle (float driveBicycle) {
  strokeWeight (5);
  stroke (0);
  ellipse (driveBicycle-50, (height)-40, 70, 70);
  ellipse (driveBicycle+70, (height)-60, 100, 100);
  fill (102);
  ellipse (driveBicycle-50, (height)-40, 20, 20);
  ellipse (driveBicycle+70, (height)-60, 50, 50);

  strokeWeight (10);
  stroke (102, 51, 0);
  line (driveBicycle, (height)-120, driveBicycle+30, (height)-120);

  strokeWeight (15);
  stroke (255, 51, 0);
  line (driveBicycle-50, (height)-60, driveBicycle+50, (height)-60);
  line (driveBicycle-50, (height)-190, driveBicycle-50, (height)-50);
  line (driveBicycle-50, (height)-140, driveBicycle+50, (height)-90);
  line (driveBicycle-70, (height)-190, driveBicycle-10, (height)-190);
}

void Array_move1 () {
  Array_MindMap (y5);
  y5--;
  if (y5==150) {
    y5++;
    fill (255);
    textSize(20);
    text ("Click mouse left to go to next page", 150, height-45);
    Array_bicycle(700);
  }
}

void Array_move2 () {
  Array_2_Article (y4);
  y4--;
  if (y4==120) {
    y4++;
  }
}

void Array_move3 () {
  Array_3_Article (y6);
  y6--;
  if (y6==120) {
    y6++;
  }
}

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

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