Advertisement
nguoido

Biến

Mar 25th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. public class Student{
  2.    // Bien instance nay la nhin thay cho bat ky lop con nao.
  3.    public String ten;
  4.    
  5.    // Bien hocphi la chi nhin thay cho lop Student.
  6.    private double hocphi;
  7.    
  8.    // Bien ten duoc gan trong constructor.
  9.    public Student (String tenSV){
  10.       ten = tenSV;
  11.    }
  12.  
  13.    // Bien hocphi duoc gan mot gia tri.
  14.    public void setHocPhi(double hp){
  15.       hocphi = hp;
  16.    }
  17.    
  18.    // Phuong thuc nay in chi tiet ve Student.
  19.    public void inThongTin(){
  20.       System.out.println("Ho va ten: " + ten );
  21.       System.out.println("Hoc phi: " + hocphi);
  22.    }
  23.  
  24.    public static void main(String args[]){
  25.       Student sv1 = new Student("Do Van Khai");
  26.       sv1.setHocPhi(4000);
  27.       sv1.inThongTin();
  28.    }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement