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

Report Rasberry Pi.

1.วิธีเขียนโค้ดเหมือนไพท้อนทุกประการ แต่คอมช้ามาก เนตก็ล่มบ่อยมากๆ
2.AS1 รันบนเว็บได้ แต่เข้าหน้าแอดมินไม่ได้
3.Animation เป็นเรื่องเกี่ยวกับ เสือมาเจอเด็กผู้หญิงยืนเต้นอยู่บนแม่น้ำ แล้วก็ตนใจว่าตัวเองกำลังเดินอยู่บนน้ำ จึงรีบวิ่งออกไป

Rasberry Pi.

class student : def __init__(self,name,id,score): self.name = name self.id = id self.score = score def display(self) : print "Name =>" , self.name , " ID => " , self.id , " Score => %3s" % self.score def get_sc(self): return self.score def set_sc(self,va): self.score = va def getGrade(score): if(score >=80): return "A" elif(score >=70): return "B" elif(score >=60): return "C" elif(score >=50): return "D" else: return "F" def count_G(score): gr = [0,0,0,0,0] for i in range (0,len(score),1): if getGrade(score[i].get_sc()) == "A" : gr[0] += 1 elif getGrade(score[i].get_sc()) == "B" : gr[1] += 1 elif getGrade(score[i].get_sc()) == "C" : gr[2] += 1 elif getGrade(score[i].get_sc()) == "D" : gr[3] += 1 elif getGrade(score[i].get_sc()) == "F" : gr[4] += 1 return gr; def C_grade (grade,a): gr = count_G(a) if grade == 'A' : print "Grade " , grade , " = ",gr[0] , "Person" elif grade == 'B' : print "Grade " , grade , " = ",gr[1] , "Person" elif grade == 'C' : print "Grade " , grade , " = ",gr[2] , "Person" elif grade == 'D' : print "Grade " , grade , " = ",gr[3] , "Person" elif grade == 'F' : print "Grade " , grade , " = ",gr[4] , "Person" def s_a_g (a,i): print" Grade = " ,getGrade(a[i].get_sc()) def main(): a = [student("eiei", 01, 100 ), student("kiki", 02, 79 ), student("kuku", 03, 65 ), student("mimi", 04, 51 ), student("mumu", 05, 40 ), student("jiji", 11, 100 ), student("juju", 12, 95 ), student("nini", 13, 98 ), student("nunu", 14, 97 ), student("ahah", 15, 99 )] for ei in range (0,len(a),1): a[ei].display() s_a_g (a,ei) count_G(a) C_grade ('A', a) C_grade ('F', a) main()

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

Inheritance.

def setup():
   a = Students("Gun", 26, 70, 1.74, 30024)
   b = Students("Rit", 25, 60, 1.70, 30076)
   c = Students("Frame", 19, 58.2, 1.73, 30058)
   d = Students("Boat", 16, 65, 1.68, 30020)
   BMI(a)

class Person:
   def __init__(self,name,age,widht,height):
      self.name = name
      self.age = age
      self.widht = widht
      self.height = height
     
   def get_name(self):
      return self.name
 
   def get_age(self):
      return self.age
 
   def get_widht(self):
      return self.widht
 
   def get_height(self):
      return self.height
 
class Students(Person):
   def __init__(self,name,age,widht,height,ID):
      super().__init__(name,age,widht,height)
      self.ID = ID
     
   def get_ID(self):
      return self.ID

def BMI(data_per):
   BMI = data_per.get_widht()/(data_per.get_height()*data_per.get_height())
   print(BMI)
 
setup()

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

Vector.

class Vector:
   def __init__(self, i, j, k):
      self.i = i
      self.j = j
      self.k = k
   
   def print(self):
      print(self.i,"i","+",self.j,"j","+",self.k,"k")
         
   def add(self,b):
      x = self.i + b.i
      y = self.j + b.j
      z = self.k + b.k
      add = Vector(x, y, z)
      return add
   

def setup():
   a = Vector(5,3,4)
   b = Vector(2,1,6)
   c = a.add(b)

   a.print()
   b.print()
   c.print()
 
   assert c.x == 7 and c.y == 4 and c.z == 10
setup()

Fraction.

