Notes
Notes - notes.io |
interface PhoneNumber {
boolean numberFormat(String number);
}
abstract class country implements PhoneNumber {
boolean isNumber(String number) {
int ctr = 0;
for (int i = 0; i < number.length(); i++) {
char ch = number.charAt(i);
int ascii = ch;
if ((ascii >= 48 && ascii <= 57) || ascii == 43 || ascii == 32 || ascii == 45) {
ctr++;
}
}
if (ctr == number.length()) {
return true;
} else {
return false;
}
}
}
class india extends country {
public boolean numberFormat(String number) {
if (isNumber(number)) {
if (number.length() == 14) {
boolean res = Pattern.matches("^\+[9][1][-][0-9]{10}", number);
if (res) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
}
class brazil extends country {
public boolean numberFormat(String number) {
if (isNumber(number)) {
if (number.length() == 17) {
boolean res = Pattern.matches("^\+[5][5][\s][0-9]{2}[\s][0-9]{5}[-][0-9]{4}", number);
if (res) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
}
class norway extends country {
public boolean numberFormat(String number) {
if (isNumber(number)) {
if (number.length() == 15) {
boolean res = Pattern.matches("^\+[4][7][-][0-9]{2}[-][0-9]{2}[-][0-9]{2}[-][0-9]{2}", number);
if (res) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
}
class qatar extends country {
public boolean numberFormat(String number) {
if (isNumber(number)) {
if (number.length() == 14) {
boolean res = Pattern.matches("^\+[9][7][4][\s][0-9]{4}[-][0-9]{4}", number);
if (res) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
}
class turkey extends country {
public boolean numberFormat(String number) {
if (isNumber(number)) {
if (number.length() == 14 || number.length() == 12) {
if ((Pattern.matches("^\+[9][0][\s][0-9]{3}[-][0-9]{6}", number))
|| (Pattern.matches("^[0-9]{4}[-][0-9]{3}[-][0-9]{3}", number))) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
}
public class Test13 {
public static void main(String[] args) {
india in = new india();
boolean result1 = in.numberFormat("+91-9972443355");
System.out.print(result1);
brazil br = new brazil();
boolean result2 = br.numberFormat("+55 15 99999-9999");
System.out.print(result2);
norway nr = new norway();
boolean result3 = nr.numberFormat("+47-49-99-99-99");
System.out.print(result3);
qatar qr = new qatar();
boolean result4 = qr.numberFormat("+974 3399-9999");
System.out.print(result4);
turkey tr = new turkey();
boolean result5 = tr.numberFormat("0509-999-999");
System.out.print(result5);
}
}
|
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team