[POO] removed regex for names
This commit is contained in:
parent
1adbd66679
commit
469cc51a11
|
@ -19,8 +19,6 @@ public class Person {
|
|||
public void setName(String name) {
|
||||
if (name == null || name.isEmpty())
|
||||
throw new IllegalArgumentException("Name cannot be null or empty");
|
||||
if (!name.matches("^[a-zA-Z ]+$"))
|
||||
throw new IllegalArgumentException("Name must only contain letters and spaces");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ public class PersonTest {
|
|||
public static void main(String[] args) {
|
||||
Scanner sin = new Scanner(System.in);
|
||||
|
||||
Student al = new Student ("Andreia Melo", 9855678,new DateYMD(18, 7, 1990), new DateYMD(1, 9, 2018));
|
||||
Professor p1 = new Professor("Jorge Almeida", 3467225, new DateYMD(13, 3, 1967), "Associado", "Informática");
|
||||
Bolser bls = new Bolser ("Igor Santos", 8976543, new DateYMD(11, 5, 1985), p1, 900);
|
||||
Student al = new Student ("Andreia Melo", 98556781,new DateYMD(18, 7, 1990), new DateYMD(1, 9, 2018));
|
||||
Professor p1 = new Professor("Jorge Almeida", 34672215, new DateYMD(13, 3, 1967), "Associado", "Informática");
|
||||
Bolser bls = new Bolser ("Igor Santos", 89765431, new DateYMD(11, 5, 1985), p1, 900);
|
||||
bls.setMonthlyAmount(1050);
|
||||
System.out.println("Student:"+ al.getName());
|
||||
System.out.println(al);
|
||||
|
|
|
@ -29,8 +29,6 @@ public class Professor extends Person {
|
|||
public void setDepartment(String department) {
|
||||
if (department == null || department.isEmpty())
|
||||
throw new IllegalArgumentException("Department cannot be null or empty");
|
||||
if (!department.matches("^[a-zA-Z ]+$"))
|
||||
throw new IllegalArgumentException("Invalid department");
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue