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

lab 8 data by java

public class Student {
 
  private String name;
 
  private int weight;
   
  private int high;
   
  private int age;
 
  private int ID;

  public  Student(String name , int weight , int high , int age , int ID ) {
     
  this.name = name ;
     
    this.weight = weight;
     
    this.high = high;
     
    this.age = age;
     
    this.ID = ID;
   }
 
  public void display() {

    System.out.println( "NAME: "+this.name);
    System.out.println( "WEIGHT:"+this.weight+"  kg.");
    System.out.println( "HIGH:"+this.high+"  cm.");
    System.out.println( "AGE :"+this.age+"  years old");
    System.out.println( "ID :"+this.ID);

 }
  public static void main(String[] args) {
    Student[] std = {new Student("Park",40,160,18,1),
                    new Student("Nani",50,180,19,2),
                     new Student("Pepe",80,185,20,3),
                     new Student("Giggs",70,160,18,4),
                     new Student("Laws",85,155,18,5)};
    int index = 0;
    while(index<std.length){
      std[index].display();
      index = index + 1;
    }
  }
}


 
 

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

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