Student$IStudent

Màu nền
Font chữ
Font size
Chiều cao dòng

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

//Student

package Student;

import java.io.Serializable;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

/**

 *

 * @author QuocViet

 */

public class Student implements Serializable {

    private int sCode;

    private String sName;

    private int sBirth;

    private String sNote;

    public Student(int sCode, String sName, int sBirth, String sNote) {

        this.sCode = sCode;

        this.sName = sName;

        this.sBirth = sBirth;

        this.sNote = sNote;

    }

    public Student() {

    }

    public int getsBirth() {

        return sBirth;

    }

    public void setsBirth(int sBirth) {

        this.sBirth = sBirth;

    }

    public int getsCode() {

        return sCode;

    }

    public void setsCode(int sCode) {

        this.sCode = sCode;

    }

    public String getsName() {

        return sName;

    }

    public void setsName(String sName) {

        this.sName = sName;

    }

    public String getsNote() {

        return sNote;

    }

    public void setsNote(String sNote) {

        this.sNote = sNote;

    }

    //Validate

    public boolean validate()

    {

        //sName phai co nhieu hon 5 ki tu

        if(this.sName.length() <= 5)

        {

            System.out.println("Name must have more than 5 letters");

            return false;

        }

        //sBirth phai co 4 ki tu

        Pattern sB = Pattern.compile("\\d{4}");

        Matcher B = sB.matcher(String.valueOf(this.sBirth));

        if(!B.matches()) {

            System.out.println("Birth must consists of 4 digits");

            return false;

        }

        //sBirth phai > 1982

        if(sBirth <= 1982) {

            System.out.println("Birth must > 1982");

            return false;

        }

        return true;

    }

    @Override

    public String toString()

    {

        return this.getsCode()+"\t"+this.getsName()+"\t"+this.getsBirth()+"\t"+this.getsNote();

    }

}

 

\\IStudent

public interface IStudent {

    //Them 1 Student vao ArrayList

    public boolean add(Student No);

    //Xoa 1 Student thong qua sCode

    public boolean delete(int sCode);

    //Tra ve mang Student co tuoi lon hon Num

    public ArrayList<Student> getList(int num);

    //Hien thi thong tin cua mot mang Student

    public void display(ArrayList<Student> list);

    //Save Student cua mang ArrayList vao text file

    public boolean save(String fileName);

    public void SortAndDisplay();

    public void read(String fileName);

    public void search(int num);

}

Bạn đang đọc truyện trên: Truyen2U.Pro