วันเสาร์ที่ 5 ธันวาคม พ.ศ. 2558

[LAB8] Data Student #JAVA

public class DataStudent
{
  private String name;
  private int sID;
  private int age;
  private int height;
  private int weight;


  public DataStudent(String name, int sID, int age,  int height, int weight)
  {
    this.name = name;
    this.sID = sID;
    this.age = age;
    this.height = height;
    this.weight = weight;
  }

  public void display()
  {
    System.out.println(this.name);
    System.out.println(this.sID);
    System.out.println(this.age);
    System.out.println(this.height);
    System.out.println(this.weight+"\n");
  }

  public static void main(String[] args)
  {
    DataStudent[] s =
    {
      new DataStudent("Nop",20046,28,173,52),
      new DataStudent("Pee",20054,35,176,67),
      new DataStudent("Fern",20097,26,174,58),
    };
 
      //Display_student
      int i = 0;
      while(i < s.length)
      {
        s[i].display();
        i = i + 1;
      }
    }
}

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

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