[POO] removed regex for names

This commit is contained in:
TiagoRG 2023-03-21 19:00:48 +00:00
parent 1adbd66679
commit 469cc51a11
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
3 changed files with 3 additions and 7 deletions

View File

@ -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;
}

View File

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

View File

@ -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;
}