วันพุธที่ 4 พฤศจิกายน พ.ศ. 2558

Report Raspberry pi

1.Python : รันได้ตามปกติ แต่จะช้าเล็กน้อย 
2.Run A1 on web : กระตุก , ไม่เจอบัคเพราะว่ากระตุกจนเล่นไม่ได้ครับ 
3.Raspberry pi : เครื่องเล็ก ใช้งานได้ แต่กระตุกไปหน่อย

Raspberry pi lab

class Student:
    def __init__(self,name,id,score):
        self.name=name
        self.id=id
        self.score=score
    def display(self):
        print('name :',self.name)
        print('id :',self.id)
        print('score :',self.score)
    def get_score(self):
        return self.score
    def set_socre(self,score):
        self.score=score
def setup():
    std = [Student('John',1,81),
         Student('Gase',2,80),
         Student('Joh',3,75),
         Student('Blob',4,65),
         Student('Sk',5,85)]
    count_grade('A',std)
    show_allGrade(std)
 
def find_grade(a):
    if a.get_score()>=80 and a.get_score()<=100:
        return 'A'
    elif a.get_score()>=70 and a.get_score()<80:
        return 'B'
    elif a.get_score()>60 and a.get_score()<70:
        return 'C'
    elif a.get_score()>=50 and a.get_score()<60:
        return 'D'
    elif a.get_score()<50 and a.get_score()>=0:
        return 'F'
def count_grade(a,array):
    count=0
    i=0
    while i<len(array):
        if find_grade(array[i])==a:
            count+=1
        i+=1
    print('Grade ',a,'= ',count)
def show_allGrade(a):
    i=0
    while i<len(a):
        a[i].display()
        print('Grade :',find_grade(a[i]))
        i+=1
setup()

วันจันทร์ที่ 2 พฤศจิกายน พ.ศ. 2558

Lab08 : String to Text [Java]

public class Banner {
  private String text="";
  private char style='#';

  public Banner(String text,char style){
    this.text=text;
    this.style=style;
  }
  public void setStyle(char style){
   this.style=style; 
  }
  public void display(){

        String[] A={" ##   ","#  #  ","####  ","#  #  ","#  #  "};
        String[] E={ "####  ", "#     ", "####  ", "#     ", "####  "};
        String[] C={ "####  ", "#     ", "#     ", "#     ", "####  "};
        String[] S={ "####  ", "#     ", "####  ", "   #  ", "####  "};
        int j=0;
    while (j<5){
            int i=0;
          while (i<this.text.length()){
                if (this.text.charAt(i)=='A'){
                    A[j]=replace_one(A[j],'#',this.style);
                    System.out.print(A[j]);
    }
                if (this.text.charAt(i)=='E'){
                    E[j]=replace_one(E[j],'#',this.style);
                    System.out.print(E[j]);
    }
                if (this.text.charAt(i)=='C'){
                    C[j]=replace_one(C[j],'#',this.style);
                    System.out.print(C[j]);
    }
                if (this.text.charAt(i)=='S'){
                    S[j]=replace_one(S[j],'#',this.style);
                    System.out.print(S[j]);
    }
                i+=1;
        }
       System.out.println();
       j+=1;
    }
  }
  public String replace_one(String t,char s,char r){
   StringBuilder temp = new StringBuilder(t);
    for (int i=0;i<t.length();i++){
      if (t.charAt(i)=='#'){
       temp.setCharAt(i,r); 
      }
    }
    return temp.toString();
  }

  public static void main(String[] args){
  Banner B = new Banner("AEC",'x');
    B.display();
   B.setStyle('o');
     B.display();

  }
}

Lab08 : Insertion sort [Java]

public class Student {

 private String name;
 private int id;
 private int age;
 private int weight;
 private int height;

