`

oob-case

阅读更多

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);

}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics