Documente Academic
Documente Profesional
Documente Cultură
//Date: 31.10.2018
//the problem: 3 , laboratory 5
package Problema3;
try{
if(RegNum.check()==true){
System.out.println("Registration numbers is correct!");
}
}
catch(MyException e){
System.out.println(e.getMessage());
}
}//end main
}//end Test
==========================================================
package Problema3;
}//end method
}//end method
//Step 3: we check the delimited fields (we must to have three fields)
//Step 3.1: we check if the first field is made up of letters
for(int i=0;i<v[0];i++){
if((CarRegistrationNumbers.charAt(i)>'Z')||
(CarRegistrationNumbers.charAt(i)<'A')){
throw new MyException("The first field of the registration
number can't contain digits!");
}//end if
}//end for
if((CarRegistrationNumbers.charAt(i)>'9')||
(CarRegistrationNumbers.charAt(i)<'0')){
throw new MyException("The second field of the registration
number can't contain letters!");
}//end if
}//end for
if((CarRegistrationNumbers.charAt(i)>'Z')||
(CarRegistrationNumbers.charAt(i)<'A')){
throw new MyException("The last field of the registration
number can't contain digits!");
}//end if
}//end for
//Step 4: we check if the fields have the required size
//Step 4.1: we check first field
if((v[0]>2)){
throw new MyException("The first field size of the registration number
is greater than two !");
}
if((v[0]<1)){
throw new MyException("The first field size of the registration number
is less than one !");
}
return true;
}//end method
===========================================================
package Problema3;
}//end MyException