 public Student(String name,int id,int age, int weight,int height) {

   this.name = name;
   this.id = id;
   this.age = age;
   this.weight=weight;
   this.height=height;
 }
  public int getWeight(){
   return this.weight; 
  }
  public int getHeight(){
   return this.height; 
  }
  public int getAge(){
   return this.age; 
  }
  public String getName(){
   return this.name ;
  }
  public int getID(){
   return this.id; 
  }
  public void setWeight(int weight){
   this.weight=weight; 
  }
  public void setHeight(int height){
   this.height=height; 
  }
  public void setAge(int age){
   this.age=age; 
  }
  public void setName(String name){
   this.name=name ;
  }
  public void setID(int id){
   this.id=id; 
  }
  public void display(){
    System.out.println("Name :"+this.name); 
    System.out.println("ID :"+this.id); 
    System.out.println("AGE :"+this.age); 
    System.out.println("WEIGHT :"+this.weight); 
    System.out.println("HEIGHT :"+this.height); 
   }
  public static void main(String[] args) { 

  Student[] std={new Student("Roger",1,18,55,165),
                 new Student("Gold",2,16,49,173),
                 new Student("D",3,17,80,163)};
    insertion_sort(std);
    display_student(std);

 }
  public static void display_student(Student[] std){
     int i=0;
   while (i<std.length){
    std[i].display();
     i+=1;
   } 
  }
  public static void insertion_sort(Student[] std){
    int j;
    for (int i=0;i<std.length;i++){
       j=i ;
         while (j>0 && std[j].getAge()<std[j-1].getAge()){
         swap_student(j,j-1,std);
         j-=1;
       }
    }
  }
  public static void swap_student(int i,int k,Student[] stdnt){
    int temp;
    temp=stdnt[i].getAge(); //1
    stdnt[i].setAge(stdnt[k].getAge());
    stdnt[k].setAge(temp) ;
    temp=stdnt[i].getWeight(); //2
    stdnt[i].setWeight(stdnt[k].getWeight());
    stdnt[k].setWeight(temp) ;
    temp=stdnt[i].getHeight() ;//3
    stdnt[i].setHeight(stdnt[k].getHeight());
    stdnt[k].setHeight(temp) ;
    temp=stdnt[i].getID() ;//4
    stdnt[i].setID(stdnt[k].getID());
    stdnt[k].setID(temp) ;
    String tempo=stdnt[i].getName(); //5
    stdnt[i].setName(stdnt[k].getName());
    stdnt[k].setName(tempo) ;
  }


}

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

Lab08 : Student Class [Java]

public class Student {

 private String name;
 private int id;
 private int age;
 private int weight;
 private int height;

 public Student(String name,int id,int age, int weight,int height) {

   this.name = name;
   this.id = id;
   this.age = age;
   this.weight=weight;
   this.height=height;
 }
  public int get_w(){
   return this.weight; 
  }
  public int get_h(){
   return this.height; 
  }
  public int get_age(){
   return this.age; 
  }
  public String get_name(){
   return this.name ;
  }
  public void display(){
    System.out.println("Name :"+this.name); 
    System.out.println("ID :"+this.id); 
    System.out.println("AGE :"+this.age); 
    System.out.println("WEIGHT :"+this.weight); 
    System.out.println("HEIGHT :"+this.height); 
   }
  public static void main(String[] args) { 

  Student[] std={new Student("Roger",1,15,55,165),
                 new Student("Gold",2,18,49,173),
                 new Student("D",3,17,80,163)};
    display_student(std);
    bmi_student(std);
    age_student(std);
     weight_student(std);
 }
  public static void display_student(Student[] std){
     int i=0;
   while (i<std.length){
    std[i].display();
     i+=1;
   } 
  }
  public static void bmi_student(Student[] std){
    int i=0;
    int count=0;
    while (i<std.length){
      float m=(float)std[i].get_h()/100;
      System.out.print("BMI [ "+std[i].get_name()+" ] ="+(float)std[i].get_w()/(m*m));
      if ((float)std[i].get_w()/(m*m) > 25){
        count+=1;
          System.out.println("<--- (BMI >25)");
      } else {
       System.out.println();
      }
       i+=1;
    }
    System.out.println("count BMI > 25 = "+count);
   
  }
  public static void age_student(Student[] std){
   float avg=0;
    int i=0;
    int count=0;
    while (i<std.length){
     avg+=std[i].get_age(); 
      if (std[i].get_age()<30){
       count+=1; 
      }
      i+=1;
    }
    avg/=std.length;
    System.out.println("average age = "+avg);
    System.out.println("count age < 30 = "+count);
    
  }
  public static void weight_student(Student[] std){
    int min=std[0].get_w();
    int i=0;
    int count=0;
    while (i < std.length){
      if (std[i].get_w() < min){
       min=std[i].get_w(); 
      }
      if (std[i].get_w() < 50){
       count+=1; 
        std[i].display();
      }
      i+=1;
    }
    System.out.println("count Weight < 50 ="+count);
    
  }

}




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

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