用户名: 密   码:
   飞诺网 加入收藏
飞诺网 软件编程 C C++ Java VB Delphi Foxpro 汇编语言 游戏开发 移动开发 软件工程师 软工与管理 VC shell编程 C#
Java系列教程 Java实例 Java技术文档 lucene J2ME

您当前的位置:飞诺网 >> java >> Java技术文档

oob-case

www.diybl.com    时间 : 2008-08-06  作者:佚名   编辑:本站 点击:   [ 评论 ]

Developing a university Registration system where students register for admission

For registration process students should contact the university registrar

Registrar pass the student details to the validator for validation and return the control back to registrar.

 

 

class Student
{
    String missionId;
    String name;
    int age;
    public Student()
    {
        name = null;
        age = 0;
        System.out.println("Student begin to regist");
    }
    public Student(String s, int i)
    {
        name = s;
        age = i;
    }
    public void getMissionId()
    {
        Registrar r = new Registrar();
        missionId = r.getMissionId(this);
    }
}

class Registrar
{
    private static int id = 0;
    public Registrar()
    {
        System.out.println("Registrar is begin now");
    }
    public String getMissionId(Student s)
    {
        Validator v = new Validator();
        if(v.missionId(s))
        {
            id++;
        }
        String missionId = "S000"+id;
        return missionId;
    }
}

class Validator
{
    public Validator()
    {
        System.out.println("Validator is begin now");
    }
    public boolean missionId(Student s)
    {
        if (s.age<18)
            return false;
        return true;
    }
}
public class UniversityRegistation {
   
    /** Creates a new instance of UniversityRegistation */
    public UniversityRegistation() {
        System.out.println("The system is working now");
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Student s = new Student("bobo",26);
        s.getMissionId();
        System.out.println(s.name+"   "+s.age+"   "+s.missionId);
       
    }
   
}

如果图片或页面不能正常显示请点击这里
Java技术文档推荐文章

文章评论