class Fraction:
   def __init__(self,numer,deno):
      self.numer = numer
      self.deno = deno
   
   def print(self):
      print(self.numer,end="/")
      print(self.deno,end="")
      print()
         
   def add(self,b):
      o = (self.numer*b.deno)+(b.numer*self.deno)
      u = (self.deno*b.deno)
      add = Fraction(o,u)
      return add
   

def setup():
   a = Fraction(5,3)
   b = Fraction(2,-1)
   c = a.add(b)

   a.print()
   b.print()
   c.print()

   assert c.numer == 1 and c.deno == -3
setup()

Complex.

class Complex:
   def __init__(self,real,im):
      self.real = real
      self.im = im
 
   def print(self):
      i = self.im
      if i > 0:
         print(self.real,end="+")
      else:
         print(self.real,end=" ")
      print(self.im,end="i")
      print()
       
   def add(self,b):
      r = self.real + b.real
      ic = self.im + b.im
      add = Complex(r,ic)
      return add
 

def setup():
   a = Complex(5,3)
   b = Complex(2,-1)
   c = a.add(b)

   a.print()
   b.print()
   c.print()

   assert c.real == 7 and c.im == 2
setup()

Create class Banner for printing a banner.

public class Banner{
    private String word;
    private char font;
 
    public Banner(String word, char font){
      this.word = word;
      this.font = font;
   }
   
    public void display(){
       String B1 = " ##### ";
       String B2 = " #     #   ";
       String B3 = " ##### ";
       String B4 = " #     #   ";
       String B5 = " ##### ";
       String [] B = {B1,B2,B3,B4,B5};
       String L1 = " #          ";
       String L2 = " #          ";
       String L3 = " #          ";
       String L4 = " #          ";
       String L5 = " ##### ";
       String [] L = {L1,L2,L3,L4,L5};
       String U1 = " #        #  ";
       String U2 = " #        #  ";
       String U3 = " #        #  ";
       String U4 = " #        #  ";
       String U5 = "  #### ";
       String [] U = {U1,U2,U3,U4,U5};
       String E1 = " ######  ";
       String E2 = " #              ";
       String E3 = " ######  ";
       String E4 = " #              ";
       String E5 = " ######  ";
       String [] E = {E1,E2,E3,E4,E5};
   
       int iw = 0;
         B = apply_font(B,'#',this.font);
         L = apply_font(L,'#',this.font);
         U = apply_font(U,'#',this.font);
         E = apply_font(E,'#',this.font);
       while(iw < 5){
          int ia = 0 ;        
          while(ia < this.word.length()){
             if(word.charAt(ia) == 'B'){
                System.out.print(B[iw]);
             }else if(word.charAt(ia) == 'L'){
                System.out.print(L[iw]);
             }else if(word.charAt(ia) == 'U'){
                System.out.print(U[iw]);
             }else if(word.charAt(ia) == 'E'){
                System.out.print(E[iw]);
             }ia = ia + 1;
          }System.out.println();
           iw = iw + 1;
       }
    }

      public String[] apply_font(String [] w,char f,char r){
      int i = 0;
      String[] font = new String[w.length]; //String that has length as  w
      while(i < w.length){
        int j = 0;
        font[i]="";
           while(j < w[i].length()){
             if (w[i].charAt(j) == f){
                font[i] = font[i] + r;
            }else{
                font[i] = font[i] + ' ';
            }j += 1;
           }
            i += 1;
       }
        return font;
     }
           
public static void main(String[] args){
    String word = "BLUE";
   Banner B = new Banner(word,'+');
    B.display();

    }
}

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

Display student records, sorted by age, use insertion sort.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }
 
   public void set_name(String name){
      this.name = name;
   }
 
   public void set_ID(int ID){
      this.ID = ID;
   }
 
   public void set_age(int age){
      this.age = age;
   }
 
   public void set_weight(int weight){
      this.weight = weight;
   }
 
   public void set_height(int height){
      this.height = height;
   }
 
     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);
      System.out.println();
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};
    sort(data);
   
    a.display();
    b.display();
    c.display();
    d.display();
    e.display();
   
  }

   public static void sort(Student [] data){
      int i = 1;
      while(i < data.length){
      int value_a = data[i].get_age();
      String value_n = data[i].get_name();
      int value_I = data[i].get_ID();
      int value_w = data[i].get_weight();
      int value_h = data[i].get_height();
      int j = i;
         while(j > 0 && data[j-1].get_age() > value_a){
         data[j].set_age(data[j-1].get_age());
         data[j].set_name(data[j-1].get_name());
         data[j].set_ID(data[j-1].get_ID());
         data[j].set_weight(data[j-1].get_weight());
         data[j].set_height(data[j-1].get_height());
            j = j - 1;
      }
      data[j].set_age(value_a);
      data[j].set_name(value_n);
      data[j].set_ID(value_I);
      data[j].set_weight(value_w);
      data[j].set_height(value_h);
      i = i + 1;
   }
}
}

Find/count number of students with weight < 50.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};  
    find(data);  
  }

   public static void find(Student [] data){
      int i = 0;
      int count = 0;
      while(i < data.length){
         if(data[i].get_weight() < 50){
           count = count + 1;
      }
     i = i + 1;
   }
      System.out.println("Have " + count + " students");
}
}

Find minimum weight of students.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};  
    find(data);  
  }

   public static void find(Student [] data){
      int i = 0;
      int min = data[i].get_weight();
      int index = 0;
      while(i < data.length){
         if(min > data[i].get_weight()){
            min = data[i].get_weight();
            index = i;
      }
     i = i + 1;
   }
      System.out.println("Min is " + data[index].get_name() + " weight = " + min);
}
}

Find/count number of students with age < 30.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};
    count(data);
  }

   public static void count(Student [] data){
      int i = 0;
      int count = 0;
      while(i < data.length){
         if(data[i].get_age() < 30){
         count = count + 1;
         
      }
          i = i + 1;
   
   }
       System.out.println("Have " + count + " students");
}
}

Find average age of students.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};  
    average(data);  
  }

   public static void average(Student [] data){
      int i = 0;
      int total = 0;
      int n = 0;
      float average = 0;
      while(i < data.length){
        total = total + data[i].get_age();
        n = n + 1;
        average = total/n;
        i += 1 ;      
      }
     System.out.println("average age = " + average);
   }
}

Find/count&display number of students with BMI > 25.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};  
    BMI(data);  
  }

   public static void BMI(Student [] data){
      int i = 0;
      float BMI = 0;
      int count = 0;
      while(i < data.length){
        BMI = data[i].get_weight()*100*100/((data[i].get_height()*(data[i].get_height())));
         if(BMI > 25){
            System.out.println(data[i].get_name() +" BMI value = " +BMI);
            count = count + 1;
         }
       
         i += 1 ;
       
      }
     
        System.out.println("Have" + count + "Students");
     
   }
}

Find student BMI.

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 String get_name(){
        return this.name;
  }

  public int get_ID(){
        return this.ID;
  }

  public int get_age(){
        return this.age;
  }

  public int get_weight(){
        return this.weight;
  }

  public int get_height(){
        return this.height;
  }

  public static void main(String[] args){
    Student a = new Student("Gun" , 32075, 26, 80, 174);
    Student b = new Student("Rit" , 32078, 25, 70, 170);
    Student c = new Student("Frame" , 32080, 19, 58, 173);
    Student d = new Student("Coffee"  , 32057, 18, 50, 168);
    Student e = new Student("Boat" , 32087, 16, 60, 165);
 
    Student [] data = {a,b,c,d,e};  
    BMI(data);  
  }

   public static void BMI(Student [] data){
      int i = 0;
      float BMI = 0;
      while(i < data.length){
        BMI = data[i].get_weight()*100*100/((data[i].get_height()*(data[i].get_height())));
        System.out.println(data[i].get_name() +" BMI value = " +BMI);
        i += 1 ;
      }
   }
}

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

Display each student record.

public class Students {
   private String name;
   private int ID;
   private int age;
   private int weight;
   private int height;
 
   public Students(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 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);
     System.out.println();
   }
 
   public static void main(String[] args) {
      Students a = new Students ("Gun", 32075, 26, 70, 174);
      Students b = new Students ("Rit", 32078, 25, 60, 170);
      Students c = new Students ("Frame", 32080, 19, 58, 173);
      Students d = new Students ("Boat", 32057, 16, 65, 168);
     
      Students [] data = {a, b, c, d};
      display(data);
   }
 
   public static void display(Students [] data){
      int i = 0;
      while(i < data.length){
        data[i].display();
        i = i + 1 ;
      }
   }
}

Link Video Presentation Resort Managemant System Project.

Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน  ทองมณี  5801012620011 ลำดับภาพ: สุพิชชา  ศรีศิริ...